Skip to content

Commit d73689f

Browse files
committed
[test] lit.cfg: TARGET_ENV_PREFIX ⟹ config.target_env_prefix
Also, integrate its configuration into the preexisting target if ladders, where it belongs.
1 parent 30d3950 commit d73689f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

test/lit.cfg

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,7 @@ config.target_cxx_lib = '-lc++'
940940
config.target_msvc_runtime_opt = ''
941941
config.target_static_library_prefix = 'lib'
942942
config.target_static_library_suffix = '.a'
943+
config.target_env_prefix = ''
943944

944945
if run_vendor == 'apple':
945946
target_specific_module_triple = '{}-apple-{}'.format(
@@ -1080,6 +1081,8 @@ if run_vendor == 'apple':
10801081
xcrun_sdk_name = "watchos"
10811082
target_future_version = "9.99.0"
10821083

1084+
config.target_env_prefix = 'IOS_CHILD_'
1085+
10831086
config.target_cc_options = (
10841087
"-target %s %s" %
10851088
(config.variant_triple, clang_mcp_opt))
@@ -1122,6 +1125,8 @@ if run_vendor == 'apple':
11221125

11231126
target_specific_module_triple += "-simulator"
11241127

1128+
config.target_env_prefix = 'SIMCTL_CHILD_'
1129+
11251130
config.target_cc_options = (
11261131
"-target %s %s" %
11271132
(config.variant_triple, clang_mcp_opt))
@@ -1330,6 +1335,7 @@ elif run_os in ['windows-msvc']:
13301335
config.target_msvc_runtime_opt = '-%s -D_MT' % config.swift_stdlib_msvc_runtime
13311336
if 'D' in config.swift_stdlib_msvc_runtime:
13321337
config.target_msvc_runtime_opt += ' -D_DLL'
1338+
config.target_env_prefix = ''
13331339

13341340
config.target_build_swift = \
13351341
('%r -target %s %s %s %s %s -libc %s' % \
@@ -1439,6 +1445,7 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
14391445
config.target_shared_library_suffix = ".so"
14401446
config.target_sdk_name = "android"
14411447
config.target_cc_options = "-fPIE"
1448+
config.target_env_prefix = 'ANDROID_CHILD_'
14421449
else:
14431450
lit_config.note("Testing Linux " + config.variant_triple)
14441451
config.target_object_format = "elf"
@@ -1572,6 +1579,7 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
15721579
config.target_runtime = "native"
15731580
config.target_swift_autolink_extract = inferSwiftBinary("swift-autolink-extract")
15741581
config.target_sdk_name = "android"
1582+
config.target_env_prefix = 'ANDROID_CHILD_'
15751583
config.resource_dir_opt = ("-resource-dir %s" % test_resource_dir)
15761584
# Since NDK r19, the headers and libraries are available in a unified
15771585
# sysroot at $NDK_PATH/toolchains/llvm/prebuilt/$prebuilt_directory/sysroot,
@@ -1775,19 +1783,6 @@ config.substitutions.append(('%string_processing_module', string_processing_modu
17751783
config.substitutions.append(('%/string_processing_module',
17761784
'/'.join(os.path.normpath(string_processing_module).split(os.sep))))
17771785

1778-
# Different OS's require different prefixes for the environment variables to be
1779-
# propagated to the calling contexts.
1780-
# In order to make tests OS-agnostic, names of environment variables should be
1781-
# prefixed with `%env-`, which is then expanded to the appropriate prefix.
1782-
SIMULATOR_ENV_PREFIX = 'SIMCTL_CHILD_'
1783-
ENV_VAR_PREFIXES = {
1784-
'iphonesimulator': SIMULATOR_ENV_PREFIX,
1785-
'watchsimulator': SIMULATOR_ENV_PREFIX,
1786-
'appletvsimulator': SIMULATOR_ENV_PREFIX,
1787-
'android': 'ANDROID_CHILD_'
1788-
}
1789-
TARGET_ENV_PREFIX = ENV_VAR_PREFIXES.get(config.target_sdk_name, "") if not kIsAndroid else ""
1790-
17911786
back_deployment_runtime = lit_config.params.get('back_deployment_runtime', None)
17921787
if back_deployment_runtime is not None:
17931788
config.available_features.add('back_deployment_runtime')
@@ -1861,6 +1856,7 @@ if 'remote_run_host' in lit_config.params:
18611856
os.path.dirname(local_swift_reflection_test),
18621857
'bin/')
18631858

1859+
config.target_env_prefix = 'REMOTE_RUN_CHILD_'
18641860
config.target_run = (
18651861
"/usr/bin/env "
18661862
"REMOTE_RUN_CHILD_DYLD_LIBRARY_PATH='{0}' " # Apple option
@@ -1874,10 +1870,14 @@ if 'remote_run_host' in lit_config.params:
18741870
remote_run_host))
18751871
config.target_swift_reflection_test = os.path.join(
18761872
remote_tmp_dir, 'bin', swift_reflection_test_name)
1877-
TARGET_ENV_PREFIX = 'REMOTE_RUN_CHILD_'
18781873
config.available_features.add('remote_run')
18791874

1880-
config.substitutions.append(('%env-', TARGET_ENV_PREFIX))
1875+
# Different OS's require different prefixes for the environment variables to be
1876+
# propagated to the calling contexts.
1877+
# In order to make tests OS-agnostic, names of environment variables should be
1878+
# prefixed with `%env-`, which is then expanded to the appropriate prefix.
1879+
config.substitutions.append(('%env-', config.target_env_prefix))
1880+
18811881
config.substitutions.append(("%target-sdk-name", config.target_sdk_name))
18821882

18831883
simulator_sdks = [
@@ -2410,7 +2410,7 @@ config.substitutions.append(('%import-static-libdispatch', getattr(config, 'impo
24102410
config.environment['SWIFT_DEBUG_ENABLE_COW_CHECKS'] = 'false'
24112411

24122412
# Add this to the command which runs an executable to enable COW checks in the swift runtime.
2413-
config.substitutions.append(('%enable-cow-checking', TARGET_ENV_PREFIX + 'SWIFT_DEBUG_ENABLE_COW_CHECKS=true;'))
2413+
config.substitutions.append(('%enable-cow-checking', config.target_env_prefix + 'SWIFT_DEBUG_ENABLE_COW_CHECKS=true;'))
24142414

24152415
# We add an expansion to ensure that migrator tests can search for the api diff
24162416
# data dir from the host compiler toolchain instead of the resource dir of the
@@ -2445,10 +2445,10 @@ if config.lldb_build_root != "":
24452445
# Disable randomized hash seeding by default. Tests need to manually opt in to
24462446
# random seeds by unsetting the SWIFT_DETERMINISTIC_HASHING environment
24472447
# variable.
2448-
config.environment[TARGET_ENV_PREFIX + 'SWIFT_DETERMINISTIC_HASHING'] = '1'
2448+
config.environment[config.target_env_prefix + 'SWIFT_DETERMINISTIC_HASHING'] = '1'
24492449

24502450
# Enable malloc scribble during tests by default.
2451-
config.environment[TARGET_ENV_PREFIX + 'SWIFT_DEBUG_ENABLE_MALLOC_SCRIBBLE'] = 'YES'
2451+
config.environment[config.target_env_prefix + 'SWIFT_DEBUG_ENABLE_MALLOC_SCRIBBLE'] = 'YES'
24522452

24532453
# Run lsb_release on the target to be tested and return the results.
24542454
def linux_get_lsb_release():

0 commit comments

Comments
 (0)