Skip to content

Commit

Permalink
Merge pull request #214 from keith:ks/toolchains
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 246558164
  • Loading branch information
swiple-rules-gardener committed May 3, 2019
2 parents e7d8ec5 + 40298b4 commit 2cb54e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit 2cb54e1

Please sign in to comment.