From fac8e1d28899d1b8dffbb73fd1f7c4f7012d7bd2 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 31 Dec 2022 10:51:41 +0200 Subject: [PATCH] aedi: update flags environment variable via one call --- aedi/state.py | 14 ++++++-------- aedi/target/base.py | 14 +++----------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/aedi/state.py b/aedi/state.py index 73d487ba..05612c35 100644 --- a/aedi/state.py +++ b/aedi/state.py @@ -211,16 +211,14 @@ class BuildState: def has_source_file(self, path: typing.Union[str, Path]): 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): + def update_flags_environment_variable(self, name: str, value: str): sdk_path = self.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() 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 diff --git a/aedi/target/base.py b/aedi/target/base.py index cd5f4548..a6a4b8aa 100644 --- a/aedi/target/base.py +++ b/aedi/target/base.py @@ -114,18 +114,10 @@ class BuildTarget(Target): if cxx_compiler := state.cxx_compiler(): env['CXX'] = str(cxx_compiler) - for prefix in ('CPP', 'C', 'CXX', 'OBJC', 'OBJCXX'): - var_name = f'{prefix}FLAGS' + for prefix in ('C', 'CPP', 'CXX', 'OBJC', 'OBJCXX'): + state.update_flags_environment_variable(f'{prefix}FLAGS', f'-I{state.include_path}') - state.update_environment(var_name, f'-I{state.include_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) + state.update_flags_environment_variable('LDFLAGS', f'-L{state.lib_path}') def install(self, state: BuildState, options: CommandLineOptions = None, tool: str = 'gmake'): if state.xcode: