forked from swiftlang/swift-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: initial support for building with CMake
Add support for building with CMake which is required to get the toolchain bootstrapped. This partially addresses swiftlang#7.
- Loading branch information
Showing
28 changed files
with
1,271 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#[[ | ||
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) | ||
|
||
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name SwiftBuild>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ConciseMagicFile>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature DeprecateApplicationMain>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature DisableOutwardActorInference>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ForwardTrailingClosures>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature GlobalConcurrency>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ImplicitOpenExistentials>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ImplicitOpenExistentialsImportObjcForwardDeclarations>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature InferSendableFromCaptures>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature IsolatedDefaultValues>" | ||
# rdar://137809703 | ||
# "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature RegionBasedIsolation>" | ||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>" | ||
"$<$<COMPILE_LANGUAGE:Swift>: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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
$<$<PLATFORM_ID:Windows>:_CRT_SECURE_NO_WARNINGS> | ||
$<$<PLATFORM_ID:Windows>:_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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module SWBCSupport { | ||
header "SWBCSupport.h" | ||
export * | ||
} |
Oops, something went wrong.