Skip to content

Commit 118c4cf

Browse files
committed
build: remove the requirement to checkout swift-syntax
In the case that a shared copy of swift-syntax is being used to build, allow the sources to be unavailable. If the user specifies `SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE`, that will be preferred, otherwise, we fallback to the upstream git repository.
1 parent a408054 commit 118c4cf

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
SET(SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE ${CMAKE_SOURCE_DIR}/../swift-syntax)
2-
message(STATUS "swift-syntax path: ${SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE}")
3-
41
include(FetchContent)
52

6-
if(NOT EXISTS "${SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE}")
7-
message(SEND_ERROR "swift-syntax is required to build SwiftPM. Please run update-checkout or specify SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE")
8-
return()
9-
endif()
10-
11-
# Build swift-syntax libraries with FetchContent.
12-
# set(CMAKE_Swift_COMPILER_TARGET ${SWIFT_HOST_TRIPLE})
133
set(BUILD_SHARED_LIBS OFF)
144

15-
file(TO_CMAKE_PATH "${SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE}" swift_syntax_path)
16-
FetchContent_Declare(SwiftSyntax SOURCE_DIR "${swift_syntax_path}")
5+
if(DEFINED SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE)
6+
file(TO_CMAKE_PATH "${SWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE}" swift_syntax_path)
7+
FetchContent_Declare(SwiftSyntax
8+
SOURCE_DIR "${swift_syntax_path}")
9+
else()
10+
FetchContent_Declare(SwiftSyntax
11+
GIT_REPOSITORY https://github.com/apple/swift-syntax
12+
GIT_TAG main)
13+
endif()
1714
FetchContent_MakeAvailable(SwiftSyntax)

Utilities/bootstrap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def parse_global_args(args):
202202
args.source_dirs["swift-collections"] = os.path.join(args.project_root, "..", "swift-collections")
203203
args.source_dirs["swift-certificates"] = os.path.join(args.project_root, "..", "swift-certificates")
204204
args.source_dirs["swift-asn1"] = os.path.join(args.project_root, "..", "swift-asn1")
205+
args.source_dirs["swift-syntax"] = os.path.join(args.project_root, "..", "swift-syntax")
205206
args.source_root = os.path.join(args.project_root, "Sources")
206207

207208
if platform.system() == 'Darwin':
@@ -608,6 +609,7 @@ def build_swiftpm_with_cmake(args):
608609
"-DSwiftCrypto_DIR=" + os.path.join(args.build_dirs["swift-crypto"], "cmake/modules"),
609610
"-DSwiftASN1_DIR=" + os.path.join(args.build_dirs["swift-asn1"], "cmake/modules"),
610611
"-DSwiftCertificates_DIR=" + os.path.join(args.build_dirs["swift-certificates"], "cmake/modules"),
612+
"-DSWIFTPM_PATH_TO_SWIFT_SYNTAX_SOURCE=" + args.source_dirs["swift-syntax"],
611613
]
612614

613615
if platform.system() == 'Darwin':

0 commit comments

Comments
 (0)