Skip to content

Commit e80fb90

Browse files
committed
Merge branch 'main' into more-swift-concurrency-1
2 parents 6c0cfdd + 4864758 commit e80fb90

26 files changed

+1461
-140
lines changed

CMakeLists.txt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#[[
2+
This source file is part of the Swift open source project
3+
4+
Copyright © 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See https://swift.org/LICENSE.txt for license information
8+
#]]
9+
10+
cmake_minimum_required(VERSION 3.24)
11+
12+
# FIXME: The C language is enabled as `GNUInstallDirs` requires the language to
13+
# function properly. We must further enable the language in the initial set to
14+
# ensure that the correct linker is detected.
15+
project(SwiftDocC
16+
LANGUAGES C Swift)
17+
18+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
19+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
20+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
21+
22+
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
23+
set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
24+
set(CMAKE_Swift_LANGUAGE_VERSION 5)
25+
26+
include(GNUInstallDirs)
27+
28+
# NOTE(compnerd) workaround CMake issues
29+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-swift-version 5>")
30+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ConciseMagicFile>")
31+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature ExistentialAny>")
32+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-upcoming-feature InternalImportsByDefault>")
33+
34+
find_package(ArgumentParser)
35+
find_package(SwiftASN1)
36+
find_package(SwiftCrypto)
37+
find_package(SwiftMarkdown)
38+
find_package(LMDB)
39+
find_package(SymbolKit)
40+
find_package(cmark-gfm)
41+
42+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:-package-name;SwiftDocC>")
43+
44+
add_subdirectory(Sources)

CONTRIBUTING.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,32 @@ by running the test suite in a Docker environment that simulates Swift on Linux.
350350
cd swift-docc
351351
swift run docc
352352
```
353-
353+
354+
## Updating Build Rules
355+
356+
In order to build DocC as part of the Windows toolchain distribution uniformly,
357+
a parallel CMake based build exists. Note that this is **not** supported for
358+
development purposes (you cannot execute the test suite with this build).
359+
360+
CMake requires that the full file list is kept up-to-date. When adding or
361+
removing files in a given module, the `CMakeLists.txt` list must be updated to
362+
the file list.
363+
364+
The 1-line script below lists all the Swift files in the current directory tree.
365+
You can use the script's output to replace the list of files in the CMakeLists.txt file for each target that you added files to or removed files from.
366+
367+
```bash
368+
python -c "print('\n'.join((f'{chr(34)}{path}{chr(34)}' if ' ' in path else path) for path in sorted(str(path) for path in __import__('pathlib').Path('.').rglob('*.swift'))))"
369+
```
370+
371+
This should provide the listing of files in the module that can be used to
372+
update the `CMakeLists.txt` associated with the target.
373+
374+
In the case that a new target is added to the project, the new directory would
375+
need to add the new library or executable target (`add_library` and
376+
`add_executable` respectively) and the new target subdirectory must be listed in
377+
the `Sources/CMakeLists.txt` (via `add_subdirectory`).
378+
354379
## Continuous Integration
355380

356381
Swift-DocC uses [swift-ci](https://ci.swift.org) infrastructure for its continuous integration

Package.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ let package = Package(
4848
.product(name: "CLMDB", package: "swift-lmdb"),
4949
.product(name: "Crypto", package: "swift-crypto"),
5050
],
51+
exclude: ["CMakeLists.txt"],
5152
swiftSettings: swiftSettings
5253
),
5354
.testTarget(
@@ -72,6 +73,7 @@ let package = Package(
7273
.product(name: "NIOHTTP1", package: "swift-nio", condition: .when(platforms: [.macOS, .iOS, .linux, .android])),
7374
.product(name: "ArgumentParser", package: "swift-argument-parser")
7475
],
76+
exclude: ["CMakeLists.txt"],
7577
swiftSettings: swiftSettings
7678
),
7779
.testTarget(
@@ -104,6 +106,7 @@ let package = Package(
104106
dependencies: [
105107
.target(name: "SwiftDocCUtilities"),
106108
],
109+
exclude: ["CMakeLists.txt"],
107110
swiftSettings: swiftSettings
108111
),
109112

@@ -125,7 +128,6 @@ let package = Package(
125128
],
126129
swiftSettings: swiftSettings
127130
),
128-
129131
]
130132
)
131133

Sources/CMakeLists.txt

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

0 commit comments

Comments
 (0)