@@ -42,21 +42,21 @@ var targets: [Target] = [
4242 . target(
4343 name: " SwiftFormat " ,
4444 dependencies: [
45- . product( name: " Markdown " , package : " swift-markdown " ) ,
46- . product( name: " SwiftSyntax " , package : " swift-syntax " ) ,
47- . product( name: " SwiftSyntaxBuilder " , package : " swift-syntax " ) ,
48- . product( name: " SwiftOperators " , package : " swift-syntax " ) ,
49- . product( name: " SwiftParser " , package : " swift-syntax " ) ,
50- . product( name: " SwiftParserDiagnostics " , package : " swift-syntax " ) ,
51- ] ,
45+ . product( name: " Markdown " , package : " swift-markdown " )
46+ ]
47+ + swiftSyntaxDependencies( [
48+ " SwiftOperators " , " SwiftParser " , " SwiftParserDiagnostics " , " SwiftSyntax " , " SwiftSyntaxBuilder " ,
49+ ] ) ,
5250 exclude: [ " CMakeLists.txt " ]
5351 ) ,
5452 . target(
5553 name: " _SwiftFormatTestSupport " ,
5654 dependencies: [
57- " SwiftFormat " ,
58- . product( name: " SwiftOperators " , package : " swift-syntax " ) ,
55+ " SwiftFormat "
5956 ]
57+ + swiftSyntaxDependencies( [
58+ " SwiftOperators " , " SwiftParser " , " SwiftParserDiagnostics " , " SwiftSyntax " , " SwiftSyntaxBuilder " ,
59+ ] )
6060 ) ,
6161 . plugin(
6262 name: " Format Source Code " ,
@@ -98,7 +98,7 @@ var targets: [Target] = [
9898 . product( name: " ArgumentParser " , package : " swift-argument-parser " ) ,
9999 . product( name: " SwiftSyntax " , package : " swift-syntax " ) ,
100100 . product( name: " SwiftParser " , package : " swift-syntax " ) ,
101- ] ,
101+ ] + swiftSyntaxDependencies ( [ " SwiftParser " , " SwiftSyntax " ] ) ,
102102 exclude: [ " CMakeLists.txt " ] ,
103103 linkerSettings: swiftformatLinkSettings
104104 ) ,
@@ -110,7 +110,7 @@ var targets: [Target] = [
110110 " _SwiftFormatTestSupport " ,
111111 . product( name: " SwiftSyntax " , package : " swift-syntax " ) ,
112112 . product( name: " SwiftParser " , package : " swift-syntax " ) ,
113- ]
113+ ] + swiftSyntaxDependencies ( [ " SwiftParser " , " SwiftSyntax " ] )
114114 ) ,
115115 . testTarget(
116116 name: " SwiftFormatTests " ,
@@ -153,6 +153,14 @@ let package = Package(
153153 targets: targets
154154)
155155
156+ func swiftSyntaxDependencies( _ names: [ String ] ) -> [ Target . Dependency ] {
157+ if buildDynamicSwiftSyntaxLibrary {
158+ return [ . product( name: " _SwiftSyntaxDynamic " , package : " swift-syntax " ) ]
159+ } else {
160+ return names. map { . product( name: $0, package : " swift-syntax " ) }
161+ }
162+ }
163+
156164// MARK: - Parse build arguments
157165
158166func hasEnvironmentVariable( _ name: String ) -> Bool {
@@ -174,6 +182,15 @@ var useLocalDependencies: Bool { hasEnvironmentVariable("SWIFTCI_USE_LOCAL_DEPS"
174182/// the `swift test` invocation so that all pre-built modules can be found.
175183var buildOnlyTests : Bool { hasEnvironmentVariable ( " SWIFTFORMAT_BUILD_ONLY_TESTS " ) }
176184
185+ /// Whether swift-syntax is being built as a single dynamic library instead of as a separate library per module.
186+ ///
187+ /// This means that the swift-syntax symbols don't need to be statically linked, which alles us to stay below the
188+ /// maximum number of exported symbols on Windows, in turn allowing us to build sourcekit-lsp using SwiftPM on Windows
189+ /// and run its tests.
190+ var buildDynamicSwiftSyntaxLibrary : Bool {
191+ hasEnvironmentVariable ( " SWIFTSYNTAX_BUILD_DYNAMIC_LIBRARY " )
192+ }
193+
177194// MARK: - Dependencies
178195
179196var dependencies : [ Package . Dependency ] {
0 commit comments