Skip to content

Commit 1d2d0a6

Browse files
author
Harlan
authored
[CMake] Only build SwiftSyntax if building SDK overlays (#12141)
* [CMake] Only build SwiftSyntax if building SDK overlays SwiftSyntax depends on Foundation, which depends on the SDK overlays being built. However, the existing build configuration tried to build SwiftSyntax even if the SDK overlays were not built. Ensure we're building overlays before building SwiftSyntax, and guard tests with an sdk_overlay test. * Remove TODO comment
1 parent 483a894 commit 1d2d0a6

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

test/SwiftSyntax/LazyCaching.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33
// REQUIRES: OS=macosx
4+
// REQUIRES: sdk_overlay
45

56
import StdlibUnittest
67
import Foundation

test/SwiftSyntax/ParseFile.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33
// REQUIRES: OS=macosx
4+
// REQUIRES: sdk_overlay
45

56
import Foundation
67
import StdlibUnittest

test/SwiftSyntax/SyntaxFactory.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-run-simple-swift
22
// REQUIRES: executable_test
33
// REQUIRES: OS=macosx
4+
// REQUIRES: sdk_overlay
45

56
import Foundation
67
import StdlibUnittest

test/lit.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ sdk_overlay_linker_opt = ""
295295
sdk_overlay_dir_opt = ""
296296
test_sdk_overlay_dir = lit_config.params.get('test_sdk_overlay_dir', None)
297297
if test_sdk_overlay_dir is not None:
298+
config.available_features.add('sdk_overlay')
299+
298300
sdk_overlay_dir_opt = ("-I %s" % os.path.join(test_sdk_overlay_dir, run_cpu))
299301
sdk_overlay_link_path_dir = os.path.join(test_sdk_overlay_dir, run_cpu)
300302
sdk_overlay_link_path = ("-L %s" % sdk_overlay_link_path_dir)

tools/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ if(SWIFT_HOST_VARIANT STREQUAL "macosx")
2222
# Only build Darwin-specific tools when deploying to OS X.
2323
add_swift_tool_subdirectory(swift-stdlib-tool)
2424

25-
if(SWIFT_BUILD_STDLIB)
25+
# SwiftSyntax depends on both the standard library (because it's a
26+
# Swift module), and the SDK overlays (because it depends on Foundation).
27+
# Ensure we only build SwiftSyntax when we're building both.
28+
if(SWIFT_BUILD_STDLIB AND SWIFT_BUILD_SDK_OVERLAY)
2629
add_subdirectory(SwiftSyntax)
2730
endif()
2831
endif()

0 commit comments

Comments
 (0)