Skip to content

Commit 30ab320

Browse files
Joe Shajrawimikeash
authored andcommitted
lit.cfg: move the DYLD_LIBRARY_PATH setting code to the config.substitutions
This change the order the configuration file to something that makes more sense: the platform_module_dir value was being set in the middle of the config.substitutions phase. We needed said value for setting the DYLD_LIBRARY_PATH, so that code was added right after it. The problem is that by that time config.substitutions.append(('%target-run', config.target_run)) has already happened for local targets This change moves all said code to just before the substitutions phase, much cleaner and resolves rdar://problem/49835064
1 parent a0aaf39 commit 30ab320

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

test/lit.cfg

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,47 @@ if platform.system() != 'Darwin':
11661166
config.target_resilience_test = ('%s --no-symbol-diff' %
11671167
config.target_resilience_test)
11681168

1169+
platform_module_dir = make_path(test_resource_dir, config.target_sdk_name)
1170+
if run_vendor != 'apple':
1171+
platform_module_dir = make_path(platform_module_dir, run_cpu)
1172+
lit_config.note('Using platform module dir: ' + platform_module_dir)
1173+
if test_sdk_overlay_dir:
1174+
platform_sdk_overlay_dir = test_sdk_overlay_dir
1175+
else:
1176+
platform_sdk_overlay_dir = platform_module_dir
1177+
1178+
# If static stdlib is present, enable static stdlib tests
1179+
static_stdlib_path = make_path(config.swift_lib_dir, "swift_static", config.target_sdk_name)
1180+
static_libswiftCore_path = make_path(static_stdlib_path, "libswiftCore.a")
1181+
if os.path.exists(static_libswiftCore_path):
1182+
config.available_features.add("static_stdlib")
1183+
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
1184+
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
1185+
1186+
# Set up testing with the standard libraries coming from the OS / just-built libraries
1187+
# default Swift tests to use the just-built libraries
1188+
target_stdlib_path = platform_module_dir
1189+
if not kIsWindows:
1190+
if 'use_os_stdlib' not in lit_config.params:
1191+
lit_config.note('Testing with the just-built libraries at ' + target_stdlib_path)
1192+
config.target_run = (
1193+
"/usr/bin/env "
1194+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1195+
"LD_LIBRARY_PATH='{0}' " # Linux option
1196+
.format(target_stdlib_path))
1197+
else:
1198+
os_stdlib_path = ''
1199+
if run_vendor == 'apple':
1200+
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1201+
os_stdlib_path = "/usr/lib/swift"
1202+
all_stdlib_path = os.path.pathsep.join((os_stdlib_path, target_stdlib_path))
1203+
lit_config.note('Testing with the standard libraries coming from the OS ' + all_stdlib_path)
1204+
config.target_run = (
1205+
"/usr/bin/env "
1206+
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1207+
"LD_LIBRARY_PATH='{0}' " # Linux option
1208+
.format(all_stdlib_path))
1209+
11691210
#
11701211
# When changing substitutions, update docs/Testing.rst.
11711212
#
@@ -1254,13 +1295,6 @@ if hasattr(config, 'target_swift_autolink_extract'):
12541295
config.substitutions.append(('%target-swift-modulewrap',
12551296
config.target_swift_modulewrap))
12561297

1257-
platform_module_dir = make_path(test_resource_dir, '%target-sdk-name', run_cpu)
1258-
lit_config.note('Using platform module dir: ' + platform_module_dir)
1259-
if test_sdk_overlay_dir is not None:
1260-
platform_sdk_overlay_dir = make_path(test_sdk_overlay_dir, run_cpu)
1261-
else:
1262-
platform_sdk_overlay_dir = platform_module_dir
1263-
12641298
config.substitutions.insert(0, ('%platform-module-dir', platform_module_dir))
12651299
config.substitutions.insert(0, ('%platform-sdk-overlay-dir', platform_sdk_overlay_dir))
12661300

@@ -1284,37 +1318,6 @@ config.substitutions.append(
12841318
pipes.quote(config.filecheck))))
12851319
config.substitutions.append(('%raw-FileCheck', pipes.quote(config.filecheck)))
12861320

1287-
# If static stdlib is present, enable static stdlib tests
1288-
static_stdlib_path = make_path(config.swift_lib_dir, "swift_static", config.target_sdk_name)
1289-
libswiftCore_path = make_path(static_stdlib_path, "libswiftCore.a")
1290-
if os.path.exists(libswiftCore_path):
1291-
config.available_features.add("static_stdlib")
1292-
config.substitutions.append(('%target-static-stdlib-path', static_stdlib_path))
1293-
lit_config.note('using static stdlib path: %s' % static_stdlib_path)
1294-
1295-
# Set up testing with the standard libraries coming from the OS / just-built libraries
1296-
# default Swift tests to use the just-built libraries
1297-
target_stdlib_path = platform_module_dir
1298-
if 'use_os_stdlib' not in lit_config.params:
1299-
lit_config.note('Testing with the just-built libraries at ' + target_stdlib_path)
1300-
config.target_run = (
1301-
"/usr/bin/env "
1302-
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1303-
"LD_LIBRARY_PATH='{0}' " # Linux option
1304-
.format(target_stdlib_path))
1305-
else:
1306-
os_stdlib_path = ''
1307-
if run_vendor == 'apple':
1308-
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1309-
os_stdlib_path = "/usr/lib/swift"
1310-
all_stdlib_path = os.path.pathsep.join((os_stdlib_path, target_stdlib_path))
1311-
lit_config.note('Testing with the standard libraries coming from the OS ' + all_stdlib_path)
1312-
config.target_run = (
1313-
"/usr/bin/env "
1314-
"DYLD_LIBRARY_PATH='{0}' " # Apple option
1315-
"LD_LIBRARY_PATH='{0}' " # Linux option
1316-
.format(all_stdlib_path))
1317-
13181321
if config.lldb_build_root != "":
13191322
config.available_features.add('lldb')
13201323
# Note: using the same approach to locating the lib dir as in

0 commit comments

Comments
 (0)