mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2025-02-16 16:41:42 +00:00
build script: add class to handle command line options
This commit is contained in:
parent
6e39dea6de
commit
f9424e5c9c
1 changed files with 16 additions and 11 deletions
27
build.py
27
build.py
|
@ -34,13 +34,25 @@ import subprocess
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
|
||||||
|
|
||||||
|
class CommandLineOptions(dict):
|
||||||
|
def to_list(self, prefix='') -> list:
|
||||||
|
result = []
|
||||||
|
|
||||||
|
for arg_name, arg_value in self.items():
|
||||||
|
option = prefix + arg_name
|
||||||
|
option += arg_value and ('=' + arg_value) or ''
|
||||||
|
result.append(option)
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Target:
|
class Target:
|
||||||
def __init__(self, name=None):
|
def __init__(self, name=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.src_root = ''
|
self.src_root = ''
|
||||||
self.prefix = None
|
self.prefix = None
|
||||||
self.environment = os.environ
|
self.environment = os.environ
|
||||||
self.options = {}
|
self.options = CommandLineOptions()
|
||||||
|
|
||||||
def prepare_source(self, builder: 'Builder'):
|
def prepare_source(self, builder: 'Builder'):
|
||||||
pass
|
pass
|
||||||
|
@ -106,9 +118,7 @@ class MakeTarget(Target):
|
||||||
'-f', self.makefile,
|
'-f', self.makefile,
|
||||||
'-j', builder.jobs,
|
'-j', builder.jobs,
|
||||||
]
|
]
|
||||||
|
args += self.options.to_list()
|
||||||
for arg_name, arg_value in self.options.items():
|
|
||||||
args.append(f'{arg_name}={arg_value}')
|
|
||||||
|
|
||||||
work_path = builder.build_path + self.src_root
|
work_path = builder.build_path + self.src_root
|
||||||
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
||||||
|
@ -146,10 +156,7 @@ class ConfigureMakeTarget(Target):
|
||||||
|
|
||||||
work_path = builder.build_path + self.src_root
|
work_path = builder.build_path + self.src_root
|
||||||
args = [work_path + os.sep + 'configure']
|
args = [work_path + os.sep + 'configure']
|
||||||
|
args += self.options.to_list()
|
||||||
for arg_name, arg_value in self.options.items():
|
|
||||||
args.append(f'{arg_name}={arg_value}')
|
|
||||||
|
|
||||||
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
subprocess.check_call(args, cwd=work_path, env=self.environment)
|
||||||
|
|
||||||
self.make.build(builder)
|
self.make.build(builder)
|
||||||
|
@ -222,9 +229,7 @@ class CMakeTarget(Target):
|
||||||
if builder.sdk_path:
|
if builder.sdk_path:
|
||||||
args.append('-DCMAKE_OSX_SYSROOT=' + builder.sdk_path)
|
args.append('-DCMAKE_OSX_SYSROOT=' + builder.sdk_path)
|
||||||
|
|
||||||
for arg_name, arg_value in self.options.items():
|
args += self.options.to_list('-D')
|
||||||
args.append(f'-D{arg_name}={arg_value}')
|
|
||||||
|
|
||||||
args.append(builder.source_path + self.src_root)
|
args.append(builder.source_path + self.src_root)
|
||||||
|
|
||||||
subprocess.check_call(args, cwd=builder.build_path, env=self.environment)
|
subprocess.check_call(args, cwd=builder.build_path, env=self.environment)
|
||||||
|
|
Loading…
Reference in a new issue