[libcxx] r292351 - Re-add mechanism to override LIT options using enviroment variables.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 23:56:58 PST 2017


Author: ericwf
Date: Wed Jan 18 01:56:57 2017
New Revision: 292351

URL: http://llvm.org/viewvc/llvm-project?rev=292351&view=rev
Log:
Re-add mechanism to override LIT options using enviroment variables.

There was a dumb mistake in the original commit that has now
been fixed

Modified:
    libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=292351&r1=292350&r2=292351&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Wed Jan 18 01:56:57 2017
@@ -85,20 +85,31 @@ class Configuration(object):
                 val = default
         return val
 
-    def get_lit_bool(self, name, default=None):
-        conf = self.get_lit_conf(name)
-        if conf is None:
-            return default
-        if isinstance(conf, bool):
-            return conf
-        if not isinstance(conf, str):
-            raise TypeError('expected bool or string')
-        if conf.lower() in ('1', 'true'):
-            return True
-        if conf.lower() in ('', '0', 'false'):
-            return False
-        self.lit_config.fatal(
-            "parameter '{}' should be true or false".format(name))
+    def get_lit_bool(self, name, default=None, env_var=None):
+        def check_value(value, var_name):
+            if value is None:
+                return default
+            if isinstance(value, bool):
+                return value
+            if not isinstance(value, str):
+                raise TypeError('expected bool or string')
+            if value.lower() in ('1', 'true'):
+                return True
+            if value.lower() in ('', '0', 'false'):
+                return False
+            self.lit_config.fatal(
+                "parameter '{}' should be true or false".format(var_name))
+
+        conf_val = self.get_lit_conf(name)
+        if env_var is not None and env_var in os.environ and \
+                os.environ[env_var] is not None:
+            val = os.environ[env_var]
+            if conf_val is not None:
+                self.lit_config.warning(
+                    'Environment variable %s=%s is overriding explicit '
+                    '--param=%s=%s' % (env_var, val, name, conf_val))
+            return check_value(val, env_var)
+        return check_value(conf_val, name)
 
     def make_static_lib_name(self, name):
         """Return the full filename for the specified library name"""
@@ -845,10 +856,9 @@ class Configuration(object):
         if platform.system() != 'Darwin':
             modules_flags += ['-Xclang', '-fmodules-local-submodule-visibility']
         supports_modules = self.cxx.hasCompileFlag(modules_flags)
-        enable_modules_default = supports_modules and \
-            os.environ.get('LIBCXX_USE_MODULES') is not None
         enable_modules = self.get_lit_bool('enable_modules',
-                                           enable_modules_default)
+                                           default=False,
+                                           env_var='LIBCXX_ENABLE_MODULES')
         if enable_modules and not supports_modules:
             self.lit_config.fatal(
                 '-fmodules is enabled but not supported by the compiler')




More information about the cfe-commits mailing list