diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index a8aa9f771bc..a148ae10fb8 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -37,4 +37,3 @@ add_subdirectory(swift-package) add_subdirectory(swift-run) add_subdirectory(swift-test) add_subdirectory(Workspace) -add_subdirectory(XCBuildSupport) diff --git a/Sources/Commands/CMakeLists.txt b/Sources/Commands/CMakeLists.txt index b20e318afad..eb8242ee3e0 100644 --- a/Sources/Commands/CMakeLists.txt +++ b/Sources/Commands/CMakeLists.txt @@ -59,8 +59,11 @@ target_link_libraries(Commands PUBLIC SourceControl TSCBasic TSCUtility - Workspace - XCBuildSupport) + Workspace) + +target_compile_definitions(Commands + PRIVATE DISABLE_XCBUILD_SUPPORT) + target_link_libraries(Commands PRIVATE DriverSupport $<$>:FoundationXML>) diff --git a/Sources/Commands/PackageTools/DumpCommands.swift b/Sources/Commands/PackageTools/DumpCommands.swift index 35845334ad2..3a569807e70 100644 --- a/Sources/Commands/PackageTools/DumpCommands.swift +++ b/Sources/Commands/PackageTools/DumpCommands.swift @@ -15,7 +15,10 @@ import Basics import CoreCommands import Foundation import PackageModel + +#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport +#endif struct DumpSymbolGraph: SwiftCommand { static let configuration = CommandConfiguration( @@ -136,6 +139,7 @@ struct DumpPIF: SwiftCommand { var preserveStructure: Bool = false func run(_ swiftTool: SwiftTool) throws { + #if !DISABLE_XCBUILD_SUPPORT let graph = try swiftTool.loadPackageGraph() let pif = try PIFBuilder.generatePIF( buildParameters: swiftTool.productsBuildParameters, @@ -144,6 +148,9 @@ struct DumpPIF: SwiftCommand { observabilityScope: swiftTool.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/PackageTools/SwiftPackageTool.swift b/Sources/Commands/PackageTools/SwiftPackageTool.swift index 61495a66a1b..ececa15cf65 100644 --- a/Sources/Commands/PackageTools/SwiftPackageTool.swift +++ b/Sources/Commands/PackageTools/SwiftPackageTool.swift @@ -20,7 +20,10 @@ import PackageModel import SourceControl import SPMBuildCore import Workspace + +#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport +#endif import enum TSCUtility.Diagnostics diff --git a/Sources/Commands/SwiftBuildTool.swift b/Sources/Commands/SwiftBuildTool.swift index 521eb0c9405..ed01e55084b 100644 --- a/Sources/Commands/SwiftBuildTool.swift +++ b/Sources/Commands/SwiftBuildTool.swift @@ -16,7 +16,10 @@ 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 1f2a45bbdc7..ec96b4170df 100644 --- a/Sources/CoreCommands/BuildSystemSupport.swift +++ b/Sources/CoreCommands/BuildSystemSupport.swift @@ -12,7 +12,10 @@ import Build import SPMBuildCore + +#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport +#endif import class Basics.ObservabilityScope import struct PackageGraph.PackageGraph @@ -60,6 +63,7 @@ private struct NativeBuildSystemFactory: BuildSystemFactory { } } +#if !DISABLE_XCBUILD_SUPPORT private struct XcodeBuildSystemFactory: BuildSystemFactory { let swiftTool: SwiftTool @@ -87,12 +91,19 @@ private struct XcodeBuildSystemFactory: BuildSystemFactory { ) } } +#endif extension SwiftTool { public var defaultBuildSystemProvider: BuildSystemProvider { + #if !DISABLE_XCBUILD_SUPPORT .init(providers: [ .native: NativeBuildSystemFactory(swiftTool: self), .xcode: XcodeBuildSystemFactory(swiftTool: self) ]) + #else + .init(providers: [ + .native: NativeBuildSystemFactory(swiftTool: self), + ]) + #endif } } diff --git a/Sources/CoreCommands/CMakeLists.txt b/Sources/CoreCommands/CMakeLists.txt index 13d446033e1..3d65ad22ce4 100644 --- a/Sources/CoreCommands/CMakeLists.txt +++ b/Sources/CoreCommands/CMakeLists.txt @@ -18,8 +18,11 @@ target_link_libraries(CoreCommands PUBLIC PackageGraph TSCBasic TSCUtility - Workspace - XCBuildSupport) + Workspace) + +target_compile_definitions(CoreCommands + PRIVATE DISABLE_XCBUILD_SUPPORT) + target_link_libraries(CoreCommands PRIVATE DriverSupport $<$>:FoundationXML>) diff --git a/Sources/XCBuildSupport/CMakeLists.txt b/Sources/XCBuildSupport/CMakeLists.txt deleted file mode 100644 index 178e0bc1ba7..00000000000 --- a/Sources/XCBuildSupport/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# 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 - 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 f2c40f4c8a0..6371d1a01d4 100644 --- a/Sources/swift-bootstrap/CMakeLists.txt +++ b/Sources/swift-bootstrap/CMakeLists.txt @@ -16,5 +16,7 @@ target_link_libraries(swift-bootstrap PRIVATE PackageLoading PackageModel TSCBasic - TSCUtility - XCBuildSupport) + TSCUtility) + +target_compile_definitions(swift-bootstrap + PRIVATE DISABLE_XCBUILD_SUPPORT) diff --git a/Sources/swift-bootstrap/main.swift b/Sources/swift-bootstrap/main.swift index b879f9a79bb..02ceae1ca1e 100644 --- a/Sources/swift-bootstrap/main.swift +++ b/Sources/swift-bootstrap/main.swift @@ -20,7 +20,10 @@ import PackageGraph import PackageLoading import PackageModel import SPMBuildCore + +#if !DISABLE_XCBUILD_SUPPORT import XCBuildSupport +#endif import struct TSCBasic.KeyedPair import func TSCBasic.topologicalSort @@ -322,6 +325,7 @@ struct SwiftBootstrapBuildTool: ParsableCommand { observabilityScope: self.observabilityScope ) case .xcode: + #if !DISABLE_XCBUILD_SUPPORT return try XcodeBuildSystem( buildParameters: buildParameters, packageGraphLoader: packageGraphLoader, @@ -330,6 +334,9 @@ struct SwiftBootstrapBuildTool: ParsableCommand { fileSystem: self.fileSystem, observabilityScope: self.observabilityScope ) + #else + fatalError("SwiftPM was built without XCBuild support") + #endif } }