Skip to content

Commit aa8308e

Browse files
committed
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.
1 parent ce1349c commit aa8308e

File tree

21 files changed

+918
-0
lines changed

21 files changed

+918
-0
lines changed

CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
cmake_minimum_required(VERSION 3.26...3.29)
12+
project(SwiftBuild
13+
LANGUAGES C CXX Swift)
14+
15+
set(CMAKE_C_VISIBILITY hidden)
16+
set(CMAKE_CXX_VISIBILITY hidden)
17+
set(CMAKE_CXX_STANDARD 17)
18+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
19+
set(CMAKE_CXX_EXTENSIONS NO)
20+
set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
21+
22+
option(SwiftBuild_USE_LLBUILD_FRAMEWORK "Use LLBuild Framework" NO)
23+
24+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-package-name SwiftBuild>"
25+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ConciseMagicFile>"
26+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature DeprecateApplicationMain>"
27+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature DisableOutwardActorInference>"
28+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ForwardTrailingClosures>"
29+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature GlobalConcurrency>"
30+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ImplicitOpenExistentials>"
31+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature ImplicitOpenExistentialsImportObjcForwardDeclarations>"
32+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature InferSendableFromCaptures>"
33+
"$<$<AND:$<COMPILE_LANGUAGE:Swift>,$<VERSION_LESS:$<TARGET_PROPERTY:Swift_LANGUAGE_VERSION>,6>>:SHELL:-enable-upcoming-feature IsolatedDefaultValues>"
34+
# rdar://127809703
35+
# "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature RegionBasedIsolation>"
36+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>"
37+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>")
38+
39+
find_package(ArgumentParser)
40+
find_package(LLBuild)
41+
find_package(SwiftDriver)
42+
find_package(SwiftSystem)
43+
find_package(TSC)
44+
# NOTE: these two are required for LLBuild dependencies
45+
find_package(Threads)
46+
find_package(SQLite3)
47+
48+
add_subdirectory(Sources)

Sources/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_subdirectory(SWBCSupport)
12+
add_subdirectory(SWBCLibc)
13+
add_subdirectory(SWBLibc)
14+
add_subdirectory(SWBUtil)
15+
add_subdirectory(SWBMacro)
16+
add_subdirectory(SWBProtocol)
17+
add_subdirectory(SWBServiceCore)
18+
add_subdirectory(SWBCAS)
19+
add_subdirectory(SWBLLBuild)
20+
add_subdirectory(SWBCore)
21+
add_subdirectory(SWBTaskConstruction)
22+
add_subdirectory(SWBTaskExecution)
23+
add_subdirectory(SWBBuildSystem)
24+
add_subdirectory(SWBBuildService)
25+
add_subdirectory(SWBProjectModel)
26+
add_subdirectory(SwiftBuild)
27+
28+
add_subdirectory(swbuild)
29+
add_subdirectory(SWBBuildServiceBundle)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_library(SWBBuildService
12+
BuildDependencyInfo.swift
13+
BuildOperationMessages.swift
14+
BuildService.swift
15+
BuildServiceEntryPoint.swift
16+
ClientExchangeDelegate.swift
17+
DependencyGraphMessages.swift
18+
DocumentationInfo.swift
19+
LocalizationInfo.swift
20+
Messages.swift
21+
PlanningOperation.swift
22+
PreviewInfo.swift
23+
ProjectDescriptor.swift
24+
Session.swift
25+
Tools.swift)
26+
set_target_properties(SWBBuildService PROPERTIES
27+
Swift_LANGUAGE_VERSION 5)
28+
target_link_libraries(SWBBuildService PUBLIC
29+
SWBBuildSystem
30+
SWBServiceCore
31+
SWBTaskExecution
32+
SwiftSystem::SystemPackage)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_executable(SWBBuildServiceBundle
12+
main.swift)
13+
set_target_properties(SWBBuildServiceBundle PROPERTIES
14+
Swift_LANGUAGE_VERSION 6)
15+
target_link_libraries(SWBBuildServiceBundle PRIVATE
16+
SWBBuildService
17+
SWBBuildSystem
18+
SWBServiceCore
19+
SWBUtil
20+
SWBCore)
21+
22+
install(TARGETS SWBBuildServiceBundle)

Sources/SWBBuildSystem/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_library(SWBBuildSystem
12+
BuildManager.swift
13+
BuildOperation.swift
14+
BuildOperationExtension.swift
15+
BuildSystemCache.swift
16+
CleanOperation.swift
17+
DependencyCycleFormatter.swift
18+
SandboxViolations.swift)
19+
set_target_properties(SWBBuildSystem PROPERTIES
20+
Swift_LANGUAGE_VERSION 5)
21+
target_link_libraries(SWBBuildSystem PUBLIC
22+
SWBCore
23+
SWBTaskConstruction
24+
SWBTaskExecution)

Sources/SWBCAS/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_library(SWBCAS
12+
CASFSNode.swift
13+
CASProtocol.swift
14+
Errors.swift
15+
plugin_api_t.swift
16+
ToolchainCASPlugin.swift)
17+
set_target_properties(SWBCAS PROPERTIES
18+
Swift_LANGUAGE_VERSION 6)
19+
target_link_libraries(SWBCAS PUBLIC
20+
SWBUtil
21+
SWBCSupport)

Sources/SWBCLibc/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_library(SWBCLibc
12+
libc.c)
13+
target_include_directories(SWBCLibc INTERFACE
14+
include)

Sources/SWBCSupport/CMakeLists.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
]]
10+
11+
add_library(SWBCSupport STATIC
12+
CLibclang.cpp
13+
CLibRemarksHelper.c)
14+
target_compile_definitions(SWBCSupport PRIVATE
15+
$<$<PLATFORM_ID:Windows>:_CRT_SECURE_NO_WARNINGS>
16+
$<$<PLATFORM_ID:Windows>:_CRT_NONSTDC_NO_WARNINGS>)
17+
target_compile_options(SWBCSupport PRIVATE
18+
-fblocks)
19+
target_include_directories(SWBCSupport PUBLIC
20+
${CMAKE_CURRENT_SOURCE_DIR})
21+
# TODO(compnerd) wire this up with `find_package`
22+
target_link_libraries(SWBCSupport PRIVATE
23+
BlocksRuntime)

Sources/SWBCSupport/module.modulemap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module SWBCSupport {
2+
header "SWBCSupport.h"
3+
export *
4+
}

0 commit comments

Comments
 (0)