Skip to content

Commit 183de84

Browse files
committed
build: begin rooting out EXCLUDE_FROM_ALL
`EXCLUDE_FROM_ALL` should be discouraged. `ALL` should build *all* targets. If a subset of targets are desired to be built, we should provide targets which make sense. Sink the single use of this flag into the standard library setup. The custom cross-compilation was the reason that the flag was plumbed all the way through. Cleaning up the macros that have been built up is needed to migrate towards proper cross-compilation support.
1 parent 4bc7837 commit 183de84

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,9 +2546,9 @@ function(_add_swift_executable_single name)
25462546

25472547
set(SWIFTEXE_SINGLE_SOURCES ${SWIFTEXE_SINGLE_UNPARSED_ARGUMENTS})
25482548

2549-
translate_flag(${SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL}
2550-
"EXCLUDE_FROM_ALL"
2551-
SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL_FLAG)
2549+
if(SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL)
2550+
message(SEND_ERROR "${name} is using EXCLUDE_FROM_ALL option which is deprecated.")
2551+
endif()
25522552

25532553
# Check arguments.
25542554
precondition(SWIFTEXE_SINGLE_SDK MESSAGE "Should specify an SDK")
@@ -2612,7 +2612,6 @@ function(_add_swift_executable_single name)
26122612
add_swift_source_group("${SWIFTEXE_SINGLE_EXTERNAL_SOURCES}")
26132613

26142614
add_executable(${name}
2615-
${SWIFTEXE_SINGLE_EXCLUDE_FROM_ALL_FLAG}
26162615
${SWIFTEXE_SINGLE_SOURCES}
26172616
${SWIFTEXE_SINGLE_EXTERNAL_SOURCES})
26182617

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function(add_swift_target_executable name)
1515

1616
set(SWIFTEXE_TARGET_SOURCES ${SWIFTEXE_TARGET_UNPARSED_ARGUMENTS})
1717

18-
translate_flag(${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL}
19-
"EXCLUDE_FROM_ALL"
20-
SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG)
18+
if(SWIFTEXE_TARGET_EXCLUDE_FROM_ALL)
19+
message(SEND_ERROR "${name} is using EXCLUDE_FROM_ALL which is deprecated.")
20+
endif()
2121

2222
# All Swift executables depend on the standard library.
2323
list(APPEND SWIFTEXE_TARGET_LINK_LIBRARIES swiftCore)
@@ -29,14 +29,6 @@ function(add_swift_target_executable name)
2929
set(VARIANT_SUFFIX "-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
3030
set(VARIANT_NAME "${name}${VARIANT_SUFFIX}")
3131

32-
set(SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT
33-
${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG})
34-
if(NOT "${VARIANT_SUFFIX}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SUFFIX}")
35-
# By default, don't build executables for target SDKs to avoid building
36-
# target stdlibs.
37-
set(SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT "EXCLUDE_FROM_ALL")
38-
endif()
39-
4032
if(SWIFTEXE_TARGET_BUILD_WITH_STDLIB)
4133
add_dependencies("swift-test-stdlib${VARIANT_SUFFIX}" ${VARIANT_NAME})
4234
endif()
@@ -54,8 +46,14 @@ function(add_swift_target_executable name)
5446
LLVM_LINK_COMPONENTS ${SWIFTEXE_TARGET_LLVM_LINK_COMPONENTS}
5547
SDK "${sdk}"
5648
ARCHITECTURE "${arch}"
57-
LINK_LIBRARIES ${SWIFTEXE_TARGET_LINK_LIBRARIES}
58-
${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT})
49+
LINK_LIBRARIES ${SWIFTEXE_TARGET_LINK_LIBRARIES})
50+
51+
if(NOT "${VARIANT_SUFFIX}" STREQUAL "${SWIFT_PRIMARY_VARIANT_SUFFIX}")
52+
# By default, don't build executables for target SDKs to avoid building
53+
# target stdlibs.
54+
set_target_properties(${VARIANT_NAME} PROPERTIES
55+
EXCLUDE_FROM_ALL TRUE)
56+
endif()
5957

6058
if(${sdk} IN_LIST SWIFT_APPLE_PLATFORMS)
6159
add_custom_command_target(unused_var2

0 commit comments

Comments
 (0)