diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-10-25 07:48:58 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-10-26 23:16:06 +0530 |
commit | 5ffb0bcd0dad9bfa1601dbeee1400b6653199722 (patch) | |
tree | c3eb604a49642428da8a6f56399febea02b7a7c6 | |
parent | 3df75d696d951dc11bae5d287e1062c5299b8367 (diff) | |
download | meson-5ffb0bcd0dad9bfa1601dbeee1400b6653199722.zip meson-5ffb0bcd0dad9bfa1601dbeee1400b6653199722.tar.gz meson-5ffb0bcd0dad9bfa1601dbeee1400b6653199722.tar.bz2 |
Use *FLAGS from the env in compiler checks
Every other build system does this, and at least OS X, iOS, and Android
depend on this to select the OS versions that your application is
targetting.
At the same time, just use a wrapper for self.run and self.links to
share the common (identical) code.
-rw-r--r-- | mesonbuild/compilers.py | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/mesonbuild/compilers.py b/mesonbuild/compilers.py index 2a89cf0..2d255dd 100644 --- a/mesonbuild/compilers.py +++ b/mesonbuild/compilers.py @@ -707,12 +707,16 @@ int main () {{ {1}; }}''' args = self.unix_link_flags_to_native(cargs + extra_args) # Read c_args/cpp_args/etc from the cross-info file (if needed) args += self.get_cross_extra_flags(env, compile=True, link=False) + # Add CFLAGS/CXXFLAGS/OBJCFLAGS/OBJCXXFLAGS from the env + # We assume that the user has ensured these are compiler-specific + args += env.coredata.external_args[self.language] # We only want to compile; not link args += self.get_compile_only_args() with self.compile(code, args) as p: return p.returncode == 0 - def links(self, code, env, extra_args=None, dependencies=None): + def _links_wrapper(self, code, env, extra_args, dependencies): + "Shares common code between self.links and self.run" if extra_args is None: extra_args = [] elif isinstance(extra_args, str): @@ -729,27 +733,19 @@ int main () {{ {1}; }}''' args += self.get_linker_debug_crt_args() # Read c_args/c_link_args/cpp_args/cpp_link_args/etc from the cross-info file (if needed) args += self.get_cross_extra_flags(env, compile=True, link=True) - with self.compile(code, args) as p: + # Add LDFLAGS from the env. We assume that the user has ensured these + # are compiler-specific + args += env.coredata.external_link_args[self.language] + return self.compile(code, args) + + def links(self, code, env, extra_args=None, dependencies=None): + with self._links_wrapper(code, env, extra_args, dependencies) as p: return p.returncode == 0 def run(self, code, env, extra_args=None, dependencies=None): - if extra_args is None: - extra_args = [] - if dependencies is None: - dependencies = [] - elif not isinstance(dependencies, list): - dependencies = [dependencies] if self.is_cross and self.exe_wrapper is None: raise CrossNoRunException('Can not run test applications in this cross environment.') - cargs = [a for d in dependencies for a in d.get_compile_args()] - link_args = [a for d in dependencies for a in d.get_link_args()] - # Convert flags to the native type of the selected compiler - args = self.unix_link_flags_to_native(cargs + link_args + extra_args) - # Select a CRT if needed since we're linking - args += self.get_linker_debug_crt_args() - # Read c_link_args/cpp_link_args/etc from the cross-info file - args += self.get_cross_extra_flags(env, compile=True, link=True) - with self.compile(code, args) as p: + with self._links_wrapper(code, env, extra_args, dependencies) as p: if p.returncode != 0: mlog.debug('Could not compile test file %s: %d\n' % ( p.input_name, |