mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2024-12-01 16:11:23 +00:00
parent
e39980838a
commit
a274880aa6
7 changed files with 48 additions and 43 deletions
|
@ -132,6 +132,7 @@ class Builder(object):
|
||||||
|
|
||||||
def _build(self, target: Target):
|
def _build(self, target: Target):
|
||||||
state = self._state
|
state = self._state
|
||||||
|
state.environment = os.environ
|
||||||
|
|
||||||
target.configure(state)
|
target.configure(state)
|
||||||
target.build(state)
|
target.build(state)
|
||||||
|
|
|
@ -52,6 +52,8 @@ class BuildState:
|
||||||
self.verbose = False
|
self.verbose = False
|
||||||
self.jobs = 1
|
self.jobs = 1
|
||||||
|
|
||||||
|
self.environment = os.environ.copy()
|
||||||
|
|
||||||
def architecture(self) -> str:
|
def architecture(self) -> str:
|
||||||
return self.platform.architecture if self.platform else ''
|
return self.platform.architecture if self.platform else ''
|
||||||
|
|
||||||
|
@ -189,3 +191,17 @@ class BuildState:
|
||||||
|
|
||||||
def has_source_file(self, path: typing.Union[str, Path]):
|
def has_source_file(self, path: typing.Union[str, Path]):
|
||||||
return (self.source / path).exists()
|
return (self.source / path).exists()
|
||||||
|
|
||||||
|
def update_environment(self, name: str, value: str):
|
||||||
|
env = self.environment
|
||||||
|
env[name] = env[name] + ' ' + value if name in env else value
|
||||||
|
|
||||||
|
def set_sdk(self, var_name: str):
|
||||||
|
sdk_path = self.sdk_path()
|
||||||
|
if sdk_path:
|
||||||
|
self.update_environment(var_name, f'-isysroot {sdk_path}')
|
||||||
|
|
||||||
|
def set_os_version(self, var_name: str):
|
||||||
|
os_version = self.os_version()
|
||||||
|
if os_version:
|
||||||
|
self.update_environment(var_name, f'-mmacosx-version-min={os_version}')
|
||||||
|
|
|
@ -62,7 +62,6 @@ class BuildTarget(Target):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
|
|
||||||
self.src_root = ''
|
self.src_root = ''
|
||||||
self.environment = os.environ.copy()
|
|
||||||
self.options = CommandLineOptions()
|
self.options = CommandLineOptions()
|
||||||
self.multi_platform = True
|
self.multi_platform = True
|
||||||
|
|
||||||
|
@ -87,7 +86,7 @@ class BuildTarget(Target):
|
||||||
|
|
||||||
os.makedirs(state.build_path, exist_ok=True)
|
os.makedirs(state.build_path, exist_ok=True)
|
||||||
|
|
||||||
env = self.environment
|
env = state.environment
|
||||||
env['PATH'] = os.pathsep.join([
|
env['PATH'] = os.pathsep.join([
|
||||||
str(state.bin_path),
|
str(state.bin_path),
|
||||||
env['PATH'],
|
env['PATH'],
|
||||||
|
@ -100,31 +99,17 @@ class BuildTarget(Target):
|
||||||
env['CXX'] = state.cxx_compiler()
|
env['CXX'] = state.cxx_compiler()
|
||||||
|
|
||||||
for prefix in ('CPP', 'C', 'CXX', 'OBJC', 'OBJCXX'):
|
for prefix in ('CPP', 'C', 'CXX', 'OBJC', 'OBJCXX'):
|
||||||
varname = f'{prefix}FLAGS'
|
var_name = f'{prefix}FLAGS'
|
||||||
|
|
||||||
self._update_env(varname, f'-I{state.include_path}')
|
state.update_environment(var_name, f'-I{state.include_path}')
|
||||||
self._set_sdk(state, varname)
|
state.set_sdk(var_name)
|
||||||
self._set_os_version(state, varname)
|
state.set_os_version(var_name)
|
||||||
|
|
||||||
ldflags = 'LDFLAGS'
|
ldflags = 'LDFLAGS'
|
||||||
|
|
||||||
self._update_env(ldflags, f'-L{state.lib_path}')
|
state.update_environment(ldflags, f'-L{state.lib_path}')
|
||||||
self._set_sdk(state, ldflags)
|
state.set_sdk(ldflags)
|
||||||
self._set_os_version(state, ldflags)
|
state.set_os_version(ldflags)
|
||||||
|
|
||||||
def _update_env(self, name: str, value: str):
|
|
||||||
env = self.environment
|
|
||||||
env[name] = env[name] + ' ' + value if name in env else value
|
|
||||||
|
|
||||||
def _set_sdk(self, state: BuildState, varname: str):
|
|
||||||
sdk_path = state.sdk_path()
|
|
||||||
if sdk_path:
|
|
||||||
self._update_env(varname, f'-isysroot {sdk_path}')
|
|
||||||
|
|
||||||
def _set_os_version(self, state: BuildState, varname: str):
|
|
||||||
os_version = state.os_version()
|
|
||||||
if os_version:
|
|
||||||
self._update_env(varname, '-mmacosx-version-min=' + str(os_version))
|
|
||||||
|
|
||||||
def install(self, state: BuildState, options: CommandLineOptions = None, tool: str = 'gmake'):
|
def install(self, state: BuildState, options: CommandLineOptions = None, tool: str = 'gmake'):
|
||||||
if state.xcode:
|
if state.xcode:
|
||||||
|
@ -136,7 +121,7 @@ class BuildTarget(Target):
|
||||||
args = [tool, 'install']
|
args = [tool, 'install']
|
||||||
args += options and options.to_list() or []
|
args += options and options.to_list() or []
|
||||||
|
|
||||||
subprocess.check_call(args, cwd=state.build_path, env=self.environment)
|
subprocess.check_call(args, cwd=state.build_path, env=state.environment)
|
||||||
|
|
||||||
self.update_pc_files(state)
|
self.update_pc_files(state)
|
||||||
|
|
||||||
|
@ -298,7 +283,7 @@ class MakeTarget(BuildTarget):
|
||||||
args += self.options.to_list()
|
args += self.options.to_list()
|
||||||
|
|
||||||
work_path = state.build_path / self.src_root
|
work_path = state.build_path / self.src_root
|
||||||
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
subprocess.check_call(args, cwd=work_path, env=state.environment)
|
||||||
|
|
||||||
|
|
||||||
class ConfigureMakeTarget(BuildTarget):
|
class ConfigureMakeTarget(BuildTarget):
|
||||||
|
@ -328,17 +313,17 @@ class ConfigureMakeTarget(BuildTarget):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Try with host and disabled dependency tracking first
|
# Try with host and disabled dependency tracking first
|
||||||
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
subprocess.check_call(args, cwd=work_path, env=state.environment)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If it fails, try with disabled dependency tracking only
|
# If it fails, try with disabled dependency tracking only
|
||||||
args = copy.copy(common_args)
|
args = copy.copy(common_args)
|
||||||
args.append(disable_dependency_tracking)
|
args.append(disable_dependency_tracking)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
subprocess.check_call(args, cwd=work_path, env=state.environment)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# Use only common command line arguments
|
# Use only common command line arguments
|
||||||
subprocess.check_call(common_args, cwd=work_path, env=self.environment)
|
subprocess.check_call(common_args, cwd=work_path, env=state.environment)
|
||||||
|
|
||||||
def build(self, state: BuildState):
|
def build(self, state: BuildState):
|
||||||
assert not state.xcode
|
assert not state.xcode
|
||||||
|
@ -415,7 +400,7 @@ class CMakeTarget(BuildTarget):
|
||||||
args += self.options.to_list(CommandLineOptions.CMAKE_RULES)
|
args += self.options.to_list(CommandLineOptions.CMAKE_RULES)
|
||||||
args.append(state.source / self.src_root)
|
args.append(state.source / self.src_root)
|
||||||
|
|
||||||
subprocess.check_call(args, cwd=state.build_path, env=self.environment)
|
subprocess.check_call(args, cwd=state.build_path, env=state.environment)
|
||||||
|
|
||||||
def build(self, state: BuildState):
|
def build(self, state: BuildState):
|
||||||
if state.xcode:
|
if state.xcode:
|
||||||
|
@ -426,7 +411,7 @@ class CMakeTarget(BuildTarget):
|
||||||
if state.verbose:
|
if state.verbose:
|
||||||
args.append('VERBOSE=1')
|
args.append('VERBOSE=1')
|
||||||
|
|
||||||
subprocess.check_call(args, cwd=state.build_path, env=self.environment)
|
subprocess.check_call(args, cwd=state.build_path, env=state.environment)
|
||||||
|
|
||||||
|
|
||||||
class ConfigureMakeDependencyTarget(ConfigureMakeTarget):
|
class ConfigureMakeDependencyTarget(ConfigureMakeTarget):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class Bzip2Target(MakeTarget):
|
||||||
opts['bzip2recover'] = None
|
opts['bzip2recover'] = None
|
||||||
# Copy compiler flags from environment to command line argument, they would be overridden by Makefile otherwise
|
# Copy compiler flags from environment to command line argument, they would be overridden by Makefile otherwise
|
||||||
cflags = 'CFLAGS'
|
cflags = 'CFLAGS'
|
||||||
opts[cflags] = self.environment[cflags] + ' -D_FILE_OFFSET_BITS=64 -O2'
|
opts[cflags] = state.environment[cflags] + ' -D_FILE_OFFSET_BITS=64 -O2'
|
||||||
|
|
||||||
def post_build(self, state: BuildState):
|
def post_build(self, state: BuildState):
|
||||||
self.options['PREFIX'] = state.install_path
|
self.options['PREFIX'] = state.install_path
|
||||||
|
@ -158,7 +158,7 @@ class GlibTarget(BuildTarget):
|
||||||
def configure(self, state: BuildState):
|
def configure(self, state: BuildState):
|
||||||
super().configure(state)
|
super().configure(state)
|
||||||
|
|
||||||
environment = self.environment
|
environment = state.environment
|
||||||
environment['LDFLAGS'] += ' -framework CoreFoundation -framework Foundation'
|
environment['LDFLAGS'] += ' -framework CoreFoundation -framework Foundation'
|
||||||
|
|
||||||
cpu = state.architecture()
|
cpu = state.architecture()
|
||||||
|
@ -194,7 +194,7 @@ endian = 'little'
|
||||||
|
|
||||||
def build(self, state: BuildState):
|
def build(self, state: BuildState):
|
||||||
args = ('ninja',)
|
args = ('ninja',)
|
||||||
subprocess.check_call(args, cwd=state.build_path, env=self.environment)
|
subprocess.check_call(args, cwd=state.build_path, env=state.environment)
|
||||||
|
|
||||||
def post_build(self, state: BuildState):
|
def post_build(self, state: BuildState):
|
||||||
self.install(state, tool='ninja')
|
self.install(state, tool='ninja')
|
||||||
|
@ -224,9 +224,6 @@ class InstPatchTarget(CMakeStaticDependencyTarget):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
self.options['LIB_SUFFIX'] = None
|
self.options['LIB_SUFFIX'] = None
|
||||||
|
|
||||||
# Workaround for missing frameworks in dependencies, no clue what's wrong at the moment
|
|
||||||
self.environment['LDFLAGS'] = '-framework CoreFoundation -framework Foundation'
|
|
||||||
|
|
||||||
def prepare_source(self, state: BuildState):
|
def prepare_source(self, state: BuildState):
|
||||||
state.download_source(
|
state.download_source(
|
||||||
'https://github.com/swami/libinstpatch/archive/v1.1.6.tar.gz',
|
'https://github.com/swami/libinstpatch/archive/v1.1.6.tar.gz',
|
||||||
|
@ -235,6 +232,12 @@ class InstPatchTarget(CMakeStaticDependencyTarget):
|
||||||
def detect(self, state: BuildState) -> bool:
|
def detect(self, state: BuildState) -> bool:
|
||||||
return state.has_source_file('libinstpatch-1.0.pc.in')
|
return state.has_source_file('libinstpatch-1.0.pc.in')
|
||||||
|
|
||||||
|
def configure(self, state: BuildState):
|
||||||
|
# Workaround for missing frameworks in dependencies, no clue what's wrong at the moment
|
||||||
|
state.environment['LDFLAGS'] = '-framework CoreFoundation -framework Foundation'
|
||||||
|
|
||||||
|
super().configure(state)
|
||||||
|
|
||||||
|
|
||||||
class IntlTarget(GettextTarget):
|
class IntlTarget(GettextTarget):
|
||||||
def __init__(self, name='intl'):
|
def __init__(self, name='intl'):
|
||||||
|
|
|
@ -126,7 +126,7 @@ class FreeImageTarget(MakeTarget):
|
||||||
# These flags are copied from Makefile.gnu
|
# These flags are copied from Makefile.gnu
|
||||||
common_flags = ' -O3 -fPIC -fexceptions -fvisibility=hidden'
|
common_flags = ' -O3 -fPIC -fexceptions -fvisibility=hidden'
|
||||||
|
|
||||||
env = self.environment
|
env = state.environment
|
||||||
env['CFLAGS'] += common_flags + ' -std=gnu89 -Wno-implicit-function-declaration'
|
env['CFLAGS'] += common_flags + ' -std=gnu89 -Wno-implicit-function-declaration'
|
||||||
env['CXXFLAGS'] += common_flags + ' -Wno-ctor-dtor-privacy'
|
env['CXXFLAGS'] += common_flags + ' -Wno-ctor-dtor-privacy'
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ class Sdl2MixerTarget(ConfigureMakeStaticDependencyTarget):
|
||||||
|
|
||||||
def configure(self, state: BuildState):
|
def configure(self, state: BuildState):
|
||||||
# Set LDFLAGS explicitly to help with FluidSynth and FLAC detection
|
# Set LDFLAGS explicitly to help with FluidSynth and FLAC detection
|
||||||
self.environment['LDFLAGS'] = state.run_pkg_config('--libs', 'fluidsynth')
|
state.environment['LDFLAGS'] = state.run_pkg_config('--libs', 'fluidsynth')
|
||||||
|
|
||||||
super().configure(state)
|
super().configure(state)
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ class SfmlTarget(CMakeStaticDependencyTarget):
|
||||||
opts['OPENAL_INCLUDE_DIR'] = state.include_path / 'AL'
|
opts['OPENAL_INCLUDE_DIR'] = state.include_path / 'AL'
|
||||||
opts['OPENAL_LIBRARY'] = state.lib_path / 'libopenal.a'
|
opts['OPENAL_LIBRARY'] = state.lib_path / 'libopenal.a'
|
||||||
|
|
||||||
super(SfmlTarget, self).configure(state)
|
super().configure(state)
|
||||||
|
|
||||||
def detect(self, state: BuildState) -> bool:
|
def detect(self, state: BuildState) -> bool:
|
||||||
return state.has_source_file('libtiff-4.pc.in')
|
return state.has_source_file('libtiff-4.pc.in')
|
||||||
|
|
|
@ -336,7 +336,7 @@ class EDuke32Target(MakeMainTarget):
|
||||||
super().configure(state)
|
super().configure(state)
|
||||||
|
|
||||||
# Fix missing definition when building with SDK older than 10.12
|
# Fix missing definition when building with SDK older than 10.12
|
||||||
self._update_env('CXXFLAGS', '-DCLOCK_MONOTONIC=0')
|
state.update_environment('CXXFLAGS', '-DCLOCK_MONOTONIC=0')
|
||||||
|
|
||||||
|
|
||||||
class NBloodTarget(EDuke32Target):
|
class NBloodTarget(EDuke32Target):
|
||||||
|
|
|
@ -53,7 +53,7 @@ class CMakeBuildTarget(CMakeTarget):
|
||||||
|
|
||||||
assert boostrap_cmake.exists()
|
assert boostrap_cmake.exists()
|
||||||
|
|
||||||
env = self.environment
|
env = state.environment
|
||||||
env['PATH'] = os.pathsep.join([str(boostrap_cmk_path), env['PATH']])
|
env['PATH'] = os.pathsep.join([str(boostrap_cmk_path), env['PATH']])
|
||||||
|
|
||||||
super().configure(state)
|
super().configure(state)
|
||||||
|
@ -135,7 +135,7 @@ class NinjaTarget(MakeTarget):
|
||||||
)
|
)
|
||||||
|
|
||||||
for args in cmdlines:
|
for args in cmdlines:
|
||||||
subprocess.run(args, check=True, cwd=state.build_path, env=self.environment)
|
subprocess.run(args, check=True, cwd=state.build_path, env=state.environment)
|
||||||
|
|
||||||
def post_build(self, state: BuildState):
|
def post_build(self, state: BuildState):
|
||||||
self.copy_to_bin(state)
|
self.copy_to_bin(state)
|
||||||
|
@ -229,7 +229,7 @@ class ZipTarget(MakeTarget):
|
||||||
]
|
]
|
||||||
|
|
||||||
for var in ('CFLAGS', 'LDFLAGS'):
|
for var in ('CFLAGS', 'LDFLAGS'):
|
||||||
args += shlex.split(self.environment[var])
|
args += shlex.split(state.environment[var])
|
||||||
|
|
||||||
subprocess.run(args, check=True, cwd=state.build_path)
|
subprocess.run(args, check=True, cwd=state.build_path)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue