diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 82562eb7a01..5af06570360 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -37,3 +37,4 @@ add_subdirectory(swift-run) add_subdirectory(swift-test) add_subdirectory(SwiftSDKCommand) add_subdirectory(Workspace) +add_subdirectory(XCBuildSupport) diff --git a/Sources/Commands/CMakeLists.txt b/Sources/Commands/CMakeLists.txt index 3f2275fbe02..e74414c60bf 100644 --- a/Sources/Commands/CMakeLists.txt +++ b/Sources/Commands/CMakeLists.txt @@ -59,11 +59,8 @@ target_link_libraries(Commands PUBLIC SourceControl TSCBasic TSCUtility - Workspace) - -target_compile_definitions(Commands - PRIVATE DISABLE_XCBUILD_SUPPORT) - + Workspace + XCBuildSupport) target_link_libraries(Commands PRIVATE DriverSupport $<$>:FoundationXML>) diff --git a/Sources/Commands/PackageCommands/DumpCommands.swift b/Sources/Commands/PackageCommands/DumpCommands.swift index bde6b0d0fe1..8727d1dd0e5 100644 --- a/Sources/Commands/PackageCommands/DumpCommands.swift +++ b/Sources/Commands/PackageCommands/DumpCommands.swift @@ -15,10 +15,7 @@ import Basics import CoreCommands import Foundation import PackageModel - -#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport -#endif struct DumpSymbolGraph: SwiftCommand { static let configuration = CommandConfiguration( @@ -139,7 +136,6 @@ struct DumpPIF: SwiftCommand { var preserveStructure: Bool = false func run(_ swiftCommandState: SwiftCommandState) throws { - #if !DISABLE_XCBUILD_SUPPORT let graph = try swiftCommandState.loadPackageGraph() let pif = try PIFBuilder.generatePIF( buildParameters: swiftCommandState.productsBuildParameters, @@ -148,9 +144,6 @@ struct DumpPIF: SwiftCommand { observabilityScope: swiftCommandState.observabilityScope, preservePIFModelStructure: preserveStructure) print(pif) - #else - fatalError("This subcommand is not available on the current platform") - #endif } var toolWorkspaceConfiguration: ToolWorkspaceConfiguration { diff --git a/Sources/Commands/PackageCommands/SwiftPackageCommand.swift b/Sources/Commands/PackageCommands/SwiftPackageCommand.swift index 826e22912b0..8c2170e2f1f 100644 --- a/Sources/Commands/PackageCommands/SwiftPackageCommand.swift +++ b/Sources/Commands/PackageCommands/SwiftPackageCommand.swift @@ -20,10 +20,7 @@ import PackageModel import SourceControl import SPMBuildCore import Workspace - -#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport -#endif import enum TSCUtility.Diagnostics diff --git a/Sources/Commands/SwiftBuildCommand.swift b/Sources/Commands/SwiftBuildCommand.swift index a29eca9d0e1..96b9a813d23 100644 --- a/Sources/Commands/SwiftBuildCommand.swift +++ b/Sources/Commands/SwiftBuildCommand.swift @@ -16,10 +16,7 @@ import Build import CoreCommands import PackageGraph import SPMBuildCore - -#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport -#endif import class TSCBasic.Process import var TSCBasic.stdoutStream diff --git a/Sources/CoreCommands/BuildSystemSupport.swift b/Sources/CoreCommands/BuildSystemSupport.swift index 567b2f0d186..3df40912808 100644 --- a/Sources/CoreCommands/BuildSystemSupport.swift +++ b/Sources/CoreCommands/BuildSystemSupport.swift @@ -12,10 +12,7 @@ import Build import SPMBuildCore - -#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport -#endif import class Basics.ObservabilityScope import struct PackageGraph.ModulesGraph @@ -63,7 +60,6 @@ private struct NativeBuildSystemFactory: BuildSystemFactory { } } -#if !DISABLE_XCBUILD_SUPPORT private struct XcodeBuildSystemFactory: BuildSystemFactory { let swiftCommandState: SwiftCommandState @@ -91,19 +87,12 @@ private struct XcodeBuildSystemFactory: BuildSystemFactory { ) } } -#endif extension SwiftCommandState { public var defaultBuildSystemProvider: BuildSystemProvider { - #if !DISABLE_XCBUILD_SUPPORT .init(providers: [ .native: NativeBuildSystemFactory(swiftCommandState: self), .xcode: XcodeBuildSystemFactory(swiftCommandState: self) ]) - #else - .init(providers: [ - .native: NativeBuildSystemFactory(swiftCommandState: self), - ]) - #endif } } diff --git a/Sources/CoreCommands/CMakeLists.txt b/Sources/CoreCommands/CMakeLists.txt index f9ae401890a..d7ec0cbb632 100644 --- a/Sources/CoreCommands/CMakeLists.txt +++ b/Sources/CoreCommands/CMakeLists.txt @@ -18,11 +18,8 @@ target_link_libraries(CoreCommands PUBLIC PackageGraph TSCBasic TSCUtility - Workspace) - -target_compile_definitions(CoreCommands - PRIVATE DISABLE_XCBUILD_SUPPORT) - + Workspace + XCBuildSupport) target_link_libraries(CoreCommands PRIVATE DriverSupport $<$>:FoundationXML>) diff --git a/Sources/XCBuildSupport/CMakeLists.txt b/Sources/XCBuildSupport/CMakeLists.txt new file mode 100644 index 00000000000..b478bdb56bd --- /dev/null +++ b/Sources/XCBuildSupport/CMakeLists.txt @@ -0,0 +1,25 @@ +# This source file is part of the Swift open source project +# +# Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors +# Licensed under Apache License v2.0 with Runtime Library Exception +# +# See http://swift.org/LICENSE.txt for license information +# See http://swift.org/CONTRIBUTORS.txt for Swift project authors + +add_library(XCBuildSupport STATIC + PIF.swift + PIFBuilder.swift + XCBuildDelegate.swift + XCBuildMessage.swift + XCBuildOutputParser.swift + XcodeBuildSystem.swift) +target_link_libraries(XCBuildSupport PUBLIC + Build + DriverSupport + TSCBasic + TSCUtility + PackageGraph +) + +set_target_properties(XCBuildSupport PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/swift-bootstrap/CMakeLists.txt b/Sources/swift-bootstrap/CMakeLists.txt index e8cb9c4e879..92052ac7098 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -17,7 +17,5 @@ target_link_libraries(swift-bootstrap PRIVATE PackageModel SwiftDriver TSCBasic - TSCUtility) - -target_compile_definitions(swift-bootstrap - PRIVATE DISABLE_XCBUILD_SUPPORT) + TSCUtility + XCBuildSupport) diff --git a/Sources/swift-bootstrap/main.swift b/Sources/swift-bootstrap/main.swift index 55f6b58e000..03d505d269d 100644 --- a/Sources/swift-bootstrap/main.swift +++ b/Sources/swift-bootstrap/main.swift @@ -24,10 +24,7 @@ import PackageGraph import PackageLoading import PackageModel import SPMBuildCore - -#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport -#endif import struct TSCBasic.KeyedPair import func TSCBasic.topologicalSort @@ -332,7 +329,6 @@ struct SwiftBootstrapBuildTool: ParsableCommand { observabilityScope: self.observabilityScope ) case .xcode: - #if !DISABLE_XCBUILD_SUPPORT return try XcodeBuildSystem( buildParameters: buildParameters, packageGraphLoader: packageGraphLoader, @@ -341,9 +337,6 @@ struct SwiftBootstrapBuildTool: ParsableCommand { fileSystem: self.fileSystem, observabilityScope: self.observabilityScope ) - #else - fatalError("SwiftPM was built without XCBuild support") - #endif } }