aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/compilers/compilers.py
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-08-24 04:16:48 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-08-23 19:16:02 -0700
commit79aec5f34226330712f606bf3655aa2d25377927 (patch)
tree81587d45c6f9f8cafd4f961b67b76fc8084ab963 /mesonbuild/compilers/compilers.py
parenta7e6c1aaa46749b0e20c91e98869208e5e664500 (diff)
downloadmeson-79aec5f34226330712f606bf3655aa2d25377927.zip
meson-79aec5f34226330712f606bf3655aa2d25377927.tar.gz
meson-79aec5f34226330712f606bf3655aa2d25377927.tar.bz2
CompilerArgs: Allow calling to_native() multiple times
Add a keyword argument to to_native() to operate on a copy so that we can call it multiple times instead of modifying the original compiler args while iterating. This is used in the unit test, and might be used in Meson at some point too.
Diffstat (limited to 'mesonbuild/compilers/compilers.py')
-rw-r--r--mesonbuild/compilers/compilers.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 5af4b5d..95f937d 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -602,16 +602,20 @@ class CompilerArgs(list):
return True
return False
- def to_native(self):
+ def to_native(self, copy=False):
# Check if we need to add --start/end-group for circular dependencies
# between static libraries, and for recursively searching for symbols
# needed by static libraries that are provided by object files or
# shared libraries.
+ if copy:
+ new = self.copy()
+ else:
+ new = self
if get_compiler_uses_gnuld(self.compiler):
global soregex
group_start = -1
group_end = -1
- for i, each in enumerate(self):
+ for i, each in enumerate(new):
if not each.startswith('-l') and not each.endswith('.a') and \
not soregex.match(each):
continue
@@ -621,9 +625,9 @@ class CompilerArgs(list):
group_start = i
if group_start >= 0:
# Last occurrence of a library
- self.insert(group_end + 1, '-Wl,--end-group')
- self.insert(group_start, '-Wl,--start-group')
- return self.compiler.unix_args_to_native(self)
+ new.insert(group_end + 1, '-Wl,--end-group')
+ new.insert(group_start, '-Wl,--start-group')
+ return self.compiler.unix_args_to_native(new)
def append_direct(self, arg):
'''