From 79224fa6a13a679db76f2413d35e74567597ae4a Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sun, 29 Nov 2020 13:18:27 +0200 Subject: [PATCH] build script: move common code out of concrete dependency target classes --- build.py | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/build.py b/build.py index 401858a3..954926ba 100755 --- a/build.py +++ b/build.py @@ -155,6 +155,20 @@ class ConfigureMakeTarget(Target): self.make.build(builder) +class ConfigureMakeDependencyTarget(ConfigureMakeTarget): + def __init__(self, name=None): + super().__init__(name) + + def post_build(self, builder: 'Builder'): + self.install(builder) + + +class ConfigureMakeStaticDependencyTarget(ConfigureMakeDependencyTarget): + def __init__(self, name=None): + super().__init__(name) + self.options['--enable-shared'] = 'no' + + class CMakeTarget(Target): def __init__(self, name=None): super().__init__(name) @@ -259,6 +273,20 @@ class CMakeTarget(Target): subprocess.check_call(args, cwd=builder.build_path) +class CMakeStaticDependencyTarget(Target): + def __init__(self, name=None): + super().__init__(name) + + # Set commonly used variables for static libraries + opts = self.options + opts['BUILD_SHARED_LIBS'] = 'NO' + opts['ENABLE_SHARED'] = 'NO' + opts['LIBTYPE'] = 'STATIC' + + def post_build(self, builder: 'Builder'): + self.install(builder) + + class ZDoomBaseTarget(CMakeTarget): def __init__(self, name=None): super().__init__(name) @@ -564,7 +592,7 @@ class QuakespasmTarget(MakeTarget): self.options[ldflags] = self.environment[ldflags] -class JpegTurboTarget(CMakeTarget): +class JpegTurboTarget(CMakeStaticDependencyTarget): def __init__(self, name='jpeg-turbo'): super().__init__(name) @@ -573,18 +601,11 @@ class JpegTurboTarget(CMakeTarget): 'https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz', 'd74b92ac33b0e3657123ddcf6728788c90dc84dcb6a52013d758af3c4af481bb') - def initialize(self, builder: 'Builder'): - super().initialize(builder) - self.options['ENABLE_SHARED'] = 'NO' - def detect(self, builder: 'Builder') -> bool: return os.path.exists(builder.source_path + 'turbojpeg.h') - def post_build(self, builder: 'Builder'): - self.install(builder) - -class NasmTarget(ConfigureMakeTarget): +class NasmTarget(ConfigureMakeDependencyTarget): def __init__(self, name='nasm'): super().__init__(name) @@ -596,11 +617,8 @@ class NasmTarget(ConfigureMakeTarget): def detect(self, builder: 'Builder') -> bool: return os.path.exists(builder.source_path + 'nasm.txt') - def post_build(self, builder: 'Builder'): - self.install(builder) - -class OggTarget(ConfigureMakeTarget): +class OggTarget(ConfigureMakeStaticDependencyTarget): def __init__(self, name='ogg'): super().__init__(name) @@ -618,16 +636,9 @@ class OggTarget(ConfigureMakeTarget): args.remove(test_arg) subprocess.check_call(args) - def initialize(self, builder: 'Builder'): - super().initialize(builder) - self.options['--enable-shared'] = 'no' - def detect(self, builder: 'Builder') -> bool: return os.path.exists(builder.source_path + 'ogg.pc.in') - def post_build(self, builder: 'Builder'): - self.install(builder) - # Case insensitive dictionary class from # https://github.com/psf/requests/blob/v2.25.0/requests/structures.py