From 97b2233e745a5fa8885356fd5db8d3a46200bc5f Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 3 Feb 2025 12:29:43 -0800 Subject: [PATCH] build: initial support for building with CMake Add support for building with CMake which is required to get the toolchain bootstrapped. This partially addresses #7. --- CMakeLists.txt | 52 +++++ Package.swift | 25 ++- Sources/CMakeLists.txt | 36 +++ Sources/SWBAndroidPlatform/CMakeLists.txt | 39 ++++ Sources/SWBApplePlatform/CMakeLists.txt | 74 ++++++ Sources/SWBBuildService/CMakeLists.txt | 39 ++++ Sources/SWBBuildServiceBundle/CMakeLists.txt | 22 ++ Sources/SWBBuildSystem/CMakeLists.txt | 24 ++ Sources/SWBCAS/CMakeLists.txt | 21 ++ Sources/SWBCLibc/CMakeLists.txt | 14 ++ Sources/SWBCSupport/CMakeLists.txt | 23 ++ Sources/SWBCSupport/module.modulemap | 4 + Sources/SWBCore/CMakeLists.txt | 212 ++++++++++++++++++ Sources/SWBGenericUnixPlatform/CMakeLists.txt | 37 +++ Sources/SWBLLBuild/CMakeLists.txt | 18 ++ Sources/SWBLibc/CMakeLists.txt | 21 ++ Sources/SWBMacro/CMakeLists.txt | 35 +++ Sources/SWBProjectModel/CMakeLists.txt | 22 ++ Sources/SWBProtocol/CMakeLists.txt | 50 +++++ Sources/SWBQNXPlatform/CMakeLists.txt | 39 ++++ Sources/SWBServiceCore/CMakeLists.txt | 20 ++ Sources/SWBTaskConstruction/CMakeLists.txt | 66 ++++++ Sources/SWBTaskExecution/CMakeLists.txt | 82 +++++++ Sources/SWBUniversalPlatform/CMakeLists.txt | 44 ++++ Sources/SWBUtil/CMakeLists.txt | 111 +++++++++ Sources/SWBWebAssemblyPlatform/CMakeLists.txt | 38 ++++ Sources/SWBWindowsPlatform/CMakeLists.txt | 40 ++++ Sources/SwiftBuild/CMakeLists.txt | 69 ++++++ Sources/swbuild/CMakeLists.txt | 20 ++ 29 files changed, 1296 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 Sources/CMakeLists.txt create mode 100644 Sources/SWBAndroidPlatform/CMakeLists.txt create mode 100644 Sources/SWBApplePlatform/CMakeLists.txt create mode 100644 Sources/SWBBuildService/CMakeLists.txt create mode 100644 Sources/SWBBuildServiceBundle/CMakeLists.txt create mode 100644 Sources/SWBBuildSystem/CMakeLists.txt create mode 100644 Sources/SWBCAS/CMakeLists.txt create mode 100644 Sources/SWBCLibc/CMakeLists.txt create mode 100644 Sources/SWBCSupport/CMakeLists.txt create mode 100644 Sources/SWBCSupport/module.modulemap create mode 100644 Sources/SWBCore/CMakeLists.txt create mode 100644 Sources/SWBGenericUnixPlatform/CMakeLists.txt create mode 100644 Sources/SWBLLBuild/CMakeLists.txt create mode 100644 Sources/SWBLibc/CMakeLists.txt create mode 100644 Sources/SWBMacro/CMakeLists.txt create mode 100644 Sources/SWBProjectModel/CMakeLists.txt create mode 100644 Sources/SWBProtocol/CMakeLists.txt create mode 100644 Sources/SWBQNXPlatform/CMakeLists.txt create mode 100644 Sources/SWBServiceCore/CMakeLists.txt create mode 100644 Sources/SWBTaskConstruction/CMakeLists.txt create mode 100644 Sources/SWBTaskExecution/CMakeLists.txt create mode 100644 Sources/SWBUniversalPlatform/CMakeLists.txt create mode 100644 Sources/SWBUtil/CMakeLists.txt create mode 100644 Sources/SWBWebAssemblyPlatform/CMakeLists.txt create mode 100644 Sources/SWBWindowsPlatform/CMakeLists.txt create mode 100644 Sources/SwiftBuild/CMakeLists.txt create mode 100644 Sources/swbuild/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..ce85223a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,52 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +cmake_minimum_required(VERSION 3.26...3.29) +project(SwiftBuild + LANGUAGES C CXX Swift) + +set(CMAKE_C_VISIBILITY hidden) +set(CMAKE_CXX_VISIBILITY hidden) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED YES) +set(CMAKE_CXX_EXTENSIONS NO) +set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) + +option(SwiftBuild_USE_LLBUILD_FRAMEWORK "Use LLBuild Framework" NO) + +set(SwiftBuild_LANGUAGE_VERSION_6 $,6>) +add_compile_options("$<$:SHELL:-package-name SwiftBuild>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ConciseMagicFile>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature DeprecateApplicationMain>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature DisableOutwardActorInference>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ForwardTrailingClosures>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature GlobalConcurrency>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ImplicitOpenExistentials>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ImplicitOpenExistentialsImportObjcForwardDeclarations>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature InferSendableFromCaptures>" + "$<$,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature IsolatedDefaultValues>" + # rdar://137809703 + # "$<$:SHELL:-enable-upcoming-feature RegionBasedIsolation>" + "$<$:SHELL:-enable-upcoming-feature ExistentialAny>" + "$<$:SHELL:-enable-upcoming-feature InternalImportsByDefault>") + +# Prefer the static initialisation for the pluigns. +add_compile_definitions(USE_STATIC_PLUGIN_INITIALIZATION) + +find_package(ArgumentParser) +find_package(LLBuild) +find_package(SwiftDriver) +find_package(SwiftSystem) +find_package(TSC) +# NOTE: these two are required for LLBuild dependencies +find_package(Threads) +find_package(SQLite3) + +add_subdirectory(Sources) diff --git a/Package.swift b/Package.swift index a09cdb14..765b2a53 100644 --- a/Package.swift +++ b/Package.swift @@ -83,18 +83,21 @@ let package = Package( "SwiftBuild", "SWBBuildServiceBundle", // the CLI needs to launch the service bundle ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .executableTarget( name: "SWBBuildServiceBundle", dependencies: [ "SWBBuildService", "SWBBuildSystem", "SWBServiceCore", "SWBUtil", "SWBCore", ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), // Libraries .target( name: "SwiftBuild", dependencies: ["SWBCSupport", "SWBCore", "SWBProtocol", "SWBUtil", "SWBProjectModel"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBBuildService", @@ -104,10 +107,12 @@ let package = Package( "SWBTaskExecution", .product(name: "SystemPackage", package: "swift-system", condition: .when(platforms: [.linux, .android, .windows])), ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBBuildSystem", dependencies: ["SWBCore", "SWBTaskConstruction", "SWBTaskExecution"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBCore", @@ -120,6 +125,7 @@ let package = Package( .product(name: "SwiftDriver", package: "swift-driver"), "SWBLLBuild", ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5), plugins: [ .plugin(name: "SWBSpecificationsPlugin") @@ -134,12 +140,13 @@ let package = Package( swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBCLibc", - exclude: ["README.md"], + exclude: ["CMakeLists.txt", "README.md"], publicHeadersPath: ".", swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBLibc", dependencies: ["SWBCLibc"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBLLBuild", @@ -149,6 +156,7 @@ let package = Package( .product(name: "libllbuild", package: useLocalDependencies ? "llbuild" : "swift-llbuild"), .product(name: "llbuildSwift", package: useLocalDependencies ? "llbuild" : "swift-llbuild"), ]), + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBMacro", @@ -156,26 +164,32 @@ let package = Package( "SWBUtil", .product(name: "SwiftDriver", package: "swift-driver"), ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBProjectModel", dependencies: ["SWBProtocol"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBProtocol", dependencies: ["SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBServiceCore", dependencies: ["SWBProtocol"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBTaskConstruction", dependencies: ["SWBCore", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBTaskExecution", dependencies: ["SWBCore", "SWBUtil", "SWBCAS", "SWBLLBuild", "SWBTaskConstruction"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBUtil", @@ -186,39 +200,48 @@ let package = Package( .product(name: "Crypto", package: "swift-crypto", condition: .when(platforms: [.linux, .android])), .product(name: "SystemPackage", package: "swift-system", condition: .when(platforms: [.linux, .android, .windows])), ], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v5)), .target( name: "SWBCAS", dependencies: ["SWBUtil", "SWBCSupport"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBAndroidPlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBApplePlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil", "SWBTaskConstruction"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBGenericUnixPlatform", dependencies: ["SWBCore", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBQNXPlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBUniversalPlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBWebAssemblyPlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), .target( name: "SWBWindowsPlatform", dependencies: ["SWBCore", "SWBMacro", "SWBUtil"], + exclude: ["CMakeLists.txt"], swiftSettings: swiftSettings(languageMode: .v6)), // Helper targets for SwiftPM diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt new file mode 100644 index 00000000..6c2fd9d4 --- /dev/null +++ b/Sources/CMakeLists.txt @@ -0,0 +1,36 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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_subdirectory(SWBCSupport) +add_subdirectory(SWBCLibc) +add_subdirectory(SWBLibc) +add_subdirectory(SWBUtil) +add_subdirectory(SWBMacro) +add_subdirectory(SWBProtocol) +add_subdirectory(SWBServiceCore) +add_subdirectory(SWBCAS) +add_subdirectory(SWBLLBuild) +add_subdirectory(SWBCore) +add_subdirectory(SWBTaskConstruction) +add_subdirectory(SWBAndroidPlatform) +add_subdirectory(SWBApplePlatform) +add_subdirectory(SWBGenericUnixPlatform) +add_subdirectory(SWBQNXPlatform) +add_subdirectory(SWBUniversalPlatform) +add_subdirectory(SWBWebAssemblyPlatform) +add_subdirectory(SWBWindowsPlatform) +add_subdirectory(SWBTaskExecution) +add_subdirectory(SWBBuildSystem) +add_subdirectory(SWBBuildService) +add_subdirectory(SWBProjectModel) +add_subdirectory(SwiftBuild) + +add_subdirectory(swbuild) +add_subdirectory(SWBBuildServiceBundle) diff --git a/Sources/SWBAndroidPlatform/CMakeLists.txt b/Sources/SWBAndroidPlatform/CMakeLists.txt new file mode 100644 index 00000000..e2f2faae --- /dev/null +++ b/Sources/SWBAndroidPlatform/CMakeLists.txt @@ -0,0 +1,39 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBAndroidPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBAndroidPlatform.resources").path + let buildPath = #"@_SWBAndroidPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBAndroidPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBAndroidPlatform STATIC + AndroidSDK.swift + Plugin.swift) +target_link_libraries(SWBAndroidPlatform PUBLIC + SWBCore + SWBMacro + SWBUtil) +target_sources(SWBAndroidPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBApplePlatform/CMakeLists.txt b/Sources/SWBApplePlatform/CMakeLists.txt new file mode 100644 index 00000000..923d25c7 --- /dev/null +++ b/Sources/SWBApplePlatform/CMakeLists.txt @@ -0,0 +1,74 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBApplePlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBApplePlatform.resources").path + let buildPath = #"@_SWBApplePlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBApplePlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBApplePlatform STATIC + Specs/AssetCatalogCompiler.swift + Specs/CopyTiffFile.swift + Specs/CoreDataCompiler.swift + Specs/CoreMLCompiler.swift + Specs/DittoTool.swift + Specs/ExtensionPointsCompiler.swift + Specs/IIGCompiler.swift + Specs/InstrumentsPackageBuilderSpec.swift + Specs/IntentsCompiler.swift + Specs/InterfaceBuilderCompiler.swift + Specs/InterfaceBuilderShared.swift + Specs/MetalCompiler.swift + Specs/MiGCompiler.swift + Specs/OpenCLCompiler.swift + Specs/RealityAssetsCompilerSpec.swift + Specs/ReferenceObjectCompiler.swift + Specs/ResMergerLinkerSpec.swift + Specs/SceneKitToolSpec.swift + Specs/StoryboardLinker.swift + Specs/XCStringsCompiler.swift + ActoolInputFileGroupingStrategy.swift + AssetCatalogCompilerOutputParser.swift + CMakeLists.txt + DevelopmentAssetsTaskProducer.swift + ImageScaleFactorsInputFileGroupingStrategy.swift + InterfaceBuilderCompilerOutputParser.swift + LocalizationInputFileGroupingStrategy.swift + MacCatalystInfoExtension.swift + Plugin.swift + RealityAssetsTaskProducer.swift + StringCatalogCompilerOutputParser.swift + StubBinaryTaskProducer.swift + XCStringsInputFileGroupingStrategy.swift) +set_target_properties(SWBApplePlatform PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBApplePlatform PUBLIC + SWBCore + SWBMacro + SWBUtil + SWBProtocol + SWBTaskConstruction) +target_sources(SWBApplePlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBBuildService/CMakeLists.txt b/Sources/SWBBuildService/CMakeLists.txt new file mode 100644 index 00000000..7609ec2e --- /dev/null +++ b/Sources/SWBBuildService/CMakeLists.txt @@ -0,0 +1,39 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBBuildService + BuildDependencyInfo.swift + BuildOperationMessages.swift + BuildService.swift + BuildServiceEntryPoint.swift + ClientExchangeDelegate.swift + DependencyGraphMessages.swift + DocumentationInfo.swift + LocalizationInfo.swift + Messages.swift + PlanningOperation.swift + PreviewInfo.swift + ProjectDescriptor.swift + Session.swift + Tools.swift) +set_target_properties(SWBBuildService PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBBuildService PUBLIC + SWBBuildSystem + SWBServiceCore + SWBTaskExecution + SWBAndroidPlatform + SWBApplePlatform + SWBGenericUnixPlatform + SWBQNXPlatform + SWBUniversalPlatform + SWBWebAssemblyPlatform + SWBWindowsPlatform + SwiftSystem::SystemPackage) diff --git a/Sources/SWBBuildServiceBundle/CMakeLists.txt b/Sources/SWBBuildServiceBundle/CMakeLists.txt new file mode 100644 index 00000000..dcae6b91 --- /dev/null +++ b/Sources/SWBBuildServiceBundle/CMakeLists.txt @@ -0,0 +1,22 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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_executable(SWBBuildServiceBundle + main.swift) +set_target_properties(SWBBuildServiceBundle PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBBuildServiceBundle PRIVATE + SWBBuildService + SWBBuildSystem + SWBServiceCore + SWBUtil + SWBCore) + +install(TARGETS SWBBuildServiceBundle) diff --git a/Sources/SWBBuildSystem/CMakeLists.txt b/Sources/SWBBuildSystem/CMakeLists.txt new file mode 100644 index 00000000..7bef4f58 --- /dev/null +++ b/Sources/SWBBuildSystem/CMakeLists.txt @@ -0,0 +1,24 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBBuildSystem + BuildManager.swift + BuildOperation.swift + BuildOperationExtension.swift + BuildSystemCache.swift + CleanOperation.swift + DependencyCycleFormatter.swift + SandboxViolations.swift) +set_target_properties(SWBBuildSystem PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBBuildSystem PUBLIC + SWBCore + SWBTaskConstruction + SWBTaskExecution) diff --git a/Sources/SWBCAS/CMakeLists.txt b/Sources/SWBCAS/CMakeLists.txt new file mode 100644 index 00000000..b35d440e --- /dev/null +++ b/Sources/SWBCAS/CMakeLists.txt @@ -0,0 +1,21 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBCAS + CASFSNode.swift + CASProtocol.swift + Errors.swift + plugin_api_t.swift + ToolchainCASPlugin.swift) +set_target_properties(SWBCAS PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBCAS PUBLIC + SWBUtil + SWBCSupport) diff --git a/Sources/SWBCLibc/CMakeLists.txt b/Sources/SWBCLibc/CMakeLists.txt new file mode 100644 index 00000000..a5d690b0 --- /dev/null +++ b/Sources/SWBCLibc/CMakeLists.txt @@ -0,0 +1,14 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBCLibc + libc.c) +target_include_directories(SWBCLibc INTERFACE + include) diff --git a/Sources/SWBCSupport/CMakeLists.txt b/Sources/SWBCSupport/CMakeLists.txt new file mode 100644 index 00000000..be685aeb --- /dev/null +++ b/Sources/SWBCSupport/CMakeLists.txt @@ -0,0 +1,23 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBCSupport STATIC + CLibclang.cpp + CLibRemarksHelper.c) +target_compile_definitions(SWBCSupport PRIVATE + $<$:_CRT_SECURE_NO_WARNINGS> + $<$:_CRT_NONSTDC_NO_WARNINGS>) +target_compile_options(SWBCSupport PRIVATE + -fblocks) +target_include_directories(SWBCSupport PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}) +# TODO(compnerd) wire this up with `find_package` +target_link_libraries(SWBCSupport PRIVATE + BlocksRuntime) diff --git a/Sources/SWBCSupport/module.modulemap b/Sources/SWBCSupport/module.modulemap new file mode 100644 index 00000000..7aef298c --- /dev/null +++ b/Sources/SWBCSupport/module.modulemap @@ -0,0 +1,4 @@ +module SWBCSupport { + header "SWBCSupport.h" + export * +} diff --git a/Sources/SWBCore/CMakeLists.txt b/Sources/SWBCore/CMakeLists.txt new file mode 100644 index 00000000..5e4c8ec0 --- /dev/null +++ b/Sources/SWBCore/CMakeLists.txt @@ -0,0 +1,212 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBCore_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBCore.resources").path + let buildPath = #"@_SWBCore_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBCore.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBCore + ActivityReporting.swift + Apple/DeviceFamily.swift + Apple/InterfaceBuilderShared.swift + BuildFileFilteringContext.swift + BuildFileResolution.swift + BuildParameters.swift + BuildRequest.swift + BuildRequestContext.swift + BuildRuleAction.swift + BuildRuleCondition.swift + BuildRuleSet.swift + CapturedBuildInfo.swift + ClangModuleVerifier/ModuleVerifierFilenameMap.swift + ClangModuleVerifier/ModuleVerifierFramework.swift + ClangModuleVerifier/ModuleVerifierHeader.swift + ClangModuleVerifier/ModuleVerifierLanguage.swift + ClangModuleVerifier/ModuleVerifierModuleMap.swift + ClangModuleVerifier/ModuleVerifierModuleMapFileVerifier.swift + ClangModuleVerifier/ModuleVerifierTarget.swift + ClangModuleVerifierOutputParser.swift + ClangSerializedDiagnostics.swift + CommandLineArgument.swift + ConfiguredTarget.swift + Core.swift + CustomTaskTypeDescription.swift + DependencyInfoEditPayload.swift + DependencyResolution.swift + DiagnosticSupport.swift + EnvironmentBindings.swift + ExecutableTask.swift + Extensions/DiagnosticToolingExtension.swift + Extensions/EnvironmentExtension.swift + Extensions/FeatureAvailabilityExtension.swift + Extensions/InputFileGroupingStrategyExtension.swift + Extensions/PlatformInfoExtension.swift + Extensions/SDKRegistryExtension.swift + Extensions/SDKVariantInfoExtension.swift + Extensions/SettingsBuilderExtension.swift + Extensions/SpecificationsExtension.swift + Extensions/ToolchainRegistryExtension.swift + FileSystemSignatureBasedCache.swift + FileToBuild.swift + KnownFolders.swift + LibclangVendored/ArrayExtensions.swift + LibclangVendored/CStringArray.swift + LibclangVendored/Libclang.swift + LibSwiftDriver/LibSwiftDriver.swift + LibSwiftDriver/PlannedBuild.swift + LinkageDependencyResolver.swift + MacCatalystInfo.swift + MacroConfigFileLoader.swift + MacroEvaluationExtensions.swift + MacroExpressionSourceExtensions.swift + MissingFrameworkDiagnostics.swift + OnDemandResources.swift + OptimizationRemarks.swift + PlannedNode.swift + PlannedTask.swift + PlannedTaskAction.swift + PlatformEnvironment.swift + PlatformFiltering.swift + PlatformRegistry.swift + Process.swift + ProcessExecutionCache.swift + ProductTypeIdentifier.swift + ProjectModel/BuildConfiguration.swift + ProjectModel/BuildFile.swift + ProjectModel/BuildPhase.swift + ProjectModel/BuildRule.swift + ProjectModel/DependencyInfoFormat.swift + ProjectModel/FilePathResolver.swift + ProjectModel/FileTextEncoding.swift + ProjectModel/ImpartedBuildProperties.swift + ProjectModel/PIFLoader.swift + ProjectModel/PlatformFilter.swift + ProjectModel/Project.swift + ProjectModel/ProjectModelItem.swift + ProjectModel/Reference.swift + ProjectModel/ReferenceLookupContext.swift + ProjectModel/Target.swift + ProjectModel/Workspace.swift + ProjectModel/WorkspaceHeaderIndex.swift + ProvisionalTask.swift + Provisioning.swift + ProvisioningTaskInputs.swift + SDKRegistry.swift + Settings/BuildRuleFile.swift + Settings/BuiltinMacros.swift + Settings/CASOptions.swift + Settings/RecursiveSearchPathResolver.swift + Settings/Settings.swift + Settings/StackedSearchPaths.swift + ShellScript.swift + SigningSupport.swift + SwiftSDK.swift + Specs/CommandLineToolSpec.swift + Specs/CompilerSpec.swift + Specs/CoreBuildSystem.xcspec + Specs/ExternalBuildSystem.xcspec + Specs/FileTypes.swift + Specs/LinkerSpec.swift + Specs/NativeBuildSystem.xcspec + Specs/ProductTypes.swift + Specs/PropertyDomainSpec.swift + Specs/RegisterSpecs.swift + Specs/SpecParser.swift + Specs/SpecRegistry.swift + Specs/Specs.swift + Specs/Tools/AppIntentsMetadataCompiler.swift + Specs/Tools/AppIntentsSSUTrainingCompiler.swift + Specs/Tools/AppShortcutStringsMetadataCompiler.swift + Specs/Tools/CCompiler.swift + Specs/Tools/ClangModuleVerifierInputGenerator.swift + Specs/Tools/ClangStatCache.swift + Specs/Tools/CodeSign.swift + Specs/Tools/ConcatenateTool.swift + Specs/Tools/ConstructStubExecutorFileListTool.swift + Specs/Tools/CopyTool.swift + Specs/Tools/CreateAssetPackManifestTool.swift + Specs/Tools/CreateBuildDirectory.swift + Specs/Tools/DocumentationCompiler.swift + Specs/Tools/DsymutilTool.swift + Specs/Tools/Gate.swift + Specs/Tools/GCCCompatibleCompilerSupport.swift + Specs/Tools/GenerateAppPlaygroundAssetCatalog.swift + Specs/Tools/InfoPlistTool.swift + Specs/Tools/LaunchServicesRegisterTool.swift + Specs/Tools/LinkerTools.swift + Specs/Tools/Lipo.swift + Specs/Tools/MasterObjectLink.swift + Specs/Tools/MergeInfoPlist.swift + Specs/Tools/MkdirTool.swift + Specs/Tools/ModulesVerifierTool.swift + Specs/Tools/PLUtilTool.swift + Specs/Tools/ProcessSDKImports.swift + Specs/Tools/ProcessXCFrameworkLibrary.swift + Specs/Tools/ProductPackaging.swift + Specs/Tools/RegisterExecutionPolicyException.swift + Specs/Tools/SetAttributes.swift + Specs/Tools/ShellScriptTool.swift + Specs/Tools/SignatureCollection.swift + Specs/Tools/StripTool.swift + Specs/Tools/SwiftABICheckerTool.swift + Specs/Tools/SwiftABIGenerationTool.swift + Specs/Tools/SwiftCompiler.swift + Specs/Tools/SwiftHeaderTool.swift + Specs/Tools/SwiftStdLibTool.swift + Specs/Tools/SwiftSymbolExtractor.swift + Specs/Tools/SymlinkTool.swift + Specs/Tools/TAPISymbolExtractor.swift + Specs/Tools/TAPITools.swift + Specs/Tools/TiffUtilTool.swift + Specs/Tools/TouchTool.swift + Specs/Tools/UnifdefTool.swift + Specs/Tools/ValidateDevelopmentAssets.swift + Specs/Tools/ValidateEmbeddedBinaryTool.swift + Specs/Tools/ValidateProductTool.swift + Specs/Tools/WriteFile.swift + SWBFeatureFlag.swift + TargetDependencyResolver.swift + TargetPlatformDiagnostics.swift + TaskGeneration.swift + TaskResult.swift + ToolchainRegistry.swift + ToolInfo/ClangToolInfo.swift + Tuning.swift + WorkspaceContext.swift + WorkspaceSettingsCache.swift + XCFramework.swift) +set_target_properties(SWBCore PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBCore PUBLIC + SWBMacro + SWBProtocol + SWBServiceCore + SWBUtil + SWBCAS + SWBLLBuild + SwiftDriver) +target_sources(SWBCore PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBGenericUnixPlatform/CMakeLists.txt b/Sources/SWBGenericUnixPlatform/CMakeLists.txt new file mode 100644 index 00000000..8e5213b8 --- /dev/null +++ b/Sources/SWBGenericUnixPlatform/CMakeLists.txt @@ -0,0 +1,37 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBGenericUnixPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBGenericUnixPlatform.resources").path + let buildPath = #"@_SWBGenericUnixPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBGenericUnixPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBGenericUnixPlatform STATIC + Plugin.swift) +target_link_libraries(SWBGenericUnixPlatform PUBLIC + SWBCore + SWBUtil) +target_sources(SWBGenericUnixPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBLLBuild/CMakeLists.txt b/Sources/SWBLLBuild/CMakeLists.txt new file mode 100644 index 00000000..3f36654b --- /dev/null +++ b/Sources/SWBLLBuild/CMakeLists.txt @@ -0,0 +1,18 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBLLBuild + LowLevelBuildSystem.swift) +set_target_properties(SWBLLBuild PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBLLBuild PUBLIC + SWBUtil + $<$>:libllbuild> + $<$>:llbuildSwift>) diff --git a/Sources/SWBLibc/CMakeLists.txt b/Sources/SWBLibc/CMakeLists.txt new file mode 100644 index 00000000..8e5daf61 --- /dev/null +++ b/Sources/SWBLibc/CMakeLists.txt @@ -0,0 +1,21 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBLibc + libc.swift) +set_target_properties(SWBLibc PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBLibc PUBLIC + SWBCLibc) + +# FIXME: why is this needed? We should be wiring up the Swift_MODULE_DIRECTORY +# without this explicit configuration. +target_include_directories(SWBLibc PUBLIC + ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Sources/SWBMacro/CMakeLists.txt b/Sources/SWBMacro/CMakeLists.txt new file mode 100644 index 00000000..4abeddf1 --- /dev/null +++ b/Sources/SWBMacro/CMakeLists.txt @@ -0,0 +1,35 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBMacro + MacroCondition.swift + MacroConditionExpression.swift + MacroConditionParameter.swift + MacroConditionSet.swift + MacroConfigFileDiagnostic.swift + MacroConfigFileParser.swift + MacroDeclaration.swift + MacroEvaluationProgram.swift + MacroEvaluationScope.swift + MacroExpression.swift + MacroExpressionDiagnostic.swift + MacroExpressionParsing.swift + MacroNamespace.swift + MacroType.swift + MacroValueAssignmentTable.swift) +set_target_properties(SWBMacro PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBMacro PUBLIC + SWBUtil + SwiftDriver + TSCBasic) + +target_include_directories(SWBMacro PUBLIC + ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Sources/SWBProjectModel/CMakeLists.txt b/Sources/SWBProjectModel/CMakeLists.txt new file mode 100644 index 00000000..3a98c919 --- /dev/null +++ b/Sources/SWBProjectModel/CMakeLists.txt @@ -0,0 +1,22 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBProjectModel + IDE/IDEPIFGenerating.swift + IDE/IDEPIFGUID.swift + IDE/IDEPIFObject.swift + IDE/IDEPIFObjectInfo.swift + IDE/IDEPIFSerializer.swift + IDE/IDESwiftPackageExtensions.swift + PIFGenerationModel.swift) +set_target_properties(SWBProjectModel PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBProjectModel PUBLIC + SWBProtocol) diff --git a/Sources/SWBProtocol/CMakeLists.txt b/Sources/SWBProtocol/CMakeLists.txt new file mode 100644 index 00000000..d00c636b --- /dev/null +++ b/Sources/SWBProtocol/CMakeLists.txt @@ -0,0 +1,50 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBProtocol + AsyncSequence.swift + BuildAction.swift + BuildOperationMessages.swift + BuildSettingsInfoMessageTypes.swift + ClientExchangeMessages.swift + DependencyClosureMessages.swift + DependencyGraphMessages.swift + DocumentationMessages.swift + IndexingMessages.swift + LocalizationMessages.swift + MacroEvaluationMessages.swift + Message.swift + MessageSupport.swift + PIFKeyConstants.swift + PlanningOperationMessages.swift + PreviewMessages.swift + ProjectDescriptorMessages.swift + ProjectDescriptorTypes.swift + ProjectModel/BuildConfiguration.swift + ProjectModel/BuildFile.swift + ProjectModel/BuildPhase.swift + ProjectModel/BuildRule.swift + ProjectModel/CustomTask.swift + ProjectModel/DependencyInfo.swift + ProjectModel/ImpartedBuildProperties.swift + ProjectModel/MacroExpressionSource.swift + ProjectModel/PIFObject.swift + ProjectModel/PlatformFilter.swift + ProjectModel/Project.swift + ProjectModel/ProvisioningSourceData.swift + ProjectModel/Reference.swift + ProjectModel/SourceTree.swift + ProjectModel/Target.swift + ProjectModel/TargetDependency.swift + ProjectModel/Workspace.swift) +set_target_properties(SWBProtocol PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBProtocol PUBLIC + SWBUtil) diff --git a/Sources/SWBQNXPlatform/CMakeLists.txt b/Sources/SWBQNXPlatform/CMakeLists.txt new file mode 100644 index 00000000..b458f8ce --- /dev/null +++ b/Sources/SWBQNXPlatform/CMakeLists.txt @@ -0,0 +1,39 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBQNXPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBQNXPlatform.resources").path + let buildPath = #"@_SWBQNXPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBQNXPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBQNXPlatform STATIC + Plugin.swift + QNXSDP.swift) +target_link_libraries(SWBQNXPlatform PUBLIC + SWBCore + SWBMacro + SWBUtil) +target_sources(SWBQNXPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBServiceCore/CMakeLists.txt b/Sources/SWBServiceCore/CMakeLists.txt new file mode 100644 index 00000000..673eec1e --- /dev/null +++ b/Sources/SWBServiceCore/CMakeLists.txt @@ -0,0 +1,20 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBServiceCore + Request.swift + Service.swift + ServiceEntryPoint.swift + ServiceExtensionPoint.swift + ServiceHostConnection.swift) +set_target_properties(SWBServiceCore PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_link_libraries(SWBServiceCore PUBLIC + SWBProtocol) diff --git a/Sources/SWBTaskConstruction/CMakeLists.txt b/Sources/SWBTaskConstruction/CMakeLists.txt new file mode 100644 index 00000000..f4227f1f --- /dev/null +++ b/Sources/SWBTaskConstruction/CMakeLists.txt @@ -0,0 +1,66 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBTaskConstruction + BuildDirectoryContext.swift + DiagnosticSupport.swift + ProductPlanning/BuildPlan.swift + ProductPlanning/BuildPlanDumping.swift + ProductPlanning/ProductPlan.swift + ProductPlanning/ProductPlanner.swift + StaleFileRemovalContext.swift + TaskPlanningDelegate.swift + TaskProducers/BuildPhaseTaskProducers/AppleScriptTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/BuildRuleTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/CopyFilesTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/FilesBasedBuildPhaseTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/HeadersTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/ResourcesTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/RezTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/ShellBasedTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/ShellScriptTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift + TaskProducers/BuildPhaseTaskProducers/SwiftPackageCopyFilesTaskProducer.swift + TaskProducers/OtherTaskProducers/AppIntentsMetadataTaskProducer.swift + TaskProducers/OtherTaskProducers/CopySwiftPackageResourcesTaskProducer.swift + TaskProducers/OtherTaskProducers/CustomTaskProducer.swift + TaskProducers/OtherTaskProducers/DevelopmentAssetsTaskProducer.swift + TaskProducers/OtherTaskProducers/DocumentationTaskProducer.swift + TaskProducers/OtherTaskProducers/ExternalTargetTaskProducer.swift + TaskProducers/OtherTaskProducers/GenerateAppPlaygroundAssetCatalogTaskProducer.swift + TaskProducers/OtherTaskProducers/GeneratedFilesTaskProducer.swift + TaskProducers/OtherTaskProducers/HeadermapTaskProducer.swift + TaskProducers/OtherTaskProducers/InfoPlistTaskProducer.swift + TaskProducers/OtherTaskProducers/ModuleMapTaskProducer.swift + TaskProducers/OtherTaskProducers/ModuleVerifierTaskProducer.swift + TaskProducers/OtherTaskProducers/ProductPostprocessingTaskProducer.swift + TaskProducers/OtherTaskProducers/ProductStructureTaskProducer.swift + TaskProducers/OtherTaskProducers/SanitizerTaskProducer.swift + TaskProducers/OtherTaskProducers/SDKStatCacheTaskProducer.swift + TaskProducers/OtherTaskProducers/SwiftFrameworkABICheckerTaskProducer.swift + TaskProducers/OtherTaskProducers/SwiftStandardLibrariesTaskProducer.swift + TaskProducers/OtherTaskProducers/TAPISymbolExtractorTaskProducer.swift + TaskProducers/OtherTaskProducers/TargetOrderTaskProducer.swift + TaskProducers/OtherTaskProducers/XCTestProductTypeTaskProducer.swift + TaskProducers/StandardTaskProducer.swift + TaskProducers/TaskProducer.swift + TaskProducers/TaskProducerExtensionPoint.swift + TaskProducers/WorkspaceTaskProducers/CreateBuildDirectoryTaskProducer.swift + TaskProducers/WorkspaceTaskProducers/HeadermapVFSTaskProducer.swift + TaskProducers/WorkspaceTaskProducers/IndexBuildVFSDirectoryRemapTaskProducer.swift + TaskProducers/WorkspaceTaskProducers/PCHModuleMapTaskProducer.swift + TaskProducers/WorkspaceTaskProducers/XCFrameworkTaskProducer.swift + TaskProducerSandboxing.swift + XCFrameworkContext.swift) +set_target_properties(SWBTaskConstruction PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBTaskConstruction PUBLIC + SWBCore + SWBUtil) diff --git a/Sources/SWBTaskExecution/CMakeLists.txt b/Sources/SWBTaskExecution/CMakeLists.txt new file mode 100644 index 00000000..9bf05c60 --- /dev/null +++ b/Sources/SWBTaskExecution/CMakeLists.txt @@ -0,0 +1,82 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBTaskExecution + BuildDescription.swift + BuildDescriptionManager.swift + BuildDescriptionSignature.swift + DynamicTaskSpecs/ClangCachingKeyQueryDynamicTaskSpec.swift + DynamicTaskSpecs/ClangCachingMaterializeKeyDynamicTaskSpec.swift + DynamicTaskSpecs/ClangCachingOutputMaterializerDynamicTaskSpec.swift + DynamicTaskSpecs/ClangCachingTaskCacheKey.swift + DynamicTaskSpecs/ClangModuleDependencyGraph.swift + DynamicTaskSpecs/CompilationCachingDataPruner.swift + DynamicTaskSpecs/CompilationCachingUploader.swift + DynamicTaskSpecs/DynamicTaskOperationContext.swift + DynamicTaskSpecs/DynamicTaskSpecRegistry.swift + DynamicTaskSpecs/PrecompileClangModuleDynamicTaskSpec.swift + DynamicTaskSpecs/SwiftCachingDynamicTaskSpec.swift + DynamicTaskSpecs/SwiftCachingTaskKeys.swift + DynamicTaskSpecs/SwiftDriverJobDynamicTaskSpec.swift + DynamicTaskSpecs/SwiftDriverPlanningDynamicTaskSpec.swift + ProjectPlanner.swift + Task.swift + TaskActions/AuxiliaryFileTaskAction.swift + TaskActions/ClangCachingKeyQueryTaskAction.swift + TaskActions/ClangCachingMaterializeKeyTaskAction.swift + TaskActions/ClangCachingOutputMaterializerTaskAction.swift + TaskActions/ClangCompileTaskAction.swift + TaskActions/ClangModuleVerifierInputGeneratorTaskAction.swift + TaskActions/ClangScanTaskAction.swift + TaskActions/CodeSignTaskAction.swift + TaskActions/ConcatenateTaskAction.swift + TaskActions/ConstructStubExecutorInputFileListTaskAction.swift + TaskActions/CopyPlistTaskAction.swift + TaskActions/CopyStringsFileTaskAction.swift + TaskActions/CopyTiffTaskAction.swift + TaskActions/CreateBuildDirectoryTaskAction.swift + TaskActions/DeferredExecutionTaskAction.swift + TaskActions/EmbedSwiftStdLibTaskAction.swift + TaskActions/FileCopyTaskAction.swift + TaskActions/GenericCachingTaskAction.swift + TaskActions/InfoPlistProcessorTaskAction.swift + TaskActions/LinkAssetCatalogTaskAction.swift + TaskActions/LSRegisterURLTaskAction.swift + TaskActions/MergeInfoPlistTaskAction.swift + TaskActions/ODRAssetPackManifestTaskAction.swift + TaskActions/PrecompileClangModuleTaskAction.swift + TaskActions/ProcessProductEntitlementsTaskAction.swift + TaskActions/ProcessProductProvisioningProfileTaskAction.swift + TaskActions/ProcessSDKImportsTaskAction.swift + TaskActions/ProcessXCFrameworkTaskAction.swift + TaskActions/RegisterExecutionPolicyExceptionTaskAction.swift + TaskActions/SignatureCollectionTaskAction.swift + TaskActions/SwiftCachingKeyQueryTaskAction.swift + TaskActions/SwiftCachingMaterializeKeyTaskAction.swift + TaskActions/SwiftCachingOutputMaterializerTaskAction.swift + TaskActions/SwiftCompilationTaskAction.swift + TaskActions/SwiftDriverCompilationRequirementTaskAction.swift + TaskActions/SwiftDriverJobSchedulingTaskAction.swift + TaskActions/SwiftDriverJobTaskAction.swift + TaskActions/SwiftDriverTaskAction.swift + TaskActions/SwiftHeaderToolTaskAction.swift + TaskActions/TaskAction.swift + TaskActions/ValidateDevelopmentAssetsTaskAction.swift + TaskActions/ValidateProductTaskAction.swift + TaskResult.swift + TaskStore.swift) +set_target_properties(SWBTaskExecution PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBTaskExecution PUBLIC + SWBCAS + SWBCore + SWBLLBuild + SWBTaskConstruction + SWBUtil) diff --git a/Sources/SWBUniversalPlatform/CMakeLists.txt b/Sources/SWBUniversalPlatform/CMakeLists.txt new file mode 100644 index 00000000..89f461f0 --- /dev/null +++ b/Sources/SWBUniversalPlatform/CMakeLists.txt @@ -0,0 +1,44 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBUniversalPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBUniversalPlatform.resources").path + let buildPath = #"@_SWBUniversalPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBUniversalPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBUniversalPlatform STATIC + Specs/CopyPlistFile.swift + Specs/CopyStringsFile.swift + Specs/CppTool.swift + Specs/DiffTool.swift + Specs/LexCompiler.swift + Specs/YaccCompiler.swift + Plugin.swift) +target_link_libraries(SWBUniversalPlatform PUBLIC + SWBCore + SWBMacro + SWBUtil) +target_sources(SWBUniversalPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBUtil/CMakeLists.txt b/Sources/SWBUtil/CMakeLists.txt new file mode 100644 index 00000000..e25ff5b3 --- /dev/null +++ b/Sources/SWBUtil/CMakeLists.txt @@ -0,0 +1,111 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SWBUtil + Architecture.swift + ArgumentSplitting.swift + Array.swift + AsyncCache.swift + AsyncFlatteningSequence.swift + AsyncIteratorProtocol.swift + AsyncLock.swift + AsyncOperationQueue.swift + AsyncSingleValueCache.swift + AsyncStreamController.swift + ByteString.swift + Cache.swift + Collection.swift + CountedSet.swift + CSV.swift + Debugger.swift + DependencyInfo.swift + DiagnosticsEngine.swift + Dictionary.swift + Diff.swift + Dispatch+Async.swift + Duration.swift + ElapsedTimer.swift + EmptyState.swift + Environment.swift + Error.swift + FileHandle+Async.swift + FilesSignature.swift + fnmatch.swift + FSProxy.swift + GraphAlgorithms.swift + HashContext.swift + Headermap.swift + HeavyCache.swift + Int.swift + InterningArena.swift + IO.swift + JSONEncoder.swift + KeyValueStorage.swift + LazyCache.swift + Library.swift + LineReader.swift + Lock.swift + MachO.swift + Math.swift + Misc+Async.swift + Misc.swift + MsgPack.swift + MsgPackSerialization.swift + NamedTemporaryDirectory.swift + Optional.swift + OrderedDictionary.swift + OrderedSet.swift + OSLog.swift + OutputByteStream.swift + Pair.swift + Path.swift + PbxCp.swift + PluginManager.swift + PluginManagerCommon.swift + POSIX.swift + Process+Async.swift + Process.swift + ProcessInfo.swift + Promise.swift + PropertyList.swift + Queue.swift + RateLimiter.swift + Ref.swift + RegEx.swift + Registry.swift + ResponseFiles.swift + Result.swift + ScopedKeepAliveCache.swift + Serialization.swift + Signatures.swift + Static.swift + Statistics.swift + String.swift + SWBDispatch.swift + TAPIFileList.swift + TBDFile.swift + UniqueSerialization.swift + UnsafeSendableDelayedInitializationWrapper.swift + URL.swift + UserDefaults.swift + Version.swift + VFS.swift + WaitCondition.swift + WeakRef.swift + XCBuildDataArchive.swift + Xcode.swift) +set_target_properties(SWBUtil PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SWBUtil PUBLIC + SWBCSupport + SWBLibc + ArgumentParser + $<$>:Crypto::Crypto> + SwiftSystem::SystemPackage) diff --git a/Sources/SWBWebAssemblyPlatform/CMakeLists.txt b/Sources/SWBWebAssemblyPlatform/CMakeLists.txt new file mode 100644 index 00000000..8953a5aa --- /dev/null +++ b/Sources/SWBWebAssemblyPlatform/CMakeLists.txt @@ -0,0 +1,38 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBWebAssemblyPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBWebAssemblyPlatform.resources").path + let buildPath = #"@_SWBWebAssemblyPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBWebAssemblyPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBWebAssemblyPlatform STATIC + Plugin.swift) +target_link_libraries(SWBWebAssemblyPlatform PUBLIC + SWBCore + SWBMacro + SWBUtil) +target_sources(SWBWebAssemblyPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SWBWindowsPlatform/CMakeLists.txt b/Sources/SWBWindowsPlatform/CMakeLists.txt new file mode 100644 index 00000000..79e016d4 --- /dev/null +++ b/Sources/SWBWindowsPlatform/CMakeLists.txt @@ -0,0 +1,40 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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 +]] + +file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" + _SWBWindowsPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR) +file(CONFIGURE + OUTPUT resource_bundle_accessor.swift + CONTENT [[ + import Foundation + extension Foundation.Bundle { + static let module: Bundle = { + let mainPath = Bundle.main.bundleURL.appendingPathComponent("SwiftBuild_SWBWindowsPlatform.resources").path + let buildPath = #"@_SWBWindowsPlatform_NATIVE_CMAKE_CURRENT_BINARY_DIR@\SwiftBuild_SWBWindowsPlatform.resources"# + let preferredBundle = Bundle(path: mainPath) + guard let bundle = preferredBundle ?? Bundle(path: buildPath) else { + Swift.fatalError("could not load resource bundle: from \(mainPath) or \(buildPath)") + } + return bundle + }() + } + ]] + ESCAPE_QUOTES @ONLY NEWLINE_STYLE LF) + +add_library(SWBWindowsPlatform STATIC + KnownFolders.swift + Plugin.swift + VSInstallation.swift) +target_link_libraries(SWBWindowsPlatform PUBLIC + SWBCore + SWBMacro + SWBUtil) +target_sources(SWBWindowsPlatform PRIVATE + "${CMAKE_CURRENT_BINARY_DIR}/resource_bundle_accessor.swift") diff --git a/Sources/SwiftBuild/CMakeLists.txt b/Sources/SwiftBuild/CMakeLists.txt new file mode 100644 index 00000000..2ccf3232 --- /dev/null +++ b/Sources/SwiftBuild/CMakeLists.txt @@ -0,0 +1,69 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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(SwiftBuild + CompatibilityShims.swift + ConsoleCommands/SWBServiceConsoleBuildCommand.swift + ConsoleCommands/SWBServiceConsoleBuildCommandProtocol.swift + ConsoleCommands/SWBServiceConsoleCreateXCFrameworkCommand.swift + ConsoleCommands/SWBServiceConsoleGeneralCommands.swift + ConsoleCommands/SWBServiceConsoleSessionCommands.swift + ConsoleCommands/SWBServiceConsoleXcodeCommands.swift + ProjectModel/BuildConfig.swift + ProjectModel/BuildFile.swift + ProjectModel/BuildPhases.swift + ProjectModel/BuildRule.swift + ProjectModel/BuildSettings.swift + ProjectModel/CustomTask.swift + ProjectModel/ImpartedBuildProperties.swift + ProjectModel/PlatformFilter.swift + ProjectModel/Project.swift + ProjectModel/ProjectModel.swift + ProjectModel/References.swift + ProjectModel/SandboxingOverride.swift + ProjectModel/TargetDependency.swift + ProjectModel/Targets.swift + SWBBuildAction.swift + SWBBuildOperation.swift + SWBBuildOperationBacktraceFrame.swift + SWBBuildParameters.swift + SWBBuildRequest.swift + SWBBuildService.swift + SWBBuildServiceConnection.swift + SWBBuildServiceConsole.swift + SWBBuildServiceSession.swift + SWBChannel.swift + SWBClientExchangeSupport.swift + SWBDocumentationSupport.swift + SWBIndexingSupport.swift + SWBLocalizationSupport.swift + SWBMacroEvaluation.swift + SWBMacroEvaluationScope.swift + SWBPreviewSupport.swift + SWBProductPlannerSupport.swift + SWBPropertyList.swift + SWBProvisioningTaskInputs.swift + SWBSystemInfo.swift + SWBTargetGUID.swift + SWBTerminal.swift + SWBuildMessage+Protocol.swift + SWBUserInfo.swift + SWBWorkspaceInfo.swift + SwiftBuild.swift + SwiftBuildVersion.swift + TerminalAttributes.swift) +set_target_properties(SwiftBuild PROPERTIES + Swift_LANGUAGE_VERSION 5) +target_link_libraries(SwiftBuild PUBLIC + SWBCSupport + SWBCore + SWBProtocol + SWBUtil + SWBProjectModel) diff --git a/Sources/swbuild/CMakeLists.txt b/Sources/swbuild/CMakeLists.txt new file mode 100644 index 00000000..04fb8b7c --- /dev/null +++ b/Sources/swbuild/CMakeLists.txt @@ -0,0 +1,20 @@ +#[[ +This source file is part of the Swift open source project + +Copyright (c) 2014 - 2025 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_executable(swbuild + SWBuildMain.swift) +set_target_properties(swbuild PROPERTIES + Swift_LANGUAGE_VERSION 6) +target_compile_options(swbuild PRIVATE + -parse-as-library) +target_link_libraries(swbuild PRIVATE + SwiftBuild) + +install(TARGETS swbuild)