-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Swift package registries
- Loading branch information
1 parent
d15b8ae
commit a5adfda
Showing
14 changed files
with
300 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Import Shared settings | ||
import %workspace%/../../shared.bazelrc | ||
|
||
# Import CI settings. | ||
import %workspace%/../../ci.bazelrc | ||
|
||
# Try to import a local.rc file; typically, written by CI | ||
try-import %workspace%/../../local.bazelrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library") | ||
|
||
swift_library( | ||
name = "SwiftPackageRegistryExample", | ||
srcs = ["main.swift"], | ||
deps = [ | ||
"@swiftpkg_swift_collections//:Collections", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module( | ||
name = "interesting_deps_example", | ||
version = "0.0.0", | ||
) | ||
|
||
bazel_dep( | ||
name = "rules_swift_package_manager", | ||
version = "0.0.0", | ||
) | ||
local_path_override( | ||
module_name = "rules_swift_package_manager", | ||
path = "../..", | ||
) | ||
|
||
bazel_dep(name = "cgrindel_bazel_starlib", version = "0.21.0") | ||
bazel_dep(name = "bazel_skylib", version = "1.7.1") | ||
|
||
# The apple_support bazel_dep must come before the rules_cc. | ||
# https://github.com/bazelbuild/apple_support#incompatible-toolchain-resolution | ||
bazel_dep(name = "apple_support", version = "1.17.1") | ||
bazel_dep( | ||
name = "rules_swift", | ||
version = "2.2.2", | ||
repo_name = "build_bazel_rules_swift", | ||
) | ||
|
||
bazel_dep( | ||
name = "bazel_skylib_gazelle_plugin", | ||
version = "1.7.1", | ||
dev_dependency = True, | ||
) | ||
bazel_dep( | ||
name = "gazelle", | ||
version = "0.39.1", | ||
dev_dependency = True, | ||
repo_name = "bazel_gazelle", | ||
) | ||
|
||
apple_cc_configure = use_extension( | ||
"@apple_support//crosstool:setup.bzl", | ||
"apple_cc_configure_extension", | ||
) | ||
use_repo(apple_cc_configure, "local_config_apple_cc") | ||
|
||
swift_deps = use_extension( | ||
"@rules_swift_package_manager//:extensions.bzl", | ||
"swift_deps", | ||
) | ||
swift_deps.from_package( | ||
resolved = "//:Package.resolved", | ||
swift = "//:Package.swift", | ||
) | ||
swift_deps.configure_swift_package( | ||
registries = { | ||
"[default]": "http://localhost:8000", | ||
}, | ||
) | ||
|
||
use_repo( | ||
swift_deps, | ||
"swift_package", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"originHash" : "21c64ff306c68b30986eb70b9aa9bb2771832a6236d332312f98a602acd95942", | ||
"pins" : [ | ||
{ | ||
"identity" : "apple.swift-collections", | ||
"kind" : "registry", | ||
"location" : "", | ||
"state" : { | ||
"version" : "1.1.3" | ||
} | ||
} | ||
], | ||
"version" : 3 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// swift-tools-version: 5.10 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SwiftPackageRegistryExample", | ||
dependencies: [ | ||
.package(id: "apple.swift-collections", exact: "1.1.3"), | ||
] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Example using a Swift Package Registry | ||
|
||
This example demonstrates how to declare dependent Swift packages that are hosted in a Swift | ||
Package Registry. | ||
|
||
TODO: Add an example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit -o nounset -o pipefail | ||
|
||
# Use the Bazel binary specified by the integration test. Otherise, fall back | ||
# to bazel. | ||
bazel="${BIT_BAZEL_BINARY:-bazel}" | ||
|
||
# This example requires a local registry to be running on `localhost:8000`. | ||
# As such we spin up a local registry using https://github.com/luispadron/fake-swift-package-registry | ||
curl \ | ||
-L https://github.com/luispadron/fake-swift-package-registry/releases/download/0.3.0/fake-swift-package-registry \ | ||
-o /tmp/fake-swift-package-registry | ||
chmod +x /tmp/fake-swift-package-registry | ||
spctl --add /tmp/fake-swift-package-registry # the binary is not signed, allow it to run | ||
|
||
# Start the fake registry in the background | ||
/tmp/fake-swift-package-registry > /tmp/fake-swift-package-registry.log 2>&1 & | ||
fake_swift_package_registry_pid=$! | ||
trap "kill ${fake_swift_package_registry_pid}" EXIT ERR | ||
|
||
# Test resolving the package via the `swift_package` repo. | ||
"${bazel}" run @swift_package//:resolve | ||
|
||
# Ensure that it builds and tests pass | ||
"${bazel}" test //... | ||
|
||
# Shutdown the fake registry | ||
kill "${fake_swift_package_registry_pid}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Collections | ||
|
||
let orderedSet = OrderedSet([1, 2, 3, 4, 5]) | ||
|
||
print("Hello, world!") | ||
print(orderedSet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.