[libcxx] r224671 - [libcxx] Teach libcxx's lit configuration new ways to find lit.site.cfg

Eric Fiselier eric at efcs.ca
Fri Dec 19 19:16:55 PST 2014


Author: ericwf
Date: Fri Dec 19 21:16:55 2014
New Revision: 224671

URL: http://llvm.org/viewvc/llvm-project?rev=224671&view=rev
Log:
[libcxx] Teach libcxx's lit configuration new ways to find lit.site.cfg

Summary:
Currently to run tests in tree you need to symlink the lit.site.cfg file generated by the cmake build into the source tree, and teach your VCS to ignore it.

This allows the user to specify where to find the lit.site.cfg file two different ways:
* lit_site_config lit parameter
* LIT_SITE_CONFIG enviroment variable. 

example usage:
```
lit -sv --param=libcxx_site_config=path/to/libcxx-build/test/lit.site.cfg path/to/tests
```
Or
```
export LIBCXX_SITE_CONFIG=path/to/libcxx-build/test/lit.site.cfg
lit -sv path/to/tests
```
The command line parameter will override the environment variable. 
If neither options are present a warning is issued and the `lit.cfg` file is loaded directly. 


Reviewers: mclow.lists, jroelofs, danalbert

Reviewed By: danalbert

Subscribers: ddunbar, cfe-commits

Differential Revision: http://reviews.llvm.org/D6255

Modified:
    libcxx/trunk/CMakeLists.txt
    libcxx/trunk/test/CMakeLists.txt
    libcxx/trunk/test/lit.cfg
    libcxx/trunk/test/lit.site.cfg.in
    libcxx/trunk/www/index.html

Modified: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=224671&r1=224670&r2=224671&view=diff
==============================================================================
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Fri Dec 19 21:16:55 2014
@@ -91,6 +91,11 @@ get_target_triple(LIBCXX_TARGET_TRIPLE
 set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
 
 
+set(LIBCXX_COMPILER    ${CMAKE_CXX_COMPILER})
+set(LIBCXX_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
+set(LIBCXX_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib)
+
 # Declare libc++ configuration variables.
 # They are intended for use as follows:
 # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker.

Modified: libcxx/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=224671&r1=224670&r2=224671&view=diff
==============================================================================
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Fri Dec 19 21:16:55 2014
@@ -23,10 +23,6 @@ if(PYTHONINTERP_FOUND)
   set(LIT_ARGS "${LLVM_LIT_ARGS}")
   separate_arguments(LIT_ARGS)
 
-  set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
-  set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
-  set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
-  set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
   pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
   pythonize_bool(LIBCXX_ENABLE_RTTI)
   pythonize_bool(LIBCXX_ENABLE_SHARED)

Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=224671&r1=224670&r2=224671&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Fri Dec 19 21:16:55 2014
@@ -211,6 +211,7 @@ class Configuration(object):
         self.cxx = None
         self.src_root = None
         self.obj_root = None
+        self.library_root = None
         self.env = {}
         self.compile_flags = ['-nostdinc++']
         self.link_flags = ['-nodefaultlibs']
@@ -246,6 +247,7 @@ class Configuration(object):
         self.configure_triple()
         self.configure_src_root()
         self.configure_obj_root()
+        self.configure_library_root()
         self.configure_use_system_lib()
         self.configure_use_clang_verify()
         self.configure_ccache()
@@ -333,6 +335,9 @@ class Configuration(object):
     def configure_obj_root(self):
         self.obj_root = self.get_lit_conf('libcxx_obj_root', self.src_root)
 
+    def configure_library_root(self):
+        self.library_root = self.get_lit_conf('libcxx_library_root', self.obj_root)
+
     def configure_use_system_lib(self):
         # This test suite supports testing against either the system library or
         # the locally built one; the former mode is useful for testing ABI
@@ -483,8 +488,8 @@ class Configuration(object):
         # Configure library search paths
         abi_library_path = self.get_lit_conf('abi_library_path', '')
         if not self.use_system_lib:
-            self.link_flags += ['-L' + self.obj_root + '/lib']
-            self.link_flags += ['-Wl,-rpath,' + self.obj_root + '/lib']
+            self.link_flags += ['-L' + self.library_root]
+            self.link_flags += ['-Wl,-rpath,' + self.library_root]
         if abi_library_path:
             self.link_flags += ['-L' + abi_library_path,
                                 '-Wl,-rpath,' + abi_library_path]
@@ -599,7 +604,7 @@ class Configuration(object):
 
     def configure_env(self):
         if sys.platform == 'darwin' and not self.use_system_lib:
-            self.env['DYLD_LIBRARY_PATH'] = os.path.join(self.obj_root, 'lib')
+            self.env['DYLD_LIBRARY_PATH'] = self.library_root
 
 # name: The name of this test suite.
 config.name = 'libc++'
@@ -610,6 +615,34 @@ config.suffixes = ['.cpp']
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)
 
+# Infer the test_exec_root from the libcxx_object root.
+libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
+if libcxx_obj_root is not None:
+    config.test_exec_root = os.path.join(libcxx_obj_root, 'test')
+
+# Check that the test exec root is known.
+if config.test_exec_root is None:
+    # Otherwise, we haven't loaded the site specific configuration (the user is
+    # probably trying to run on a test file directly, and either the site
+    # configuration hasn't been created by the build system, or we are in an
+    # out-of-tree build situation).
+    site_cfg = lit_config.params.get('libcxx_site_config',
+                                     os.environ.get('LIBCXX_SITE_CONFIG'))
+    if not site_cfg:
+        lit_config.warning('No site specific configuration file found!'
+                           ' Running the tests in the default configuration.')
+        # TODO: Set test_exec_root to a temporary directory where output files
+        # can be placed. This is needed for ShTest.
+    elif not os.path.isfile(site_cfg):
+        lit_config.fatal(
+            "Specified site configuration file does not exist: '%s'"  %
+            site_cfg)
+    else:
+        lit_config.note('using site specific configuration at %s' % site_cfg)
+        lit_config.load_config(config, site_cfg)
+        raise SystemExit()
+
+
 cfg_variant = getattr(config, 'configuration_variant', '')
 if cfg_variant:
     print 'Using configuration variant: %s' % cfg_variant

Modified: libcxx/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=224671&r1=224670&r2=224671&view=diff
==============================================================================
--- libcxx/trunk/test/lit.site.cfg.in (original)
+++ libcxx/trunk/test/lit.site.cfg.in Fri Dec 19 21:16:55 2014
@@ -3,7 +3,7 @@ config.cxx_under_test           = "@LIBC
 config.std                      = "@LIBCXX_STD_VERSION@"
 config.libcxx_src_root          = "@LIBCXX_SOURCE_DIR@"
 config.libcxx_obj_root          = "@LIBCXX_BINARY_DIR@"
-config.python_executable        = "@PYTHON_EXECUTABLE@"
+config.libcxx_library_root      = "@LIBCXX_LIBRARY_DIR@"
 config.enable_exceptions        = "@LIBCXX_ENABLE_EXCEPTIONS@"
 config.enable_rtti              = "@LIBCXX_ENABLE_RTTI@"
 config.enable_shared            = "@LIBCXX_ENABLE_SHARED@"

Modified: libcxx/trunk/www/index.html
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/index.html?rev=224671&r1=224670&r2=224671&view=diff
==============================================================================
--- libcxx/trunk/www/index.html (original)
+++ libcxx/trunk/www/index.html Fri Dec 19 21:16:55 2014
@@ -216,8 +216,9 @@
   <ul>
     <li><code>cd path/to/libcxx/libcxx</code></li>
     <li><code>alias lit='python path/to/llvm/utils/lit/lit.py'</code></li>
-    <li><code>ln -s path/to/build/dir/projects/libcxx/test/lit.site.cfg
-        test/lit.site.cfg</code></li>
+    <li><code>export
+        LIBCXX_SITE_CONFIG=path/to/build/dir/projects/libcxx/test/lit.site.cfg
+        </code></li>
     <li><code>lit -sv test/re/ # or whichever subset of tests you're interested
         in</code></li>
   </ul>





More information about the cfe-commits mailing list