build script: move common code out of concrete dependency target classes

This commit is contained in:
alexey.lysiuk 2020-11-29 13:18:27 +02:00
parent fec150fb5c
commit 79224fa6a1

View file

@ -155,6 +155,20 @@ class ConfigureMakeTarget(Target):
self.make.build(builder) 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): class CMakeTarget(Target):
def __init__(self, name=None): def __init__(self, name=None):
super().__init__(name) super().__init__(name)
@ -259,6 +273,20 @@ class CMakeTarget(Target):
subprocess.check_call(args, cwd=builder.build_path) 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): class ZDoomBaseTarget(CMakeTarget):
def __init__(self, name=None): def __init__(self, name=None):
super().__init__(name) super().__init__(name)
@ -564,7 +592,7 @@ class QuakespasmTarget(MakeTarget):
self.options[ldflags] = self.environment[ldflags] self.options[ldflags] = self.environment[ldflags]
class JpegTurboTarget(CMakeTarget): class JpegTurboTarget(CMakeStaticDependencyTarget):
def __init__(self, name='jpeg-turbo'): def __init__(self, name='jpeg-turbo'):
super().__init__(name) 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', 'https://downloads.sourceforge.net/project/libjpeg-turbo/2.0.6/libjpeg-turbo-2.0.6.tar.gz',
'd74b92ac33b0e3657123ddcf6728788c90dc84dcb6a52013d758af3c4af481bb') 'd74b92ac33b0e3657123ddcf6728788c90dc84dcb6a52013d758af3c4af481bb')
def initialize(self, builder: 'Builder'):
super().initialize(builder)
self.options['ENABLE_SHARED'] = 'NO'
def detect(self, builder: 'Builder') -> bool: def detect(self, builder: 'Builder') -> bool:
return os.path.exists(builder.source_path + 'turbojpeg.h') return os.path.exists(builder.source_path + 'turbojpeg.h')
def post_build(self, builder: 'Builder'):
self.install(builder)
class NasmTarget(ConfigureMakeDependencyTarget):
class NasmTarget(ConfigureMakeTarget):
def __init__(self, name='nasm'): def __init__(self, name='nasm'):
super().__init__(name) super().__init__(name)
@ -596,11 +617,8 @@ class NasmTarget(ConfigureMakeTarget):
def detect(self, builder: 'Builder') -> bool: def detect(self, builder: 'Builder') -> bool:
return os.path.exists(builder.source_path + 'nasm.txt') return os.path.exists(builder.source_path + 'nasm.txt')
def post_build(self, builder: 'Builder'):
self.install(builder)
class OggTarget(ConfigureMakeStaticDependencyTarget):
class OggTarget(ConfigureMakeTarget):
def __init__(self, name='ogg'): def __init__(self, name='ogg'):
super().__init__(name) super().__init__(name)
@ -618,16 +636,9 @@ class OggTarget(ConfigureMakeTarget):
args.remove(test_arg) args.remove(test_arg)
subprocess.check_call(args) subprocess.check_call(args)
def initialize(self, builder: 'Builder'):
super().initialize(builder)
self.options['--enable-shared'] = 'no'
def detect(self, builder: 'Builder') -> bool: def detect(self, builder: 'Builder') -> bool:
return os.path.exists(builder.source_path + 'ogg.pc.in') return os.path.exists(builder.source_path + 'ogg.pc.in')
def post_build(self, builder: 'Builder'):
self.install(builder)
# Case insensitive dictionary class from # Case insensitive dictionary class from
# https://github.com/psf/requests/blob/v2.25.0/requests/structures.py # https://github.com/psf/requests/blob/v2.25.0/requests/structures.py