summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-07-05 14:51:30 +0200
committerDavid Robillard <d@drobilla.net>2020-07-05 14:51:30 +0200
commitf773f9a6a1ace4e3ddda5db05db4fa49bd0173ac (patch)
tree2cdd7a1c173f43830a9a9edee1c045db85d245f7
parent315b2efc1f6635b0199afd2d43bff585b52d7fdd (diff)
downloadautowaf-f773f9a6a1ace4e3ddda5db05db4fa49bd0173ac.tar.gz
autowaf-f773f9a6a1ace4e3ddda5db05db4fa49bd0173ac.tar.bz2
autowaf-f773f9a6a1ace4e3ddda5db05db4fa49bd0173ac.zip
Make add_compiler_flags() a top level function
So it can be used with any env.
-rw-r--r--extras/autowaf.py51
1 files changed, 26 insertions, 25 deletions
diff --git a/extras/autowaf.py b/extras/autowaf.py
index 7451a66..b9d10f2 100644
--- a/extras/autowaf.py
+++ b/extras/autowaf.py
@@ -142,31 +142,6 @@ class ConfigureContext(Configure.ConfigurationContext):
"""Return `path` within the build directory"""
return str(self.path.get_bld().make_node(path))
- def add_compiler_flags(self, lang, compiler_to_flags):
- """Add compiler-specific flags, for example to suppress warnings.
-
- The lang argument must be "c", "cxx", or "*" for both.
-
- The compiler_to_flags argument must be a map from compiler name
- ("clang", "gcc", or "msvc") to a list of command line flags.
- """
-
- if lang == "*":
- self.add_compiler_flags('c', compiler_to_flags)
- self.add_compiler_flags('cxx', compiler_to_flags)
- else:
- if lang == 'c':
- compiler_name = self.env.CC_NAME
- elif lang == 'cxx':
- compiler_name = self.env.CXX_NAME
- else:
- raise Exception('Unknown language "%s"' % lang)
-
- var_name = lang.upper() + 'FLAGS'
- for name, flags in compiler_to_flags.items():
- if name in compiler_name:
- self.env.append_value(var_name, flags)
-
def get_check_func(conf, lang):
if lang == 'c':
@@ -462,6 +437,32 @@ def set_warnings_as_errors(env):
env.append_unique('CXXFLAGS', ['/WX'])
+def add_compiler_flags(env, lang, compiler_to_flags):
+ """Add compiler-specific flags, for example to suppress warnings.
+
+ The lang argument must be "c", "cxx", or "*" for both.
+
+ The compiler_to_flags argument must be a map from compiler name
+ ("clang", "gcc", or "msvc") to a list of command line flags.
+ """
+
+ if lang == "*":
+ add_compiler_flags(env, 'c', compiler_to_flags)
+ add_compiler_flags(env, 'cxx', compiler_to_flags)
+ else:
+ if lang == 'c':
+ compiler_name = env.CC_NAME
+ elif lang == 'cxx':
+ compiler_name = env.CXX_NAME
+ else:
+ raise Exception('Unknown language "%s"' % lang)
+
+ var_name = lang.upper() + 'FLAGS'
+ for name, flags in compiler_to_flags.items():
+ if name in compiler_name:
+ env.append_value(var_name, flags)
+
+
def configure(conf):
def append_cxx_flags(flags):
conf.env.append_value('CFLAGS', flags)