diff --git a/libcxx/utils/libcxx/test/config.py b/libcxx/utils/libcxx/test/config.py --- a/libcxx/utils/libcxx/test/config.py +++ b/libcxx/utils/libcxx/test/config.py @@ -59,7 +59,6 @@ def __init__(self, lit_config, config): self.lit_config = lit_config self.config = config - self.is_windows = platform.system() == 'Windows' self.cxx = None self.cxx_is_clang_cl = None self.cxx_stdlib_under_test = None @@ -119,7 +118,7 @@ def make_static_lib_name(self, name): """Return the full filename for the specified library name""" - if self.is_windows: + if self.target_info.is_windows(): assert name == 'c++' # Only allow libc++ to use this function for now. return 'lib' + name + '.lib' else: @@ -471,7 +470,7 @@ intMacroValue(macros['__cpp_deduction_guides']) < 201611: self.config.available_features.add('libcpp-no-deduction-guides') - if self.is_windows: + if self.target_info.is_windows(): self.config.available_features.add('windows') if self.cxx_stdlib_under_test == 'libc++': # LIBCXX-WINDOWS-FIXME is the feature name used to XFAIL the @@ -506,7 +505,7 @@ # Configure extra flags compile_flags_str = self.get_lit_conf('compile_flags', '') self.cxx.compile_flags += shlex.split(compile_flags_str) - if self.is_windows: + if self.target_info.is_windows(): # FIXME: Can we remove this? self.cxx.compile_flags += ['-D_CRT_SECURE_NO_WARNINGS'] # Required so that tests using min/max don't fail on Windows, @@ -572,7 +571,7 @@ # the Windows build of libc++, the forced inclusion of a header requires # that _DEBUG is defined. Incorrect ordering will result in -target # being elided. - if self.is_windows and self.debug_build: + if self.target_info.is_windows() and self.debug_build: self.cxx.compile_flags += ['-D_DEBUG'] if self.use_target: if not self.cxx.addFlagIfSupported( @@ -605,7 +604,7 @@ support_path = os.path.join(self.libcxx_src_root, 'test', 'support') self.configure_config_site_header() if self.cxx_stdlib_under_test != 'libstdc++' and \ - not self.is_windows: + not self.target_info.is_windows(): self.cxx.compile_flags += [ '-include', os.path.join(support_path, 'nasty_macros.h')] if self.cxx_stdlib_under_test == 'msvc': @@ -613,7 +612,7 @@ '-include', os.path.join(support_path, 'msvc_stdlib_force_include.h')] pass - if self.is_windows and self.debug_build and \ + if self.target_info.is_windows() and self.debug_build and \ self.cxx_stdlib_under_test != 'msvc': self.cxx.compile_flags += [ '-include', os.path.join(support_path, @@ -757,7 +756,7 @@ if self.cxx_stdlib_under_test == 'libc++': self.cxx.link_flags += ['-nodefaultlibs'] # FIXME: Handle MSVCRT as part of the ABI library handling. - if self.is_windows: + if self.target_info.is_windows(): self.cxx.link_flags += ['-nostdlib'] self.configure_link_flags_cxx_library() self.configure_link_flags_abi_library() @@ -780,20 +779,20 @@ if not self.use_system_cxx_lib: if self.cxx_library_root: self.cxx.link_flags += ['-L' + self.cxx_library_root] - if self.is_windows and self.link_shared: + if self.target_info.is_windows() and self.link_shared: self.add_path(self.cxx.compile_env, self.cxx_library_root) if self.cxx_runtime_root: - if not self.is_windows: + if not self.target_info.is_windows(): self.cxx.link_flags += ['-Wl,-rpath,' + self.cxx_runtime_root] - elif self.is_windows and self.link_shared: + elif self.target_info.is_windows() and self.link_shared: self.add_path(self.exec_env, self.cxx_runtime_root) elif os.path.isdir(str(self.use_system_cxx_lib)): self.cxx.link_flags += ['-L' + self.use_system_cxx_lib] - if not self.is_windows: + if not self.target_info.is_windows(): self.cxx.link_flags += ['-Wl,-rpath,' + self.use_system_cxx_lib] - if self.is_windows and self.link_shared: + if self.target_info.is_windows() and self.link_shared: self.add_path(self.cxx.compile_env, self.use_system_cxx_lib) additional_flags = self.get_lit_conf('test_linker_flags') if additional_flags: @@ -804,7 +803,7 @@ self.abi_library_root = self.get_lit_conf('abi_library_path') if self.abi_library_root: self.cxx.link_flags += ['-L' + self.abi_library_root] - if not self.is_windows: + if not self.target_info.is_windows(): self.cxx.link_flags += ['-Wl,-rpath,' + self.abi_library_root] else: self.add_path(self.exec_env, self.abi_library_root) @@ -857,7 +856,7 @@ self.cxx.link_flags += ['-l%s%s' % (lib, debug_suffix) for lib in ['vcruntime', 'ucrt', 'msvcrt']] elif cxx_abi == 'none' or cxx_abi == 'default': - if self.is_windows: + if self.target_info.is_windows(): debug_suffix = 'd' if self.debug_build else '' self.cxx.link_flags += ['-lmsvcrt%s' % debug_suffix] else: @@ -1206,6 +1205,6 @@ if 'PATH' not in dest_env: dest_env['PATH'] = new_path else: - split_char = ';' if self.is_windows else ':' + split_char = ';' if self.target_info.is_windows() else ':' dest_env['PATH'] = '%s%s%s' % (new_path, split_char, dest_env['PATH']) diff --git a/libcxx/utils/libcxx/test/target_info.py b/libcxx/utils/libcxx/test/target_info.py --- a/libcxx/utils/libcxx/test/target_info.py +++ b/libcxx/utils/libcxx/test/target_info.py @@ -23,6 +23,9 @@ def platform(self): return sys.platform.lower().strip() + def is_windows(self): + return self.platform() == 'win32' + def add_locale_features(self, features): self.full_config.lit_config.warning( "No locales entry for target_system: %s" % self.platform())