[libc++] Provide a method for adding compiler flags in lit.local.cfg files

That way, local lit configuration files don't have to worry about
deep-copying the compiler instance of the test format, which is
arguably an implementation detail.

We pass the config to this method even though it is not used by the
current test format because this allows replacing the current test
format by other test formats that would require the config to add
new compile flags.
This commit is contained in:
Louis Dionne 2020-03-30 13:22:06 -04:00
parent d3a729ab24
commit fb47ffc618
4 changed files with 9 additions and 9 deletions

View File

@ -1 +1 @@
config.test_format.cxx.compile_flags += ['-D_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM']
config.test_format.addCompileFlags(config, '-D_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM')

View File

@ -4,6 +4,4 @@
if 'fcoroutines-ts' not in config.available_features:
config.unsupported = True
else:
import copy
config.test_format.cxx = copy.deepcopy(config.test_format.cxx)
config.test_format.cxx.compile_flags += ['-fcoroutines-ts']
config.test_format.addCompileFlags(config, '-fcoroutines-ts')

View File

@ -1,4 +1,3 @@
import copy
import os
import sys
@ -8,11 +7,9 @@ if 'dylib-has-no-filesystem' in config.available_features:
if 'c++filesystem-disabled' in config.available_features:
config.unsupported = True
config.test_format.cxx = copy.deepcopy(config.test_format.cxx)
inputs = os.path.join(os.path.dirname(__file__), 'Inputs', 'static_test_env')
config.test_format.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="{}"'.format(inputs)]
config.test_format.addCompileFlags(config, '-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="{}"'.format(inputs))
dynamic_helper = os.path.join(config.test_source_root, 'support', 'filesystem_dynamic_test_helper.py')
assert os.path.isfile(dynamic_helper)
config.test_format.cxx.compile_flags += ['-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="{} {}"'.format(sys.executable, dynamic_helper)]
config.test_format.addCompileFlags(config, '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="{} {}"'.format(sys.executable, dynamic_helper))

View File

@ -51,6 +51,11 @@ class LibcxxTestFormat(object):
initial_value=[])
]
# Utility function to add compile flags in lit.local.cfg files.
def addCompileFlags(self, config, *flags):
self.cxx = copy.deepcopy(self.cxx)
self.cxx.compile_flags += flags
@staticmethod
def _get_parser(key, parsers):
for p in parsers: