-
Notifications
You must be signed in to change notification settings - Fork 97
build: initial support for building with CMake #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+1,296
−1
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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 $<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>) | ||
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name SwiftBuild>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ConciseMagicFile>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature DeprecateApplicationMain>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature DisableOutwardActorInference>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ForwardTrailingClosures>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature GlobalConcurrency>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ImplicitOpenExistentials>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature ImplicitOpenExistentialsImportObjcForwardDeclarations>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_LANGUAGE_VERSION_6}>:SHELL:-enable-upcoming-feature InferSendableFromCaptures>" | ||
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,${SwiftBuild_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) | ||
owenv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
find_package(TSC) | ||
# NOTE: these two are required for LLBuild dependencies | ||
find_package(Threads) | ||
find_package(SQLite3) | ||
|
||
add_subdirectory(Sources) |
This file contains hidden or 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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) | ||
compnerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.