Skip to content
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

Add custom macOS Swift toolchain support #214

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@ environment variable `CC=clang` when invoking Bazel.
This step is not necessary for macOS users because the Xcode toolchain always
uses `clang`.

## Building with Custom Toolchains

**macOS hosts:** You can build with a custom toolchain installed in
`/Library/Developer/Toolchains` instead of Xcode's default. To do so, pass the
following flag to Bazel:

```
--define=SWIFT_CUSTOM_TOOLCHAIN=toolchain.id
```

where `toolchain.id` is the value of the `CFBundleIdentifier` key in the
toolchain's Info.plist file.

**Linux hosts:** At this time, Bazel uses whichever `swift` executable is
encountered first on your `PATH`.

## Future Work

* Support for building and linking to shared libraries (`.dylib`/`.so`) written
Expand Down
4 changes: 4 additions & 0 deletions swift/internal/xcode_swift_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,10 @@ def _xcode_swift_toolchain_impl(ctx):

# Configure the action registrars that automatically prepend xcrunwrapper to registered actions.
env = _xcode_env(xcode_config, platform)
custom_toolchain = ctx.var.get("SWIFT_CUSTOM_TOOLCHAIN")
if custom_toolchain:
env["TOOLCHAINS"] = custom_toolchain

execution_requirements = {"requires-darwin": ""}
bazel_xcode_wrapper = ctx.executable._bazel_xcode_wrapper
action_registrars = struct(
Expand Down