Skip to content

Commit 9853e9b

Browse files
committed
[libcxx] [test] Deduplicate setting parameters for clangcl test configs. NFC.
Differential Revision: https://reviews.llvm.org/D156573
1 parent 2f6ca38 commit 9853e9b

File tree

4 files changed

+30
-51
lines changed

4 files changed

+30
-51
lines changed

libcxx/test/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ if (NOT DEFINED LIBCXX_TEST_DEPS)
4646
message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined")
4747
endif()
4848

49+
if (MSVC)
50+
# Shared code for initializing some parameters used by all
51+
# llvm-libc++-*-clangcl.cfg.in test configs.
52+
set(dbg_include "")
53+
54+
if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
55+
set(crt_lib "msvcrt")
56+
set(cxx_lib "msvcprt")
57+
else()
58+
set(crt_lib "libcmt")
59+
set(cxx_lib "libcpmt")
60+
endif()
61+
62+
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
63+
set(dbg_include " -D_DEBUG -include set_windows_crt_report_mode.h")
64+
set(crt_lib "${crt_lib}d")
65+
set(cxx_lib "${cxx_lib}d")
66+
endif()
67+
68+
serialize_lit_param(dbg_include "\"${dbg_include}\"")
69+
serialize_lit_param(crt_lib "\"${crt_lib}\"")
70+
serialize_lit_param(cxx_lib "\"${cxx_lib}\"")
71+
endif()
72+
4973
if (LIBCXX_INCLUDE_TESTS)
5074
include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite
5175

libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,12 @@
33

44
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
55

6-
dbg_include = ''
7-
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
8-
9-
if runtime_library == '' or runtime_library.endswith('DLL'):
10-
crt_lib = 'msvcrt'
11-
cxx_lib = 'msvcprt'
12-
else:
13-
crt_lib = 'libcmt'
14-
cxx_lib = 'libcpmt'
15-
16-
if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
17-
dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
18-
crt_lib += 'd'
19-
cxx_lib += 'd'
20-
216
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
227
config.substitutions.append(('%{compile_flags}',
23-
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include
8+
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
249
))
2510
config.substitutions.append(('%{link_flags}',
26-
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
11+
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
2712
))
2813
config.substitutions.append(('%{exec}',
2914
'%{executor} --execdir %T --prepend_env PATH=%{lib} -- '

libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,12 @@
44

55
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
66

7-
dbg_include = ''
8-
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
9-
10-
if runtime_library == '' or runtime_library.endswith('DLL'):
11-
crt_lib = 'msvcrt'
12-
cxx_lib = 'msvcprt'
13-
else:
14-
crt_lib = 'libcmt'
15-
cxx_lib = 'libcpmt'
16-
17-
if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
18-
dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
19-
crt_lib += 'd'
20-
cxx_lib += 'd'
21-
227
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
238
config.substitutions.append(('%{compile_flags}',
24-
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + dbg_include
9+
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + config.dbg_include
2510
))
2611
config.substitutions.append(('%{link_flags}',
27-
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
12+
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
2813
))
2914
config.substitutions.append(('%{exec}',
3015
'%{executor} --execdir %T --prepend_env PATH=%{lib} -- '

libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,12 @@
33

44
lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
55

6-
dbg_include = ''
7-
runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@'
8-
9-
if runtime_library == '' or runtime_library.endswith('DLL'):
10-
crt_lib = 'msvcrt'
11-
cxx_lib = 'msvcprt'
12-
else:
13-
crt_lib = 'libcmt'
14-
cxx_lib = 'libcpmt'
15-
16-
if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG':
17-
dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h'
18-
crt_lib += 'd'
19-
cxx_lib += 'd'
20-
216
config.substitutions.append(('%{flags}', '--driver-mode=g++'))
227
config.substitutions.append(('%{compile_flags}',
23-
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include
8+
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
249
))
2510
config.substitutions.append(('%{link_flags}',
26-
'-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib)
11+
'-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
2712
))
2813
config.substitutions.append(('%{exec}',
2914
'%{executor} --execdir %T -- '

0 commit comments

Comments
 (0)