Skip to content

Commit 753cbcd

Browse files
authored
[test] Generate Lit Swift features file once during CMake generation (#77658)
Some people are reporting problems with the features file being missing during testing. Try executing the same process that will regenerate the files when dependencies change during CMake generation, so the file is there after the project is configured. (Maybe) Fixes #77642
1 parent 004ef74 commit 753cbcd

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

test/CMakeLists.txt

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,39 @@ function(swift_configure_lit_site_cfg source_path destination_path installed_nam
2828
endif()
2929
endfunction()
3030

31+
function(swift_generate_lit_swift_features_cfg output_path)
32+
if(SWIFT_COMPILER_IS_MSVC_LIKE)
33+
set(test_lit_swift_features_cmd
34+
"${CMAKE_C_COMPILER}" "/P" "/EP" "/I" "${SWIFT_MAIN_INCLUDE_DIR}" "/TC"
35+
"/Fi<<<OUTPUT_FILE>>>")
36+
else()
37+
set(test_lit_swift_features_cmd
38+
"${CMAKE_C_COMPILER}" "-E" "-P" "-I${SWIFT_MAIN_INCLUDE_DIR}" "-x" "c" "-o"
39+
"<<<OUTPUT_FILE>>>")
40+
endif()
41+
42+
list(
43+
TRANSFORM test_lit_swift_features_cmd
44+
REPLACE "<<<OUTPUT_FILE>>>" "${output_path}")
45+
add_custom_command(
46+
OUTPUT "${output_path}"
47+
COMMAND
48+
${test_lit_swift_features_cmd}
49+
"${CMAKE_CURRENT_SOURCE_DIR}/lit.swift-features.cfg.inc"
50+
DEPENDS
51+
"lit.swift-features.cfg.inc"
52+
"${SWIFT_MAIN_INCLUDE_DIR}/swift/Basic/Features.def"
53+
)
54+
55+
# Execute during generation once, so one can run Lit without rebuilding the
56+
# test suite dependencies first.
57+
execute_process(
58+
COMMAND
59+
${test_lit_swift_features_cmd}
60+
"${CMAKE_CURRENT_SOURCE_DIR}/lit.swift-features.cfg.inc"
61+
)
62+
endfunction()
63+
3164
function(normalize_boolean_spelling var_name)
3265
if(${var_name})
3366
set("${var_name}" TRUE PARENT_SCOPE)
@@ -254,16 +287,6 @@ if(NOT "${COVERAGE_DB}" STREQUAL "")
254287
COMMENT "Touching covering tests")
255288
endif()
256289

257-
if(SWIFT_COMPILER_IS_MSVC_LIKE)
258-
set(C_PREPROCESSOR_COMMAND
259-
"${CMAKE_C_COMPILER}" "/P" "/EP" "/I" "${SWIFT_MAIN_INCLUDE_DIR}" "/TC"
260-
"/Fi<<<OUTPUT_FILE>>>")
261-
else()
262-
set(C_PREPROCESSOR_COMMAND
263-
"${CMAKE_C_COMPILER}" "-E" "-P" "-I${SWIFT_MAIN_INCLUDE_DIR}" "-x" "c" "-o"
264-
"<<<OUTPUT_FILE>>>")
265-
endif()
266-
267290
foreach(SDK ${SWIFT_SDKS})
268291
foreach(ARCH ${SWIFT_SDK_${SDK}_ARCHITECTURES})
269292
# macCatalyst needs to run two sets of tests: one with the normal macosx target triple
@@ -315,33 +338,8 @@ foreach(SDK ${SWIFT_SDKS})
315338
"${validation_test_bin_dir}/lit.site.cfg"
316339
"validation-test${VARIANT_SUFFIX}.lit.site.cfg")
317340

318-
set(test_lit_swift_features_cmd ${C_PREPROCESSOR_COMMAND})
319-
list(
320-
TRANSFORM test_lit_swift_features_cmd
321-
REPLACE "<<<OUTPUT_FILE>>>" "${test_bin_dir}/lit.swift-features.cfg")
322-
add_custom_command(
323-
OUTPUT "${test_bin_dir}/lit.swift-features.cfg"
324-
COMMAND
325-
${test_lit_swift_features_cmd}
326-
"${CMAKE_CURRENT_SOURCE_DIR}/lit.swift-features.cfg.inc"
327-
DEPENDS
328-
"lit.swift-features.cfg.inc"
329-
"${SWIFT_MAIN_INCLUDE_DIR}/swift/Basic/Features.def"
330-
)
331-
332-
set(validation_test_lit_swift_features_cmd ${C_PREPROCESSOR_COMMAND})
333-
list(
334-
TRANSFORM validation_test_lit_swift_features_cmd
335-
REPLACE "<<<OUTPUT_FILE>>>" "${validation_test_bin_dir}/lit.swift-features.cfg")
336-
add_custom_command(
337-
OUTPUT "${validation_test_bin_dir}/lit.swift-features.cfg"
338-
COMMAND
339-
${validation_test_lit_swift_features_cmd}
340-
"${CMAKE_CURRENT_SOURCE_DIR}/lit.swift-features.cfg.inc"
341-
DEPENDS
342-
"lit.swift-features.cfg.inc"
343-
"${SWIFT_MAIN_INCLUDE_DIR}/swift/Basic/Features.def"
344-
)
341+
swift_generate_lit_swift_features_cfg("${test_bin_dir}/lit.swift-features.cfg")
342+
swift_generate_lit_swift_features_cfg("${validation_test_bin_dir}/lit.swift-features.cfg")
345343
add_custom_target(lit_swift_features_cfg_${VARIANT_SUFFIX}
346344
DEPENDS
347345
"${test_bin_dir}/lit.swift-features.cfg"

0 commit comments

Comments
 (0)