Skip to content

Commit

Permalink
feat: add support for Swift package registries
Browse files Browse the repository at this point in the history
  • Loading branch information
luispadron committed Nov 12, 2024
1 parent 8697941 commit 9838fcd
Show file tree
Hide file tree
Showing 31 changed files with 588 additions and 95 deletions.
4 changes: 2 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# To update these lines, execute
# `bazel run @rules_bazel_integration_test//tools:update_deleted_packages`
build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
build --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/swift_package_registry_example,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example
query --deleted_packages=bzlmod/workspace,bzlmod/workspace/Sources/MyExecutable,bzlmod/workspace/Sources/MyLibrary,bzlmod/workspace/Sources/System,bzlmod/workspace/Tests/MyLibraryTests,examples/firebase_example,examples/firebase_example/abtesting,examples/firebase_example/abtesting/SharedApp,examples/firebase_example/analytics/AnalyticsExample,examples/firebase_example/appdistribution,examples/firebase_example/appdistribution/AppDistributionExample,examples/firebase_example/appdistribution/AppDistributionTests,examples/firebase_example/crashlytics,examples/google_maps_example,examples/google_maps_example/GoogleMapsExample,examples/google_maps_example/third-party/google-maps-ios-sdk,examples/grpc_example,examples/grpc_example/aaa_test,examples/grpc_example/protos,examples/grpc_example/protos/echo_service,examples/grpc_example/protos/echo_service/requests,examples/grpc_example/protos/echo_service/responses,examples/grpc_example/sources,examples/grpc_example/sources/client,examples/grpc_example/sources/server,examples/grpc_example/sources/test,examples/grpc_package_example,examples/grpc_package_example/aaa_test,examples/grpc_package_example/protos,examples/grpc_package_example/protos/echo_service,examples/grpc_package_example/sources,examples/grpc_package_example/sources/client,examples/grpc_package_example/sources/server,examples/grpc_package_example/sources/test,examples/interesting_deps,examples/ios_sim,examples/ios_sim/Sources/Foo,examples/ios_sim/Tests/FooTests,examples/ios_sim/third-party/swift-cmark,examples/lottie_ios_example,examples/lottie_ios_example/LottieExample,examples/lottie_ios_example/LottieExampleUITest,examples/messagekit_example,examples/messagekit_example/Sources,examples/messagekit_example/UITests,examples/nimble_example,examples/nimble_example/Sources/NimbleExample,examples/objc_code,examples/phone_number_kit,examples/phone_number_kit/Tests/PhoneNumberKitTests,examples/pkg_manifest_minimal,examples/pkg_manifest_minimal/Sources/MyExecutable,examples/pkg_manifest_minimal/Sources/MyLibrary,examples/pkg_manifest_minimal/Tests/MyLibraryTests,examples/pkg_manifest_minimal/third_party,examples/resources_example,examples/resources_example/Sources/MyApp,examples/resources_example/Tests/MyAppTests,examples/resources_example/Tests/MyAppUITests,examples/resources_example/third_party,examples/shake_ios_example,examples/shake_ios_example/ShakeIOSExample,examples/shake_ios_example/ShakeIOSExampleUITests,examples/snapkit_example,examples/soto_example,examples/soto_example/Tests/SotoTests,examples/stripe_example,examples/stripe_example/PaymentSheet/PaymentSheetExample,examples/stripe_example/PaymentSheet/PaymentSheetUITest,examples/swift_package_registry_example,examples/symlink_example,examples/symlink_example/Sources/ImportFramework,examples/symlink_example/Tests/ImportFrameworkTests,examples/tca_example,examples/tca_example/Sources,examples/tca_example/Tests,examples/vapor_example,examples/vapor_example/Sources/App,examples/vapor_example/Sources/Run,examples/vapor_example/Tests/AppTests,examples/vapor_example/swift,examples/xcmetrics_example

# Import Shared settings
import %workspace%/shared.bazelrc
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ jobs:
runner: macos-13
- test: '@@//examples:stripe_example_test_bazel_.bazelversion'
runner: macos-13
- test: '@@//examples:swift_package_registry_example_test_bazel_.bazelversion'
runner: macos-13
- test: '@@//examples:symlink_example_test_bazel_.bazelversion'
runner: macos-13
- test: '@@//examples:tca_example_test_bazel_.bazelversion'
Expand Down
1 change: 1 addition & 0 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ _DOC_INFOS = [
symbols = [
"local_swift_package",
"swift_package",
"registry_swift_package",
],
),
doc_infos.new(
Expand Down
10 changes: 7 additions & 3 deletions docs/bzlmod_extensions_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ On this page:
swift_deps = use_extension("@rules_swift_package_manager//:extensions.bzl", "swift_deps")
swift_deps.configure_package(<a href="#swift_deps.configure_package-name">name</a>, <a href="#swift_deps.configure_package-init_submodules">init_submodules</a>, <a href="#swift_deps.configure_package-patch_args">patch_args</a>, <a href="#swift_deps.configure_package-patch_cmds">patch_cmds</a>, <a href="#swift_deps.configure_package-patch_cmds_win">patch_cmds_win</a>,
<a href="#swift_deps.configure_package-patch_tool">patch_tool</a>, <a href="#swift_deps.configure_package-patches">patches</a>, <a href="#swift_deps.configure_package-recursive_init_submodules">recursive_init_submodules</a>)
swift_deps.configure_swift_package(<a href="#swift_deps.configure_swift_package-build_path">build_path</a>, <a href="#swift_deps.configure_swift_package-cache_path">cache_path</a>, <a href="#swift_deps.configure_swift_package-dependency_caching">dependency_caching</a>, <a href="#swift_deps.configure_swift_package-manifest_cache">manifest_cache</a>,
<a href="#swift_deps.configure_swift_package-manifest_caching">manifest_caching</a>, <a href="#swift_deps.configure_swift_package-security_path">security_path</a>)
swift_deps.from_package(<a href="#swift_deps.from_package-declare_swift_deps_info">declare_swift_deps_info</a>, <a href="#swift_deps.from_package-declare_swift_package">declare_swift_package</a>, <a href="#swift_deps.from_package-resolved">resolved</a>, <a href="#swift_deps.from_package-swift">swift</a>)
swift_deps.configure_swift_package(<a href="#swift_deps.configure_swift_package-build_path">build_path</a>, <a href="#swift_deps.configure_swift_package-cache_path">cache_path</a>, <a href="#swift_deps.configure_swift_package-config_path">config_path</a>, <a href="#swift_deps.configure_swift_package-dependency_caching">dependency_caching</a>,
<a href="#swift_deps.configure_swift_package-manifest_cache">manifest_cache</a>, <a href="#swift_deps.configure_swift_package-manifest_caching">manifest_caching</a>, <a href="#swift_deps.configure_swift_package-replace_scm_with_registry">replace_scm_with_registry</a>,
<a href="#swift_deps.configure_swift_package-security_path">security_path</a>)
swift_deps.from_package(<a href="#swift_deps.from_package-declare_swift_deps_info">declare_swift_deps_info</a>, <a href="#swift_deps.from_package-declare_swift_package">declare_swift_package</a>, <a href="#swift_deps.from_package-registries">registries</a>, <a href="#swift_deps.from_package-resolved">resolved</a>, <a href="#swift_deps.from_package-swift">swift</a>)
</pre>


Expand Down Expand Up @@ -56,9 +57,11 @@ Used to configure the flags used when running the `swift package` binary.
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="swift_deps.configure_swift_package-build_path"></a>build_path | The relative path within the runfiles tree for the Swift Package Manager build directory. | String | optional | `".build"` |
| <a id="swift_deps.configure_swift_package-cache_path"></a>cache_path | The relative path within the runfiles tree for the shared Swift Package Manager cache directory. | String | optional | `".cache"` |
| <a id="swift_deps.configure_swift_package-config_path"></a>config_path | The relative path within the runfiles tree for the Swift Package Manager configuration directory. | String | optional | `".swiftpm"` |
| <a id="swift_deps.configure_swift_package-dependency_caching"></a>dependency_caching | Whether to enable the dependency cache. | Boolean | optional | `True` |
| <a id="swift_deps.configure_swift_package-manifest_cache"></a>manifest_cache | Caching mode of Package.swift manifests (shared: shared cache, local: package's build directory, none: disabled) | String | optional | `"shared"` |
| <a id="swift_deps.configure_swift_package-manifest_caching"></a>manifest_caching | Whether to enable build manifest caching. | Boolean | optional | `True` |
| <a id="swift_deps.configure_swift_package-replace_scm_with_registry"></a>replace_scm_with_registry | Look up source control dependencies in the registry and use the registry to retrieve them instead of source control when possible. | Boolean | optional | `False` |
| <a id="swift_deps.configure_swift_package-security_path"></a>security_path | The relative path within the runfiles tree for the security directory. | String | optional | `".security"` |

<a id="swift_deps.from_package"></a>
Expand All @@ -73,6 +76,7 @@ Load Swift packages from `Package.swift` and `Package.resolved` files.
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="swift_deps.from_package-declare_swift_deps_info"></a>declare_swift_deps_info | Declare a `swift_deps_info` repository that is used by external tooling (e.g. Swift Gazelle plugin). | Boolean | optional | `False` |
| <a id="swift_deps.from_package-declare_swift_package"></a>declare_swift_package | Declare a `swift_package_tool` repository named `swift_package` which defines two targets: `update` and `resolve`. These targets run can be used to run the `swift package` binary in a Bazel context. The flags used when running the underlying `swift package` can be configured using the `configure_swift_package` tag.<br><br>They can be `bazel run` to update/resolve the `resolved` file:<br><br><pre><code>bazel run @swift_package//:update&#10;bazel run @swift_package//:resolve</code></pre> | Boolean | optional | `True` |
| <a id="swift_deps.from_package-registries"></a>registries | A `registries.json` file that defines the configured Swift package registries.<br><br>The `registries.json` file is used when resolving Swift packages from a Swift package registry. It is created by Swift Package Manager when using the `swift package-registry` commands.<br><br>When using the `swift_package_tool` rules, this file is symlinked to the `config_path` directory defined in the `configure_swift_package` tag. If not using the `swift_package_tool` rules, the file must be in one of Swift Package Manager's search paths or in the manually specified `--config-path` directory. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="swift_deps.from_package-resolved"></a>resolved | A `Package.resolved`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
| <a id="swift_deps.from_package-swift"></a>swift | A `Package.swift`. | <a href="https://bazel.build/concepts/labels">Label</a> | required | |

Expand Down
Loading

0 comments on commit 9838fcd

Please sign in to comment.