-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows dependencies of kind path to work, both in the [dependencies] table and the [patches] table. The intention is that this is used for third-party code not first-party code.
- Loading branch information
1 parent
4329e41
commit 0e23fc0
Showing
46 changed files
with
1,750 additions
and
115 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
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
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,63 @@ | ||
"""`local_crate_mirror` rule implementation. | ||
This is a private implementation detail of crate_universe, and should not be relied on in manually written code. | ||
This is effectively a `local_repository` rule impementation, but where the BUILD.bazel file is generated using the `cargo-bazel render` command. | ||
""" | ||
|
||
load("//crate_universe/private:common_utils.bzl", "execute") | ||
load("//crate_universe/private:generate_utils.bzl", "get_generator") | ||
load("//crate_universe/private:urls.bzl", "CARGO_BAZEL_SHA256S", "CARGO_BAZEL_URLS") | ||
load("//rust/platform:triple.bzl", "get_host_triple") | ||
|
||
def _local_crate_mirror_impl(repository_ctx): | ||
path = repository_ctx.path(repository_ctx.attr.path) | ||
|
||
host_triple = get_host_triple(repository_ctx) | ||
|
||
generator, _generator_sha256 = get_generator(repository_ctx, host_triple.str) | ||
|
||
execute(repository_ctx, ["bash", "-c", "cp -r {}/* {}/".format(path, repository_ctx.path("."))]) | ||
|
||
paths_to_track = execute(repository_ctx, ["bash", "-c", "find {} -type f".format(path)]).stdout.strip().split("\n") | ||
for path_to_track in paths_to_track: | ||
if path_to_track: | ||
repository_ctx.read(path_to_track) | ||
|
||
execute(repository_ctx, [generator, "render", "--options-json", repository_ctx.attr.options_json, "--output-path", repository_ctx.path("BUILD.bazel")]) | ||
|
||
repository_ctx.file("WORKSPACE", "") | ||
|
||
local_crate_mirror = repository_rule( | ||
implementation = _local_crate_mirror_impl, | ||
attrs = { | ||
"generator": attr.string( | ||
doc = ( | ||
"The absolute label of a generator. Eg. `@cargo_bazel_bootstrap//:cargo-bazel`. " + | ||
"This is typically used when bootstrapping" | ||
), | ||
), | ||
"generator_sha256s": attr.string_dict( | ||
doc = "Dictionary of `host_triple` -> `sha256` for a `cargo-bazel` binary.", | ||
default = CARGO_BAZEL_SHA256S, | ||
), | ||
"generator_urls": attr.string_dict( | ||
doc = ( | ||
"URL template from which to download the `cargo-bazel` binary. `{host_triple}` and will be " + | ||
"filled in according to the host platform." | ||
), | ||
default = CARGO_BAZEL_URLS, | ||
), | ||
"options_json": attr.string( | ||
doc = "JSON serialized instance of a crate_universe::context::SingleBuildFileRenderContext", | ||
), | ||
"path": attr.string( | ||
# TODO: Verify what happens if this is not an absolute path. | ||
doc = "Absolute path to the BUILD.bazel file to generate.", | ||
), | ||
"quiet": attr.bool( | ||
doc = "If stdout and stderr should not be printed to the terminal.", | ||
default = True, | ||
), | ||
}, | ||
) |
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.