aedi: add glew target

This commit is contained in:
alexey.lysiuk 2021-06-22 17:21:15 +03:00
parent cf3e203d33
commit 21c2dff63d
2 changed files with 42 additions and 0 deletions

View File

@ -70,6 +70,7 @@ def targets():
DumbTarget(),
FmtTarget(),
FreeTypeTarget(),
GlewTarget(),
LzmaTarget(),
MadTarget(),
MikmodTarget(),

View File

@ -78,6 +78,47 @@ class FreeTypeTarget(CMakeStaticDependencyTarget):
shutil.copy(state.patch_path + 'freetype-config', bin_path)
class GlewTarget(CMakeStaticDependencyTarget):
def __init__(self, name='glew'):
super().__init__(name)
self.src_root = 'build/cmake'
self.options['BUILD_UTILS'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.tgz',
'd4fc82893cfb00109578d0a1a2337fb8ca335b3ceccf97b97e5cc7f08e4353e1')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'glew.pc.in')
LINKER_FLAGS = '-framework OpenGL'
def post_build(self, state: BuildState):
super().post_build(state)
def update_linker_flags(line: str):
link_var = ' INTERFACE_LINK_LIBRARIES '
if line.startswith(link_var):
return f'{link_var}"{GlewTarget.LINKER_FLAGS}"\n'
return line
cmake_module = state.install_path + 'lib/cmake/glew/glew-targets.cmake'
self.update_text_file(cmake_module, update_linker_flags)
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
libs = 'Libs:'
if line.startswith(libs):
return libs + ' -L${libdir} -lGLEW ' + GlewTarget.LINKER_FLAGS + os.linesep
return line
class LzmaTarget(CMakeStaticDependencyTarget):
def __init__(self, name='lzma'):
super().__init__(name)