apple/swift
Tooling
The build system, scripts, and helper utilities you'll touch as a contributor.
build-script
utils/build-script (Python) is the canonical entry point for building everything. It calls utils/build-script-impl (a CMake/Ninja driver) and utils/build-toolchain (a tarball builder).
Common invocations:
# Default debug build
./swift/utils/build-script
# Release with assertions, plus tests, plus benchmarks
./swift/utils/build-script -R --test --benchmark
# Build only the host stdlib (skip cross targets)
./swift/utils/build-script --skip-build-osx --skip-build-ios
# Build a toolchain tarball
./swift/utils/build-toolchain com.examplePresets
Common configurations live in utils/build-presets.ini:
buildbot_incremental-- the CI baseline.mixin_buildbot_install_components_with_clang-- adds Clang to the toolchain.mixin_buildbot_tools_RA_stdlib_DA-- release-with-assertions tools, debug stdlib.
Invoke with --preset=<name>.
update-checkout
utils/update-checkout keeps the side-by-side dependent repos at compatible revisions. The list is in utils/update-checkout/update-checkout-config.json. Useful subcommands:
./utils/update-checkout --clone # initial clone of all repos
./utils/update-checkout --scheme=main # update to latest tested
./utils/update-checkout --tag=swift-6.3-RELEASE # check out a specific taggyb
utils/gyb.py ("Generate Your Boilerplate") is a Python templating tool used heavily in the standard library. Files end in .gyb. The build runs gyb on every .gyb to produce the corresponding source. Try:
./utils/gyb stdlib/public/core/Tuple.swift.gyb -o /tmp/Tuple.swiftGYB syntax: % python_statement, ${python_expression}, %end to close blocks.
Other helpful scripts
| Script | What it does |
|---|---|
utils/run-test |
Wraps lit to run subsets of test/. |
utils/build-toolchain |
Produces a redistributable toolchain tarball. |
utils/git-clang-format-all.zsh |
Run clang-format over the working tree. |
utils/python_lint.py |
Run pylint over the Python code. |
utils/find-overlay-dependencies.sh |
Visualize stdlib overlay dependencies. |
utils/swift-api-dump.py |
Dump a Clang module as Swift API. |
utils/api_checker/ |
Compare two SDKs for API breakage (used by ABI check CI). |
utils/generate-xcode |
Produce an Xcode project for IDE use. |
utils/bug_reducer/ |
Reducer for compiler crash repros. |
utils/swift-mode.el, utils/sil-mode.el |
Emacs modes. |
CMake structure
Top-level CMakeLists.txt drives the build. Major subprojects:
lib/CMakeLists.txt-- compiler libraries.tools/CMakeLists.txt-- driver, demangle, sourcekit, etc.stdlib/CMakeLists.txt-- standard library and overlays (multi-target cross-compile).Runtimes/CMakeLists.txt-- the newer, decoupled stdlib build (see Runtimes).unittests/CMakeLists.txt-- C++ unit tests.
CMake helpers live in cmake/modules/. The two most important are:
cmake/modules/AddSwift.cmake--add_swift_target_library,add_swift_host_library, etc.cmake/modules/SwiftSource.cmake-- handles.swiftsources for the standard library.
Editor integrations
- VS Code: install the Swift extension; the build emits
compile_commands.jsonfor clangd. - Xcode:
utils/generate-xcodeproduces a.xcodeprojfor the C++ sources. - Emacs:
utils/swift-mode.el,utils/sil-mode.el,utils/inferior-swift-mode.el. - Vim: most contributors install swift-syntax for Vim externally.
CI
.github/workflows/ holds GitHub Actions configurations (mostly auxiliary). The primary CI is the Apple-internal Jenkins farm fronted by the @swift_ci bot. PR comments trigger jobs.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.