Skip to content

Commit

Permalink
Added helper macro for declaring transitive dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
UebelAndre authored and keith committed Sep 21, 2020
1 parent 4f4b7f0 commit d2efe38
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 24 deletions.
41 changes: 17 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,11 @@ load(
swift_rules_dependencies()

load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
"@build_bazel_rules_swift//swift:extras.bzl",
"swift_rules_extra_dependencies",
)

apple_support_dependencies()

load(
"@com_google_protobuf//:protobuf_deps.bzl",
"protobuf_deps",
)

protobuf_deps()
swift_rules_extra_dependencies()
```

The `swift_rules_dependencies` macro creates a toolchain appropriate for your
Expand All @@ -98,7 +91,7 @@ uses `clang`.
`/Library/Developer/Toolchains` instead of Xcode's default. To do so, pass the
following flag to Bazel:

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

Expand All @@ -107,7 +100,7 @@ toolchain's Info.plist file.

To list the available toolchains and their bundle identifiers, you can run:

```
```command
bazel run @build_bazel_rules_swift//tools/dump_toolchains
```

Expand All @@ -116,24 +109,24 @@ encountered first on your `PATH`.

## Future Work

* Support for building and linking to shared libraries (`.dylib`/`.so`) written
- Support for building and linking to shared libraries (`.dylib`/`.so`) written
in Swift.
* Interoperability with Swift Package Manager.
* Migration to the Bazel platforms/toolchains APIs.
* Support for multiple toolchains, and support for non-Xcode toolchains on
- Interoperability with Swift Package Manager.
- Migration to the Bazel platforms/toolchains APIs.
- Support for multiple toolchains, and support for non-Xcode toolchains on
macOS.
* Automatically download a Linux toolchain from [swift.org](https://swift.org)
- Automatically download a Linux toolchain from [swift.org](https://swift.org)
if one is not already installed.

## Acknowledgments

We gratefully acknowledge the following external packages that rules_swift
depends on:

* [Apple Support for Bazel](https://github.com/bazelbuild/apple_support) (Google)
* [Bazel Skylib](https://github.com/bazelbuild/bazel-skylib) (Google)
* [JSON for Modern C++](https://github.com/nlohmann/json) (Niels Lohmann)
* [Protocol Buffers](https://github.com/protocolbuffers/protobuf) (Google)
* [Swift gRPC](https://github.com/grpc/grpc-swift) (Google)
* [Swift Protobuf](https://github.com/apple/swift-protobuf) (Apple)
* [zlib](https://www.zlib.net) (Jean-loup Gailly and Mark Adler)
- [Apple Support for Bazel](https://github.com/bazelbuild/apple_support) (Google)
- [Bazel Skylib](https://github.com/bazelbuild/bazel-skylib) (Google)
- [JSON for Modern C++](https://github.com/nlohmann/json) (Niels Lohmann)
- [Protocol Buffers](https://github.com/protocolbuffers/protobuf) (Google)
- [Swift gRPC](https://github.com/grpc/grpc-swift) (Google)
- [Swift Protobuf](https://github.com/apple/swift-protobuf) (Apple)
- [zlib](https://www.zlib.net) (Jean-loup Gailly and Mark Adler)
33 changes: 33 additions & 0 deletions swift/extras.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2018 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Definitions for handling Bazel transitive repositories used by the
dependencies of the Swift rules.
"""

load("@build_bazel_apple_support//lib:repositories.bzl", "apple_support_dependencies")
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

def swift_rules_extra_dependencies():
"""Fetches transitive repositories of the dependencies of `rules_swift`.
Users should call this macro in their `WORKSPACE` following the use of
`swift_rules_dependencies` to ensure that all of the dependencies of
the Swift rules are downloaded and that they are isolated from changes
to those dependencies.
"""

apple_support_dependencies()

protobuf_deps()

0 comments on commit d2efe38

Please sign in to comment.