Skip to content

Commit 75acad4

Browse files
committed
Use lit_config.substitute instead of foo % lit_config.params everywhere
This mechanically applies the same changes from D121427 everywhere. Differential Revision: https://reviews.llvm.org/D121746
1 parent 264d966 commit 75acad4

26 files changed

+85
-364
lines changed

bolt/test/Unit/lit.site.cfg.py.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,15 @@
22

33
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
44
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
5-
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
6-
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
7-
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
5+
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
6+
config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
7+
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
88
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
99
config.bolt_obj_root = "@BOLT_BINARY_DIR@"
1010
config.bolt_src_root = "@BOLT_SOURCE_DIR@"
1111
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1212
config.python_executable = "@Python3_EXECUTABLE@"
1313

14-
# Support substitution of the tools and libs dirs with user parameters. This is
15-
# used when we can't determine the tool dir at configuration time.
16-
try:
17-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
18-
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
19-
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
20-
except KeyError as e:
21-
key, = e.args
22-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
23-
2414
import lit.llvm
2515
lit.llvm.initialize(lit_config, config)
2616

bolt/test/lit.site.cfg.py.in

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@"
66
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
77
config.bolt_obj_root = "@BOLT_BINARY_DIR@"
88
config.bolt_enable_runtime = @BOLT_ENABLE_RUNTIME@
9-
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
10-
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
11-
config.llvm_shlib_dir = "@SHLIBDIR@"
9+
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
10+
config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
11+
config.llvm_shlib_dir = lit_config.substitute("@SHLIBDIR@")
1212
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
1313
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
1414
config.host_triple = "@LLVM_HOST_TRIPLE@"
@@ -22,17 +22,6 @@ config.python_executable = "@PYTHON_EXECUTABLE@"
2222
config.bolt_clang = "@BOLT_CLANG_EXE@"
2323
config.bolt_lld = "@BOLT_LLD_EXE@"
2424

25-
# Support substitution of the tools and libs dirs with user parameters. This is
26-
# used when we can't determine the tool dir at configuration time.
27-
try:
28-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
29-
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
30-
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
31-
except KeyError:
32-
e = sys.exc_info()[1]
33-
key, = e.args
34-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
35-
3625
import lit.llvm
3726
lit.llvm.initialize(lit_config, config)
3827

clang/test/Unit/lit.site.cfg.py.in

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,14 @@ import sys
44

55
config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
66
config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
7-
config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
8-
config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
9-
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
7+
config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
8+
config.llvm_libs_dir = lit_config.substitute(path(r"@LLVM_LIBS_DIR@"))
9+
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
1010
config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
1111
config.enable_shared = @ENABLE_SHARED@
12-
config.shlibdir = path(r"@SHLIBDIR@")
12+
config.shlibdir = lit_config.substitute(path(r"@SHLIBDIR@"))
1313
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1414

15-
# Support substitution of the tools_dir, libs_dirs, and build_mode with user
16-
# parameters. This is used when we can't determine the tool dir at
17-
# configuration time.
18-
try:
19-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
20-
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
21-
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
22-
config.shlibdir = config.shlibdir % lit_config.params
23-
except KeyError:
24-
e = sys.exc_info()[1]
25-
key, = e.args
26-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
27-
2815
# Let the main config do the real work.
2916
lit_config.load_config(
3017
config, os.path.join(path(r"@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))

clang/test/lit.site.cfg.py.in

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import sys
44

55
config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
66
config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
7-
config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
8-
config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
9-
config.llvm_shlib_dir = path(r"@SHLIBDIR@")
7+
config.llvm_tools_dir = lit_config.substitute(path(r"@LLVM_TOOLS_DIR@"))
8+
config.llvm_libs_dir = lit_config.substitute(path(r"@LLVM_LIBS_DIR@"))
9+
config.llvm_shlib_dir = lit_config.substitute(path(r"@SHLIBDIR@"))
1010
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
1111
config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
1212
config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@"
1313
config.clang_lit_site_cfg = __file__
1414
config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
1515
config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@")
16-
config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
16+
config.clang_tools_dir = lit_config.substitute(path(r"@CLANG_TOOLS_DIR@"))
1717
config.clang_lib_dir = path(r"@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
1818
config.host_triple = "@LLVM_HOST_TRIPLE@"
1919
config.target_triple = "@LLVM_TARGET_TRIPLE@"
@@ -38,18 +38,6 @@ config.has_plugins = @CLANG_PLUGIN_SUPPORT@
3838
config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
3939
config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
4040

41-
# Support substitution of the tools and libs dirs with user parameters. This is
42-
# used when we can't determine the tool dir at configuration time.
43-
try:
44-
config.clang_tools_dir = config.clang_tools_dir % lit_config.params
45-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
46-
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
47-
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
48-
except KeyError:
49-
e = sys.exc_info()[1]
50-
key, = e.args
51-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
52-
5341
import lit.llvm
5442
lit.llvm.initialize(lit_config, config)
5543

clang/utils/perf-training/lit.site.cfg.in

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
import sys
44

5-
config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
5+
config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
66
config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
77
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
88
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
99
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1010
config.python_exe = "@Python3_EXECUTABLE@"
1111

12-
# Support substitution of the tools and libs dirs with user parameters. This is
13-
# used when we can't determine the tool dir at configuration time.
14-
try:
15-
config.clang_tools_dir = config.clang_tools_dir % lit_config.params
16-
except KeyError:
17-
e = sys.exc_info()[1]
18-
key, = e.args
19-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
20-
2112
# Let the main config do the real work.
2213
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/lit.cfg")

clang/utils/perf-training/order-files.lit.site.cfg.in

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,12 @@
22

33
import sys
44

5-
config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
5+
config.clang_tools_dir = lit_config.substitute("@CLANG_TOOLS_DIR@")
66
config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
77
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
88
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
99
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1010
config.python_exe = "@Python3_EXECUTABLE@"
1111

12-
# Support substitution of the tools and libs dirs with user parameters. This is
13-
# used when we can't determine the tool dir at configuration time.
14-
try:
15-
config.clang_tools_dir = config.clang_tools_dir % lit_config.params
16-
except KeyError:
17-
e = sys.exc_info()[1]
18-
key, = e.args
19-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
20-
2112
# Let the main config do the real work.
2213
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/order-files.lit.cfg")

compiler-rt/test/lit.common.configured.in

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,9 @@ set_default("libcxx_used", "@LLVM_LIBCXX_USED@")
7070

7171
# LLVM tools dir can be passed in lit parameters, so try to
7272
# apply substitution.
73-
try:
74-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
75-
config.clang = config.clang % lit_config.params
76-
config.compiler_rt_libdir = config.compiler_rt_libdir % lit_config.params
77-
except KeyError as e:
78-
key, = e.args
79-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
73+
config.llvm_tools_dir = lit_config.substitute(config.llvm_tools_dir)
74+
config.clang = lit_config.substitute(config.clang)
75+
config.compiler_rt_libdir = lit_config.substitute(config.compiler_rt_libdir)
8076

8177
if not os.path.exists(config.clang):
8278
lit_config.fatal("Can't find compiler on path %r" % config.clang)

compiler-rt/unittests/lit.common.unit.configured.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,16 @@
44
config.target_triple = "@LLVM_TARGET_TRIPLE@"
55
config.llvm_src_root = "@LLVM_MAIN_SRC_DIR@"
66
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
7-
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
7+
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
88
config.compiler_rt_src_root = "@COMPILER_RT_SOURCE_DIR@"
9-
config.compiler_rt_libdir = "@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@"
9+
config.compiler_rt_libdir = lit_config.substitute("@COMPILER_RT_RESOLVED_LIBRARY_OUTPUT_DIR@")
1010
config.enable_per_target_runtime_dir = @LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_PYBOOL@
11-
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
11+
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
1212
config.host_arch = "@HOST_ARCH@"
1313
config.host_os = "@HOST_OS@"
1414
config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
1515
config.gwp_asan = @COMPILER_RT_HAS_GWP_ASAN_PYBOOL@
1616
config.emulator = "@COMPILER_RT_EMULATOR@"
1717

18-
# LLVM tools dir and build mode can be passed in lit parameters,
19-
# so try to apply substitution.
20-
try:
21-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
22-
config.compiler_rt_libdir = config.compiler_rt_libdir % lit_config.params
23-
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
24-
except KeyError as e:
25-
key, = e.args
26-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
27-
2818
# Setup attributes common for all compiler-rt unit tests.
2919
lit_config.load_config(config, "@COMPILER_RT_SOURCE_DIR@/unittests/lit.common.unit.cfg.py")

cross-project-tests/lit.site.cfg.py.in

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import lit.util
55

66
config.targets_to_build = "@TARGETS_TO_BUILD@".split()
77
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
8-
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
8+
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
99
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
10-
config.llvm_shlib_dir = "@SHLIBDIR@"
10+
config.llvm_shlib_dir = lit_config.substitute("@SHLIBDIR@")
1111
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
1212
config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
1313
config.cross_project_tests_obj_root = "@CROSS_PROJECT_TESTS_BINARY_DIR@"
@@ -21,16 +21,6 @@ config.mlir_src_root = "@MLIR_SOURCE_DIR@"
2121

2222
config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
2323

24-
# Support substitution of the tools_dir with user parameters. This is
25-
# used when we can't determine the tool dir at configuration time.
26-
try:
27-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
28-
config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params
29-
except KeyError:
30-
e = sys.exc_info()[1]
31-
key, = e.args
32-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
33-
3424
import lit.llvm
3525
lit.llvm.initialize(lit_config, config)
3626

flang/test/NonGtestUnit/lit.site.cfg.py.in

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
config.llvm_src_root = "@LLVM_SOURCE_DIR@"
44
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
5-
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
6-
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
7-
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
5+
config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@")
6+
config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@")
7+
config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@")
88
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
99
config.flang_obj_root = "@FLANG_BINARY_DIR@"
1010
config.flang_src_root = "@FLANG_SOURCE_DIR@"
@@ -13,15 +13,5 @@ config.flang_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
1313
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1414
config.python_executable = "@Python3_EXECUTABLE@"
1515

16-
# Support substitution of the tools and libs dirs with user parameters. This is
17-
# used when we can't determine the tool dir at configuration time.
18-
try:
19-
config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
20-
config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params
21-
config.llvm_build_mode = config.llvm_build_mode % lit_config.params
22-
except KeyError as e:
23-
key, = e.args
24-
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
25-
2616
# Let the main config do the real work.
2717
lit_config.load_config(config, "@FLANG_SOURCE_DIR@/test/NonGtestUnit/lit.cfg.py")

0 commit comments

Comments
 (0)