Skip to content

Commit 7974e39

Browse files
committed
build: collapse two checks into a single one (NFC)
Merge two cases into a single case rather than keeping them separate. Additionally check the condition early rather than perform the action and then revert it. NFC.
1 parent d426a71 commit 7974e39

File tree

1 file changed

+10
-23
lines changed

1 file changed

+10
-23
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,34 +1536,21 @@ function(add_swift_library name)
15361536
# library itself.
15371537
if(SWIFTLIB_HAS_SWIFT_CONTENT AND NOT SWIFTLIB_IS_STDLIB_CORE)
15381538
list(APPEND SWIFTLIB_SWIFT_MODULE_DEPENDS Core)
1539-
endif()
1540-
1541-
if((NOT "${SWIFT_BUILD_STDLIB}") AND
1542-
(NOT "${SWIFTLIB_SWIFT_MODULE_DEPENDS}" STREQUAL ""))
1543-
list(REMOVE_ITEM SWIFTLIB_SWIFT_MODULE_DEPENDS
1544-
Core)
1545-
endif()
15461539

1547-
if(SWIFTLIB_HAS_SWIFT_CONTENT AND NOT SWIFTLIB_IS_STDLIB_CORE)
1548-
# All Swift code depends on the SwiftOnoneSupport in non-optimized mode,
1549-
# except for the standard library itself.
1550-
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" optimized)
1551-
if(NOT optimized)
1552-
list(APPEND SWIFTLIB_SWIFT_MODULE_DEPENDS SwiftOnoneSupport)
1540+
# swiftSwiftOnoneSupport does not depend on itself, obviously.
1541+
if(NOT ${name} STREQUAL swiftSwiftOnoneSupport)
1542+
# All Swift code depends on the SwiftOnoneSupport in non-optimized mode,
1543+
# except for the standard library itself.
1544+
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" optimized)
1545+
if(NOT optimized)
1546+
list(APPEND SWIFTLIB_SWIFT_MODULE_DEPENDS SwiftOnoneSupport)
1547+
endif()
15531548
endif()
15541549
endif()
15551550

15561551
if((NOT "${SWIFT_BUILD_STDLIB}") AND
1557-
(NOT "${SWIFTLIB_SWIFT_MODULE_DEPENDS}" STREQUAL ""))
1558-
list(REMOVE_ITEM SWIFTLIB_SWIFT_MODULE_DEPENDS
1559-
SwiftOnoneSupport)
1560-
endif()
1561-
1562-
# swiftSwiftOnoneSupport does not depend on itself,
1563-
# obviously.
1564-
if("${name}" STREQUAL "swiftSwiftOnoneSupport")
1565-
list(REMOVE_ITEM SWIFTLIB_SWIFT_MODULE_DEPENDS
1566-
SwiftOnoneSupport)
1552+
(NOT "${SWIFTLIB_SWIFT_MODULE_DEPENDS}" STREQUAL ""))
1553+
list(REMOVE_ITEM SWIFTLIB_SWIFT_MODULE_DEPENDS Core SwiftOnoneSupport)
15671554
endif()
15681555

15691556
translate_flags(SWIFTLIB "${SWIFTLIB_options}")

0 commit comments

Comments
 (0)