Files
swift-mirror/test/Macros/lit.local.cfg
Daniel Rodríguez Troitiño 83a9913ac1 [test] Propagate CMake shared linker flags for tests to use (#85623)
The same that some setups needs the `CMAKE_EXE_LINKER_FLAGS` propagated
for the test to compile plugins in the same configuration as the
compiler was using, the `CMAKE_SHARED_LINKER_FLAGS` needs to be
propagated if one wants to match the configuration used by CMake to
create libraries during the tests.

Add a new `config` value derived from `CMAKE_EXE_LINKER_FLAGS`, turn
that value into a substitution for the `Macros` tests, and use the
substibution in one test that creates a shared object. This allows the
shared object to be linked in the same way that it has been configured
in CMake.
2025-12-01 09:41:27 -08:00

35 lines
1.4 KiB
INI

# '-enable-experimental-feature Macros' requires an asserts build.
if 'asserts' not in config.available_features:
config.unsupported = True
config.subsitutions = list(config.substitutions)
def get_target_os():
import re
(run_cpu, run_vendor, run_os, run_version) = re.match('([^-]+)-([^-]+)-([^0-9]+)(.*)', config.variant_triple).groups()
return run_os
if get_target_os() in ['windows-msvc']:
config.substitutions.insert(0, ('%target-abi', 'WIN'))
config.substitutions.insert(
0,
(
'%swift-build-c-plugin',
'%clang -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin'
)
)
else:
# FIXME(compnerd) do all the targets we currently support use SysV ABI?
config.substitutions.insert(0, ('%target-abi', 'SYSV'))
config.substitutions.insert(0, ('%cmake-c-compiler', config.cmake_c_compiler))
config.substitutions.insert(
0,
(
'%swift-build-c-plugin',
'%cmake-c-compiler %c-flags %exe-linker-flags -target %host_triple -isysroot %host_sdk -I %swift_src_root/include -L %swift-lib-dir -l_swiftMockPlugin -Xlinker -rpath -Xlinker %swift-lib-dir'
)
)
config.substitutions.append(('%c-flags', config.c_flags))
config.substitutions.append(('%exe-linker-flags', config.exe_linker_flags))
config.substitutions.append(('%shared-linker-flags', config.shared_linker_flags))