Skip to content

Commit

Permalink
[CMake] Only build SwiftSyntax if building SDK overlays (#12141)
Browse files Browse the repository at this point in the history
* [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
  • Loading branch information
harlanhaskins committed Oct 4, 2017
1 parent 483a894 commit 1d2d0a6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions test/SwiftSyntax/LazyCaching.swift
@@ -1,6 +1,7 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: OS=macosx
// REQUIRES: sdk_overlay

import StdlibUnittest
import Foundation
Expand Down
1 change: 1 addition & 0 deletions test/SwiftSyntax/ParseFile.swift
@@ -1,6 +1,7 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: OS=macosx
// REQUIRES: sdk_overlay

import Foundation
import StdlibUnittest
Expand Down
1 change: 1 addition & 0 deletions test/SwiftSyntax/SyntaxFactory.swift
@@ -1,6 +1,7 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: OS=macosx
// REQUIRES: sdk_overlay

import Foundation
import StdlibUnittest
Expand Down
2 changes: 2 additions & 0 deletions test/lit.cfg
Expand Up @@ -295,6 +295,8 @@ sdk_overlay_linker_opt = ""
sdk_overlay_dir_opt = ""
test_sdk_overlay_dir = lit_config.params.get('test_sdk_overlay_dir', None)
if test_sdk_overlay_dir is not None:
config.available_features.add('sdk_overlay')

sdk_overlay_dir_opt = ("-I %s" % os.path.join(test_sdk_overlay_dir, run_cpu))
sdk_overlay_link_path_dir = os.path.join(test_sdk_overlay_dir, run_cpu)
sdk_overlay_link_path = ("-L %s" % sdk_overlay_link_path_dir)
Expand Down
5 changes: 4 additions & 1 deletion tools/CMakeLists.txt
Expand Up @@ -22,7 +22,10 @@ if(SWIFT_HOST_VARIANT STREQUAL "macosx")
# Only build Darwin-specific tools when deploying to OS X.
add_swift_tool_subdirectory(swift-stdlib-tool)

if(SWIFT_BUILD_STDLIB)
# SwiftSyntax depends on both the standard library (because it's a
# Swift module), and the SDK overlays (because it depends on Foundation).
# Ensure we only build SwiftSyntax when we're building both.
if(SWIFT_BUILD_STDLIB AND SWIFT_BUILD_SDK_OVERLAY)
add_subdirectory(SwiftSyntax)
endif()
endif()
Expand Down

0 comments on commit 1d2d0a6

Please sign in to comment.