Home | History | Annotate | Download | only in test
      1 import os
      2 
      3 import libcxx.test.config
      4 import libcxx.android.build
      5 import libcxx.android.test.format
      6 
      7 
      8 class Configuration(libcxx.test.config.Configuration):
      9     def __init__(self, lit_config, config):
     10         super(Configuration, self).__init__(lit_config, config)
     11         self.cxx_under_test = None
     12         self.build_cmds_dir = None
     13         self.cxx_template = None
     14         self.link_template = None
     15 
     16     def configure(self):
     17         self.configure_cxx()
     18         self.configure_triple()
     19         self.configure_src_root()
     20         self.configure_obj_root()
     21         self.configure_cxx_library_root()
     22         self.configure_compile_flags()
     23         self.configure_link_flags()
     24         self.configure_features()
     25 
     26     def configure_link_flags(self):
     27         self.link_flags.append('-nodefaultlibs')
     28 
     29         # Configure libc++ library paths.
     30         self.link_flags.append('-L' + self.cxx_library_root)
     31 
     32         # Add libc_ndk's output path to the library search paths.
     33         libdir = '{}/obj/STATIC_LIBRARIES/libc_ndk_intermediates'.format(
     34             os.getenv('ANDROID_PRODUCT_OUT'))
     35         self.link_flags.append('-L' + libdir)
     36 
     37         self.link_flags.append('-lc++_ndk')
     38         self.link_flags.append('-lc_ndk')
     39         self.link_flags.append('-lc')
     40 
     41     def configure_features(self):
     42         self.config.available_features.add('long_tests')
     43 
     44     def get_test_format(self):
     45         cxx_template = ' '.join(
     46             self.compile_flags + ['-c', '-o', '%OUT%', '%SOURCE%'])
     47         link_template = ' '.join(
     48             ['-o', '%OUT%', '%SOURCE%'] + self.compile_flags + self.link_flags)
     49         tmp_dir = getattr(self.config, 'device_dir', '/data/local/tmp/')
     50 
     51         return libcxx.android.test.format.TestFormat(
     52             self.cxx,
     53             self.libcxx_src_root,
     54             self.obj_root,
     55             cxx_template,
     56             link_template,
     57             tmp_dir,
     58             getattr(self.config, 'timeout', '300'),
     59             exec_env={'LD_LIBRARY_PATH': tmp_dir})
     60