feat: mark development deps as dev_dependency and make swift_deps_info unique#1982
Draft
luispadron wants to merge 1 commit into
Draft
feat: mark development deps as dev_dependency and make swift_deps_info unique#1982luispadron wants to merge 1 commit into
dev_dependency and make swift_deps_info unique#1982luispadron wants to merge 1 commit into
Conversation
dev_dependencydev_dependency and make swift_deps_info unique
a735e5c to
87411ea
Compare
…info` unique BREAKING CHANGES: - Users which require `swift_deps_info` to be declared must now specify a `module(name)` in their `MODULE.bazel`. - Development repositories like `swift_package` are marked as dev dependencies. - The name of the `swift_deps_info` repository will now be prefixed by the Bazel module name that defines it. This change works towards #769, in order to support `rules_swift_package_manager` usage in multiple modules within a single Bazel module we must make the `swift_deps_info` and `swift_package` repositories unique. For `swift_deps_info` we do this by prefixing it with the name of the defining Bazel module (via `module(name = "...")`). I opted for this because defining `swift_deps_info` as a dev dependency means we'd effectively run the SPM commands to dump the package and such multiple times. I opened bazelbuild/bazel#28210 to look into a better way to define dev dependencies without requiring multiple `use_extension` calls. For `swift_package` we can define it as a `dev_dependency` as it doens't share much with the `swift_deps` extension. To do this we create a new `swift_dev_deps` extension which can be used to define dev dependencies, for now just `swift_package`. This extension is used with `use_extension(..., dev_dependency = True)`. This ensures it is not part of the Bazel module resolution. Example before: ```starlark swift_deps = use_extension( "@rules_swift_package_manager//:extensions.bzl", "swift_deps", ) swift_deps.from_package( registries = "//:registries.json", resolved = "//:Package.resolved", swift = "//:Package.swift", ) swift_deps.configure_swift_package( replace_scm_with_registry = True, ) use_repo( swift_deps, "swift_package", "swiftpkg_apple.swift_collections", "swiftpkg_apple.swift_nio", "swiftpkg_swift_async_algorithms", ) ``` Example after: ```starlark swift_deps = use_extension( "@rules_swift_package_manager//:extensions.bzl", "swift_deps", ) swift_deps.from_package( registries = "//:registries.json", replace_scm_with_registry = True, resolved = "//:Package.resolved", swift = "//:Package.swift", ) use_repo( swift_deps, "swiftpkg_apple.swift_collections", "swiftpkg_apple.swift_nio", "swiftpkg_swift_async_algorithms", ) swift_dev_deps = use_extension( "@rules_swift_package_manager//:extensions.bzl", "swift_dev_deps", dev_dependency = True, ) swift_dev_deps.from_package( registries = "//:registries.json", replace_scm_with_registry = True, swift = "//:Package.swift", ) use_repo(swift_dev_deps, "swift_package") ```
87411ea to
0876a77
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BREAKING CHANGES:
swift_deps_infoto be declared must now specify amodule(name)in theirMODULE.bazel.swift_packageare marked as dev dependencies.swift_deps_inforepository will now be prefixed by the Bazel module name that defines it.This change works towards #769, in order to support
rules_swift_package_managerusage in multiple modules within a single Bazel module we must make theswift_deps_infoandswift_packagerepositories unique.For
swift_deps_infowe do this by prefixing it with the name of the defining Bazel module (viamodule(name = "...")). I opted for this because definingswift_deps_infoas a dev dependency means we'd effectively run the SPM commands to dump the package and such multiple times. I opened bazelbuild/bazel#28210 to look into a better way to define dev dependencies without requiring multipleuse_extensioncalls.For
swift_packagewe can define it as adev_dependencyas it doens't share much with theswift_depsextension. To do this we create a newswift_dev_depsextension which can be used to define dev dependencies, for now justswift_package. This extension is used withuse_extension(..., dev_dependency = True). This ensures it is not part of the Bazel module resolution.Example before:
Example after: