aedi: update flags environment variable via one call

This commit is contained in:
alexey.lysiuk 2022-12-31 10:51:41 +02:00
parent e8b3338d90
commit fac8e1d288
2 changed files with 9 additions and 19 deletions

View file

@ -211,16 +211,14 @@ 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): def update_flags_environment_variable(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() sdk_path = self.sdk_path()
if sdk_path: if sdk_path:
self.update_environment(var_name, f'-isysroot {sdk_path}') value += f' -isysroot {sdk_path}'
def set_os_version(self, var_name: str):
os_version = self.os_version() os_version = self.os_version()
if os_version: if os_version:
self.update_environment(var_name, f'-mmacosx-version-min={os_version}') value += f' -mmacosx-version-min={os_version}'
env = self.environment
env[name] = env[name] + ' ' + value if name in env else value

View file

@ -114,18 +114,10 @@ class BuildTarget(Target):
if cxx_compiler := state.cxx_compiler(): if cxx_compiler := state.cxx_compiler():
env['CXX'] = str(cxx_compiler) env['CXX'] = str(cxx_compiler)
for prefix in ('CPP', 'C', 'CXX', 'OBJC', 'OBJCXX'): for prefix in ('C', 'CPP', 'CXX', 'OBJC', 'OBJCXX'):
var_name = f'{prefix}FLAGS' state.update_flags_environment_variable(f'{prefix}FLAGS', f'-I{state.include_path}')
state.update_environment(var_name, f'-I{state.include_path}') state.update_flags_environment_variable('LDFLAGS', f'-L{state.lib_path}')
state.set_sdk(var_name)
state.set_os_version(var_name)
ldflags = 'LDFLAGS'
state.update_environment(ldflags, f'-L{state.lib_path}')
state.set_sdk(ldflags)
state.set_os_version(ldflags)
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: