From 4cf2925a486585bd9d2ea4fc2a30c7318ba0c234 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 25 Nov 2020 11:23:18 +0200 Subject: [PATCH] build script: quakespasm is based on genetic make target --- build.py | 54 +++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/build.py b/build.py index 2986beb8..cdadfb33 100755 --- a/build.py +++ b/build.py @@ -470,9 +470,10 @@ class DevilutionXTarget(CMakeTarget): opts['CMAKE_EXE_LINKER_FLAGS'] += extra_linker_args -class QuakespasmTarget(Target): +class QuakespasmTarget(MakeTarget): def __init__(self, name='quakespasm'): super().__init__(name) + self.src_root = 'Quake' def prepare_source(self, builder: 'Builder'): builder.checkout_git('https://git.code.sf.net/p/quakespasm/quakespasm') @@ -480,32 +481,35 @@ class QuakespasmTarget(Target): def detect(self, builder: 'Builder') -> bool: return os.path.exists(builder.source_path + os.sep + 'Quakespasm.txt') - def configure(self, builder: 'Builder'): - os.makedirs(builder.build_path, exist_ok=True) - Builder.symlink_directory(builder.source_path, builder.build_path) - - def build(self, builder: 'Builder'): - assert not builder.xcode - + def initialize(self, builder: 'Builder'): # TODO: Use macOS specific Makefile which requires manual application bundle creation - args = ( - 'make', '-j', builder.jobs, - 'USE_SDL2=1', 'USE_CODEC_FLAC=1', 'USE_CODEC_OPUS=1', 'USE_CODEC_MIKMOD=1', 'USE_CODEC_UMX=1', - # Use CPUFLAGS instead of CFLAGS to avoid discarding of the latter if we specify them at command line - f'CPUFLAGS=-I{builder.include_path} -I{builder.include_path}opus', - # Use main() alias to workaround executable linking without macOS launcher - # TODO: Specify full paths for all libraries - f'LDFLAGS=-L{builder.lib_path} -lopus -lopusfile -Wl,-alias -Wl,_SDL_main -Wl,_main', - # TODO: Setup sdl2-config - f'SDL_CFLAGS=-I{builder.include_path}SDL2', - f'SDL_LIBS={builder.lib_path}libSDL2.a', - 'COMMON_LIBS=-framework AudioToolbox -framework Carbon -framework Cocoa -framework CoreAudio' - ' -framework CoreVideo -framework ForceFeedback -framework IOKit -framework OpenGL', - # TODO: Enable use of custom macOS SDK and deployment target - ) - work_path = builder.build_path + 'Quake' + opts = self.options + opts['USE_SDL2'] = '1' + opts['USE_CODEC_FLAC'] = '1' + opts['USE_CODEC_OPUS'] = '1' + opts['USE_CODEC_MIKMOD'] = '1' + opts['USE_CODEC_UMX'] = '1' + # TODO: Setup sdl2-config + opts['SDL_CFLAGS'] = f'-I{builder.include_path}SDL2' + opts['SDL_LIBS'] = f'{builder.lib_path}libSDL2.a' + opts['COMMON_LIBS'] = '-framework AudioToolbox -framework Carbon -framework Cocoa -framework CoreAudio' \ + ' -framework CoreVideo -framework ForceFeedback -framework IOKit -framework OpenGL' - subprocess.check_call(args, cwd=work_path) + self._update_env('CFLAGS', f'-I{builder.include_path}opus') + # Use main() alias to workaround executable linking without macOS launcher + self._update_env('LDFLAGS', f'-Wl,-alias -Wl,_SDL_main -Wl,_main') + + for name in ('opus', 'opusfile'): + self._update_env('LDFLAGS', f'{builder.lib_path}lib{name}.a') + + # TODO: Specify full paths for remaining libraries + + def configure(self, builder: 'Builder'): + super().configure(builder) + + # Copy linker flags from enviroment to command line argument, they would be overridden by Makefile otherwise + ldflags = 'LDFLAGS' + self.options[ldflags] = self.environment[ldflags] # Case insensitive dictionary class from