From 6f1ee702daf9745cc1c174482856c555919f8fd3 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Wed, 14 Sep 2022 14:30:14 -0700 Subject: [PATCH 1/5] Add support for additional Cargo workspaces This is how I work around https://github.com/rust-lang/cargo/issues/5042 to get path dependencies into vendored Rust dependencies. The generated BUILD files are built with https://github.com/google/cargo-raze/pull/524, because otherwise they don't work. This fixes #361. --- WORKSPACE.bazel | 2 +- .../binary_dependencies/cargo/crates.bzl | 2 +- .../build_dependencies/cargo/crates.bzl | 2 +- .../remote/cargo_workspace/cargo/crates.bzl | 2 +- .../cargo/crates.bzl | 2 +- .../remote/dev_dependencies/cargo/crates.bzl | 2 +- examples/remote/no_deps/cargo/crates.bzl | 2 +- examples/remote/non_cratesio/cargo/crates.bzl | 2 +- .../cargo/BUILD.bazel | 24 + .../cargo/crates.bzl | 437 ++++++++++++++++++ .../cargo/remote/BUILD.ansi_term-0.12.1.bazel | 68 +++ .../cargo/remote/BUILD.atty-0.2.14.bazel | 88 ++++ .../cargo/remote/BUILD.bazel | 17 + .../cargo/remote/BUILD.bitflags-1.3.2.bazel | 59 +++ .../cargo/remote/BUILD.cfg-if-1.0.0.bazel | 54 +++ .../cargo/remote/BUILD.clap-2.34.0.bazel | 95 ++++ .../remote/BUILD.ferris-says-0.2.1.bazel | 57 +++ .../cargo/remote/BUILD.getrandom-0.1.16.bazel | 153 ++++++ .../remote/BUILD.hermit-abi-0.1.19.bazel | 53 +++ .../cargo/remote/BUILD.libc-0.2.132.bazel | 82 ++++ .../remote/BUILD.ppv-lite86-0.2.16.bazel | 56 +++ .../cargo/remote/BUILD.rand-0.7.3.bazel | 129 ++++++ .../remote/BUILD.rand_chacha-0.2.2.bazel | 57 +++ .../cargo/remote/BUILD.rand_core-0.5.1.bazel | 58 +++ .../cargo/remote/BUILD.rand_hc-0.2.0.bazel | 53 +++ .../cargo/remote/BUILD.rng-0.1.0.bazel | 53 +++ .../cargo/remote/BUILD.smallvec-0.4.5.bazel | 58 +++ .../cargo/remote/BUILD.smawk-0.3.1.bazel | 60 +++ .../cargo/remote/BUILD.strsim-0.8.0.bazel | 56 +++ .../cargo/remote/BUILD.textwrap-0.11.0.bazel | 61 +++ .../cargo/remote/BUILD.textwrap-0.13.4.bazel | 65 +++ .../remote/BUILD.unicode-width-0.1.10.bazel | 55 +++ .../cargo/remote/BUILD.vec_map-0.8.2.bazel | 52 +++ ...LD.wasi-0.9.0+wasi-snapshot-preview1.bazel | 56 +++ .../cargo/remote/BUILD.winapi-0.3.9.bazel | 100 ++++ ...ILD.winapi-i686-pc-windows-gnu-0.4.0.bazel | 80 ++++ ...D.winapi-x86_64-pc-windows-gnu-0.4.0.bazel | 80 ++++ .../parent_directory_workspace/dep/Cargo.toml | 4 + .../dep/rng/BUILD.bazel | 13 + .../dep/rng/Cargo.toml | 7 + .../dep/rng/src/lib.rs | 7 + .../main/Cargo.lock | 234 ++++++++++ .../main/Cargo.toml | 15 + .../main/printer/BUILD.bazel | 11 + .../main/printer/Cargo.toml | 8 + .../main/printer/src/lib.rs | 18 + .../main/remote_num_printer/BUILD.bazel | 13 + .../main/remote_num_printer/Cargo.toml | 13 + .../main/remote_num_printer/src/main.rs | 26 ++ examples/repositories.bzl | 18 +- examples/tests/BUILD.bazel | 1 + impl/src/bin/cargo-raze.rs | 9 +- impl/src/context.rs | 1 + impl/src/metadata.rs | 354 ++++++++++---- impl/src/planning.rs | 2 +- impl/src/planning/crate_catalog.rs | 45 +- impl/src/planning/subplanners.rs | 191 +++++--- .../templates/remote_crates.bzl.template | 13 +- impl/src/settings.rs | 38 ++ tools/examples_repository_tools.sh | 3 +- 60 files changed, 3191 insertions(+), 185 deletions(-) create mode 100644 examples/remote/parent_directory_workspace/cargo/BUILD.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/crates.bzl create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.ansi_term-0.12.1.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.atty-0.2.14.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.bitflags-1.3.2.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.cfg-if-1.0.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.clap-2.34.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.ferris-says-0.2.1.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.getrandom-0.1.16.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.hermit-abi-0.1.19.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.libc-0.2.132.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.ppv-lite86-0.2.16.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand-0.7.3.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_chacha-0.2.2.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_core-0.5.1.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_hc-0.2.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.rng-0.1.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.smallvec-0.4.5.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.smawk-0.3.1.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.strsim-0.8.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.11.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.13.4.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.unicode-width-0.1.10.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.vec_map-0.8.2.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.wasi-0.9.0+wasi-snapshot-preview1.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-0.3.9.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel create mode 100644 examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel create mode 100644 examples/remote/parent_directory_workspace/dep/Cargo.toml create mode 100644 examples/remote/parent_directory_workspace/dep/rng/BUILD.bazel create mode 100644 examples/remote/parent_directory_workspace/dep/rng/Cargo.toml create mode 100644 examples/remote/parent_directory_workspace/dep/rng/src/lib.rs create mode 100644 examples/remote/parent_directory_workspace/main/Cargo.lock create mode 100644 examples/remote/parent_directory_workspace/main/Cargo.toml create mode 100644 examples/remote/parent_directory_workspace/main/printer/BUILD.bazel create mode 100644 examples/remote/parent_directory_workspace/main/printer/Cargo.toml create mode 100644 examples/remote/parent_directory_workspace/main/printer/src/lib.rs create mode 100644 examples/remote/parent_directory_workspace/main/remote_num_printer/BUILD.bazel create mode 100644 examples/remote/parent_directory_workspace/main/remote_num_printer/Cargo.toml create mode 100644 examples/remote/parent_directory_workspace/main/remote_num_printer/src/main.rs diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 571b0e600..f6e19946b 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -14,7 +14,7 @@ examples_repository() load("@cargo_raze_examples//:repositories.bzl", examples_repositories = "repositories") -examples_repositories() +examples_repositories(local_path_prefix = "examples/") load("@rules_rust//tools/rust_analyzer:deps.bzl", "rust_analyzer_deps") diff --git a/examples/remote/binary_dependencies/cargo/crates.bzl b/examples/remote/binary_dependencies/cargo/crates.bzl index b41421031..030f61b53 100644 --- a/examples/remote/binary_dependencies/cargo/crates.bzl +++ b/examples/remote/binary_dependencies/cargo/crates.bzl @@ -167,7 +167,7 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies -def remote_binary_dependencies_fetch_remote_crates(): +def remote_binary_dependencies_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/build_dependencies/cargo/crates.bzl b/examples/remote/build_dependencies/cargo/crates.bzl index 57d0ce073..355a8ac5b 100644 --- a/examples/remote/build_dependencies/cargo/crates.bzl +++ b/examples/remote/build_dependencies/cargo/crates.bzl @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -def remote_build_dependencies_fetch_remote_crates(): +def remote_build_dependencies_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/cargo_workspace/cargo/crates.bzl b/examples/remote/cargo_workspace/cargo/crates.bzl index 4c4d5fc93..a8be4e894 100644 --- a/examples/remote/cargo_workspace/cargo/crates.bzl +++ b/examples/remote/cargo_workspace/cargo/crates.bzl @@ -185,7 +185,7 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies -def remote_cargo_workspace_fetch_remote_crates(): +def remote_cargo_workspace_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/complicated_cargo_library/cargo/crates.bzl b/examples/remote/complicated_cargo_library/cargo/crates.bzl index a5d2b0c47..017388f35 100644 --- a/examples/remote/complicated_cargo_library/cargo/crates.bzl +++ b/examples/remote/complicated_cargo_library/cargo/crates.bzl @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -def remote_complicated_cargo_library_fetch_remote_crates(): +def remote_complicated_cargo_library_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/dev_dependencies/cargo/crates.bzl b/examples/remote/dev_dependencies/cargo/crates.bzl index 4a9adbe99..ccfabb12c 100644 --- a/examples/remote/dev_dependencies/cargo/crates.bzl +++ b/examples/remote/dev_dependencies/cargo/crates.bzl @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -def remote_dev_dependencies_fetch_remote_crates(): +def remote_dev_dependencies_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/no_deps/cargo/crates.bzl b/examples/remote/no_deps/cargo/crates.bzl index c7e4f52dc..1642671fd 100644 --- a/examples/remote/no_deps/cargo/crates.bzl +++ b/examples/remote/no_deps/cargo/crates.bzl @@ -9,6 +9,6 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -def remote_no_deps_fetch_remote_crates(): +def remote_no_deps_fetch_remote_crates(local_path_prefix = ""): """No crates were detected in the source Cargo.toml. This is a no-op""" pass diff --git a/examples/remote/non_cratesio/cargo/crates.bzl b/examples/remote/non_cratesio/cargo/crates.bzl index 753e79976..4e51d6874 100644 --- a/examples/remote/non_cratesio/cargo/crates.bzl +++ b/examples/remote/non_cratesio/cargo/crates.bzl @@ -9,7 +9,7 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -def remote_non_cratesio_fetch_remote_crates(): +def remote_non_cratesio_fetch_remote_crates(local_path_prefix = ""): """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/parent_directory_workspace/cargo/BUILD.bazel b/examples/remote/parent_directory_workspace/cargo/BUILD.bazel new file mode 100644 index 000000000..406c16812 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/BUILD.bazel @@ -0,0 +1,24 @@ +""" +@generated +cargo-raze generated Bazel file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# Export file for Stardoc support +exports_files( + glob([ + "**/*.bazel", + "**/*.bzl", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "srcs", + srcs = glob([ + "**/*.bazel", + "**/*.bzl", + ]), + visibility = ["//visibility:public"], +) diff --git a/examples/remote/parent_directory_workspace/cargo/crates.bzl b/examples/remote/parent_directory_workspace/cargo/crates.bzl new file mode 100644 index 000000000..3803d37f9 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/crates.bzl @@ -0,0 +1,437 @@ +""" +@generated +cargo-raze generated Bazel file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # buildifier: disable=load +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load +load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load + +# EXPERIMENTAL -- MAY CHANGE AT ANY TIME: A mapping of package names to a set of normal dependencies for the Rust targets of that package. +_DEPENDENCIES = { + "remote/parent_directory_workspace/main/printer": { + "ferris-says": "@remote_parent_directory_workspace__ferris_says__0_2_1//:ferris_says", + "rng": "@remote_parent_directory_workspace__rng__0_1_0//:rng", + }, + "remote/parent_directory_workspace/main/remote_num_printer": { + "clap": "@remote_parent_directory_workspace__clap__2_34_0//:clap", + }, +} + +# EXPERIMENTAL -- MAY CHANGE AT ANY TIME: A mapping of package names to a set of proc_macro dependencies for the Rust targets of that package. +_PROC_MACRO_DEPENDENCIES = { + "remote/parent_directory_workspace/main/printer": { + }, + "remote/parent_directory_workspace/main/remote_num_printer": { + }, +} + +# EXPERIMENTAL -- MAY CHANGE AT ANY TIME: A mapping of package names to a set of normal dev dependencies for the Rust targets of that package. +_DEV_DEPENDENCIES = { + "remote/parent_directory_workspace/main/printer": { + }, + "remote/parent_directory_workspace/main/remote_num_printer": { + }, +} + +# EXPERIMENTAL -- MAY CHANGE AT ANY TIME: A mapping of package names to a set of proc_macro dev dependencies for the Rust targets of that package. +_DEV_PROC_MACRO_DEPENDENCIES = { + "remote/parent_directory_workspace/main/printer": { + }, + "remote/parent_directory_workspace/main/remote_num_printer": { + }, +} + +def crate_deps(deps, package_name = None): + """EXPERIMENTAL -- MAY CHANGE AT ANY TIME: Finds the fully qualified label of the requested crates for the package where this macro is called. + + WARNING: This macro is part of an expeirmental API and is subject to change. + + Args: + deps (list): The desired list of crate targets. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()`. + Returns: + list: A list of labels to cargo-raze generated targets (str) + """ + + if not package_name: + package_name = native.package_name() + + # Join both sets of dependencies + dependencies = _flatten_dependency_maps([ + _DEPENDENCIES, + _PROC_MACRO_DEPENDENCIES, + _DEV_DEPENDENCIES, + _DEV_PROC_MACRO_DEPENDENCIES, + ]) + + if not deps: + return [] + + missing_crates = [] + crate_targets = [] + for crate_target in deps: + if crate_target not in dependencies[package_name]: + missing_crates.append(crate_target) + else: + crate_targets.append(dependencies[package_name][crate_target]) + + if missing_crates: + fail("Could not find crates `{}` among dependencies of `{}`. Available dependencies were `{}`".format( + missing_crates, + package_name, + dependencies[package_name], + )) + + return crate_targets + +def all_crate_deps(normal = False, normal_dev = False, proc_macro = False, proc_macro_dev = False, package_name = None): + """EXPERIMENTAL -- MAY CHANGE AT ANY TIME: Finds the fully qualified label of all requested direct crate dependencies \ + for the package where this macro is called. + + If no parameters are set, all normal dependencies are returned. Setting any one flag will + otherwise impact the contents of the returned list. + + Args: + normal (bool, optional): If True, normal dependencies are included in the + output list. Defaults to False. + normal_dev (bool, optional): If True, normla dev dependencies will be + included in the output list. Defaults to False. + proc_macro (bool, optional): If True, proc_macro dependencies are included + in the output list. Defaults to False. + proc_macro_dev (bool, optional): If True, dev proc_macro dependencies are + included in the output list. Defaults to False. + package_name (str, optional): The package name of the set of dependencies to look up. + Defaults to `native.package_name()`. + + Returns: + list: A list of labels to cargo-raze generated targets (str) + """ + + if not package_name: + package_name = native.package_name() + + # Determine the relevant maps to use + all_dependency_maps = [] + if normal: + all_dependency_maps.append(_DEPENDENCIES) + if normal_dev: + all_dependency_maps.append(_DEV_DEPENDENCIES) + if proc_macro: + all_dependency_maps.append(_PROC_MACRO_DEPENDENCIES) + if proc_macro_dev: + all_dependency_maps.append(_DEV_PROC_MACRO_DEPENDENCIES) + + # Default to always using normal dependencies + if not all_dependency_maps: + all_dependency_maps.append(_DEPENDENCIES) + + dependencies = _flatten_dependency_maps(all_dependency_maps) + + if not dependencies: + return [] + + return dependencies[package_name].values() + +def _flatten_dependency_maps(all_dependency_maps): + """Flatten a list of dependency maps into one dictionary. + + Dependency maps have the following structure: + + ```python + DEPENDENCIES_MAP = { + # The first key in the map is a Bazel package + # name of the workspace this file is defined in. + "package_name": { + + # An alias to a crate target. # The label of the crate target the + # Aliases are only crate names. # alias refers to. + "alias": "@full//:label", + } + } + ``` + + Args: + all_dependency_maps (list): A list of dicts as described above + + Returns: + dict: A dictionary as described above + """ + dependencies = {} + + for dep_map in all_dependency_maps: + for pkg_name in dep_map: + if pkg_name not in dependencies: + # Add a non-frozen dict to the collection of dependencies + dependencies.setdefault(pkg_name, dict(dep_map[pkg_name].items())) + continue + + duplicate_crate_aliases = [key for key in dependencies[pkg_name] if key in dep_map[pkg_name]] + if duplicate_crate_aliases: + fail("There should be no duplicate crate aliases: {}".format(duplicate_crate_aliases)) + + dependencies[pkg_name].update(dep_map[pkg_name]) + + return dependencies + +def remote_parent_directory_workspace_fetch_remote_crates(local_path_prefix = ""): + """This function defines a collection of repos and should be called in a WORKSPACE file""" + maybe( + http_archive, + name = "remote_parent_directory_workspace__ansi_term__0_12_1", + url = "https://crates.io/api/v1/crates/ansi_term/0.12.1/download", + type = "tar.gz", + sha256 = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2", + strip_prefix = "ansi_term-0.12.1", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.ansi_term-0.12.1.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__atty__0_2_14", + url = "https://crates.io/api/v1/crates/atty/0.2.14/download", + type = "tar.gz", + sha256 = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8", + strip_prefix = "atty-0.2.14", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.atty-0.2.14.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__bitflags__1_3_2", + url = "https://crates.io/api/v1/crates/bitflags/1.3.2/download", + type = "tar.gz", + sha256 = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a", + strip_prefix = "bitflags-1.3.2", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.bitflags-1.3.2.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__cfg_if__1_0_0", + url = "https://crates.io/api/v1/crates/cfg-if/1.0.0/download", + type = "tar.gz", + sha256 = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd", + strip_prefix = "cfg-if-1.0.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.cfg-if-1.0.0.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__clap__2_34_0", + url = "https://crates.io/api/v1/crates/clap/2.34.0/download", + type = "tar.gz", + sha256 = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c", + strip_prefix = "clap-2.34.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.clap-2.34.0.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__ferris_says__0_2_1", + url = "https://crates.io/api/v1/crates/ferris-says/0.2.1/download", + type = "tar.gz", + sha256 = "9515ec2dd9606ec230f6b2d1f25fd9e808a2f2af600143f7efe7e5865505b7aa", + strip_prefix = "ferris-says-0.2.1", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.ferris-says-0.2.1.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__getrandom__0_1_16", + url = "https://crates.io/api/v1/crates/getrandom/0.1.16/download", + type = "tar.gz", + sha256 = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce", + strip_prefix = "getrandom-0.1.16", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.getrandom-0.1.16.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__hermit_abi__0_1_19", + url = "https://crates.io/api/v1/crates/hermit-abi/0.1.19/download", + type = "tar.gz", + sha256 = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33", + strip_prefix = "hermit-abi-0.1.19", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.hermit-abi-0.1.19.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__libc__0_2_132", + url = "https://crates.io/api/v1/crates/libc/0.2.132/download", + type = "tar.gz", + sha256 = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5", + strip_prefix = "libc-0.2.132", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.libc-0.2.132.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__ppv_lite86__0_2_16", + url = "https://crates.io/api/v1/crates/ppv-lite86/0.2.16/download", + type = "tar.gz", + sha256 = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872", + strip_prefix = "ppv-lite86-0.2.16", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.ppv-lite86-0.2.16.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__rand__0_7_3", + url = "https://crates.io/api/v1/crates/rand/0.7.3/download", + type = "tar.gz", + sha256 = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03", + strip_prefix = "rand-0.7.3", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.rand-0.7.3.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__rand_chacha__0_2_2", + url = "https://crates.io/api/v1/crates/rand_chacha/0.2.2/download", + type = "tar.gz", + sha256 = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402", + strip_prefix = "rand_chacha-0.2.2", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.rand_chacha-0.2.2.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__rand_core__0_5_1", + url = "https://crates.io/api/v1/crates/rand_core/0.5.1/download", + type = "tar.gz", + sha256 = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19", + strip_prefix = "rand_core-0.5.1", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.rand_core-0.5.1.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__rand_hc__0_2_0", + url = "https://crates.io/api/v1/crates/rand_hc/0.2.0/download", + type = "tar.gz", + sha256 = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c", + strip_prefix = "rand_hc-0.2.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.rand_hc-0.2.0.bazel"), + ) + + maybe( + native.new_local_repository, + name = "remote_parent_directory_workspace__rng__0_1_0", + path = local_path_prefix + "remote/parent_directory_workspace/dep/rng", + build_file = local_path_prefix + "//remote/parent_directory_workspace/cargo/remote/BUILD.rng-0.1.0.bazel".strip("/"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__smallvec__0_4_5", + url = "https://crates.io/api/v1/crates/smallvec/0.4.5/download", + type = "tar.gz", + sha256 = "f90c5e5fe535e48807ab94fc611d323935f39d4660c52b26b96446a7b33aef10", + strip_prefix = "smallvec-0.4.5", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.smallvec-0.4.5.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__smawk__0_3_1", + url = "https://crates.io/api/v1/crates/smawk/0.3.1/download", + type = "tar.gz", + sha256 = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043", + strip_prefix = "smawk-0.3.1", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.smawk-0.3.1.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__strsim__0_8_0", + url = "https://crates.io/api/v1/crates/strsim/0.8.0/download", + type = "tar.gz", + sha256 = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a", + strip_prefix = "strsim-0.8.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.strsim-0.8.0.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__textwrap__0_11_0", + url = "https://crates.io/api/v1/crates/textwrap/0.11.0/download", + type = "tar.gz", + sha256 = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060", + strip_prefix = "textwrap-0.11.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.textwrap-0.11.0.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__textwrap__0_13_4", + url = "https://crates.io/api/v1/crates/textwrap/0.13.4/download", + type = "tar.gz", + sha256 = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835", + strip_prefix = "textwrap-0.13.4", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.textwrap-0.13.4.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__unicode_width__0_1_10", + url = "https://crates.io/api/v1/crates/unicode-width/0.1.10/download", + type = "tar.gz", + sha256 = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b", + strip_prefix = "unicode-width-0.1.10", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.unicode-width-0.1.10.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__vec_map__0_8_2", + url = "https://crates.io/api/v1/crates/vec_map/0.8.2/download", + type = "tar.gz", + sha256 = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191", + strip_prefix = "vec_map-0.8.2", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.vec_map-0.8.2.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__wasi__0_9_0_wasi_snapshot_preview1", + url = "https://crates.io/api/v1/crates/wasi/0.9.0+wasi-snapshot-preview1/download", + type = "tar.gz", + sha256 = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519", + strip_prefix = "wasi-0.9.0+wasi-snapshot-preview1", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.wasi-0.9.0+wasi-snapshot-preview1.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__winapi__0_3_9", + url = "https://crates.io/api/v1/crates/winapi/0.3.9/download", + type = "tar.gz", + sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419", + strip_prefix = "winapi-0.3.9", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.winapi-0.3.9.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__winapi_i686_pc_windows_gnu__0_4_0", + url = "https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/0.4.0/download", + type = "tar.gz", + sha256 = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6", + strip_prefix = "winapi-i686-pc-windows-gnu-0.4.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel"), + ) + + maybe( + http_archive, + name = "remote_parent_directory_workspace__winapi_x86_64_pc_windows_gnu__0_4_0", + url = "https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gnu/0.4.0/download", + type = "tar.gz", + sha256 = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f", + strip_prefix = "winapi-x86_64-pc-windows-gnu-0.4.0", + build_file = Label("//remote/parent_directory_workspace/cargo/remote:BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel"), + ) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ansi_term-0.12.1.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ansi_term-0.12.1.bazel new file mode 100644 index 000000000..598a21918 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ansi_term-0.12.1.bazel @@ -0,0 +1,68 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "256_colours" with type "example" omitted + +# Unsupported target "basic_colours" with type "example" omitted + +# Unsupported target "rgb_colours" with type "example" omitted + +rust_library( + name = "ansi_term", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=ansi_term", + "manual", + ], + version = "0.12.1", + # buildifier: leave-alone + deps = [ + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@remote_parent_directory_workspace__winapi__0_3_9//:winapi", + ], + "//conditions:default": [], + }), +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.atty-0.2.14.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.atty-0.2.14.bazel new file mode 100644 index 000000000..03a66a761 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.atty-0.2.14.bazel @@ -0,0 +1,88 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "atty" with type "example" omitted + +rust_library( + name = "atty", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=atty", + "manual", + ], + version = "0.2.14", + # buildifier: leave-alone + deps = [ + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + "@remote_parent_directory_workspace__libc__0_2_132//:libc", + ], + "//conditions:default": [], + }) + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + ): [ + "@remote_parent_directory_workspace__winapi__0_3_9//:winapi", + ], + "//conditions:default": [], + }), +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bazel new file mode 100644 index 000000000..b49fb6866 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bazel @@ -0,0 +1,17 @@ +# Export file for Stardoc support +exports_files( + glob([ + "**/*.bazel", + "**/*.bzl", + ]), + visibility = ["//visibility:public"], +) + +filegroup( + name = "srcs", + srcs = glob([ + "**/*.bazel", + "**/*.bzl", + ]), + visibility = ["//visibility:public"], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bitflags-1.3.2.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bitflags-1.3.2.bazel new file mode 100644 index 000000000..7bf8a1365 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.bitflags-1.3.2.bazel @@ -0,0 +1,59 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "bitflags", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=bitflags", + "manual", + ], + version = "1.3.2", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "basic" with type "test" omitted + +# Unsupported target "compile" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.cfg-if-1.0.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.cfg-if-1.0.0.bazel new file mode 100644 index 000000000..c74a53d3c --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.cfg-if-1.0.0.bazel @@ -0,0 +1,54 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "cfg_if", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=cfg-if", + "manual", + ], + version = "1.0.0", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "xcrate" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.clap-2.34.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.clap-2.34.0.bazel new file mode 100644 index 000000000..42cd2df0f --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.clap-2.34.0.bazel @@ -0,0 +1,95 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "clap", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + "ansi_term", + "atty", + "color", + "default", + "strsim", + "suggestions", + "vec_map", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=clap", + "manual", + ], + version = "2.34.0", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__atty__0_2_14//:atty", + "@remote_parent_directory_workspace__bitflags__1_3_2//:bitflags", + "@remote_parent_directory_workspace__strsim__0_8_0//:strsim", + "@remote_parent_directory_workspace__textwrap__0_11_0//:textwrap", + "@remote_parent_directory_workspace__unicode_width__0_1_10//:unicode_width", + "@remote_parent_directory_workspace__vec_map__0_8_2//:vec_map", + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:wasm32-unknown-unknown", + "@rules_rust//rust/platform:wasm32-wasi", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + "@remote_parent_directory_workspace__ansi_term__0_12_1//:ansi_term", + ], + "//conditions:default": [], + }), +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ferris-says-0.2.1.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ferris-says-0.2.1.bazel new file mode 100644 index 000000000..0212b29b1 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ferris-says-0.2.1.bazel @@ -0,0 +1,57 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "ferris_says", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=ferris_says", + "manual", + ], + version = "0.2.1", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__smallvec__0_4_5//:smallvec", + "@remote_parent_directory_workspace__textwrap__0_13_4//:textwrap", + "@remote_parent_directory_workspace__unicode_width__0_1_10//:unicode_width", + ], +) + +# Unsupported target "integration_test" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.getrandom-0.1.16.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.getrandom-0.1.16.bazel new file mode 100644 index 000000000..425f5cfbd --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.getrandom-0.1.16.bazel @@ -0,0 +1,153 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "getrandom_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "std", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.1.16", + visibility = ["//visibility:private"], + deps = [ + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:wasm32-wasi", + ): [ + ], + "//conditions:default": [], + }) + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + ], + "//conditions:default": [], + }), +) + +# Unsupported target "mod" with type "bench" omitted + +rust_library( + name = "getrandom", + srcs = glob(["**/*.rs"]), + aliases = { + }, + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=getrandom", + "manual", + ], + version = "0.1.16", + # buildifier: leave-alone + deps = [ + ":getrandom_build_script", + "@remote_parent_directory_workspace__cfg_if__1_0_0//:cfg_if", + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:wasm32-wasi", + ): [ + "@remote_parent_directory_workspace__wasi__0_9_0_wasi_snapshot_preview1//:wasi", + ], + "//conditions:default": [], + }) + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + "@remote_parent_directory_workspace__libc__0_2_132//:libc", + ], + "//conditions:default": [], + }), +) + +# Unsupported target "common" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.hermit-abi-0.1.19.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.hermit-abi-0.1.19.bazel new file mode 100644 index 000000000..afd88a848 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.hermit-abi-0.1.19.bazel @@ -0,0 +1,53 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "hermit_abi", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=hermit-abi", + "manual", + ], + version = "0.1.19", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__libc__0_2_132//:libc", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.libc-0.2.132.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.libc-0.2.132.bazel new file mode 100644 index 000000000..e36db3646 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.libc-0.2.132.bazel @@ -0,0 +1,82 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "libc_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.2.132", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "libc", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=libc", + "manual", + ], + version = "0.2.132", + # buildifier: leave-alone + deps = [ + ":libc_build_script", + ], +) + +# Unsupported target "const_fn" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ppv-lite86-0.2.16.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ppv-lite86-0.2.16.bazel new file mode 100644 index 000000000..e54da628f --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.ppv-lite86-0.2.16.bazel @@ -0,0 +1,56 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "ppv_lite86", + srcs = glob(["**/*.rs"]), + crate_features = [ + "simd", + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=ppv-lite86", + "manual", + ], + version = "0.2.16", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand-0.7.3.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand-0.7.3.bazel new file mode 100644 index 000000000..bd4d6b694 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand-0.7.3.bazel @@ -0,0 +1,129 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +# Unsupported target "generators" with type "bench" omitted + +# Unsupported target "misc" with type "bench" omitted + +# Unsupported target "seq" with type "bench" omitted + +# Unsupported target "weighted" with type "bench" omitted + +# Unsupported target "monte-carlo" with type "example" omitted + +# Unsupported target "monty-hall" with type "example" omitted + +rust_library( + name = "rand", + srcs = glob(["**/*.rs"]), + aliases = { + "@remote_parent_directory_workspace__getrandom__0_1_16//:getrandom": "getrandom_package", + }, + crate_features = [ + "alloc", + "default", + "getrandom", + "getrandom_package", + "libc", + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=rand", + "manual", + ], + version = "0.7.3", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__getrandom__0_1_16//:getrandom", + "@remote_parent_directory_workspace__rand_core__0_5_1//:rand_core", + ] + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-pc-windows-msvc", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-pc-windows-msvc", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:wasm32-unknown-unknown", + "@rules_rust//rust/platform:wasm32-wasi", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + "@remote_parent_directory_workspace__rand_chacha__0_2_2//:rand_chacha", + ], + "//conditions:default": [], + }) + selects.with_or({ + ( + "@rules_rust//rust/platform:i686-apple-darwin", + "@rules_rust//rust/platform:i686-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-darwin", + "@rules_rust//rust/platform:x86_64-unknown-linux-gnu", + "@rules_rust//rust/platform:aarch64-apple-darwin", + "@rules_rust//rust/platform:aarch64-apple-ios", + "@rules_rust//rust/platform:aarch64-apple-ios-sim", + "@rules_rust//rust/platform:aarch64-linux-android", + "@rules_rust//rust/platform:aarch64-unknown-linux-gnu", + "@rules_rust//rust/platform:arm-unknown-linux-gnueabi", + "@rules_rust//rust/platform:armv7-linux-androideabi", + "@rules_rust//rust/platform:i686-linux-android", + "@rules_rust//rust/platform:i686-unknown-freebsd", + "@rules_rust//rust/platform:powerpc-unknown-linux-gnu", + "@rules_rust//rust/platform:s390x-unknown-linux-gnu", + "@rules_rust//rust/platform:x86_64-apple-ios", + "@rules_rust//rust/platform:x86_64-linux-android", + "@rules_rust//rust/platform:x86_64-unknown-freebsd", + ): [ + "@remote_parent_directory_workspace__libc__0_2_132//:libc", + ], + "//conditions:default": [], + }), +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_chacha-0.2.2.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_chacha-0.2.2.bazel new file mode 100644 index 000000000..6e0f642f8 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_chacha-0.2.2.bazel @@ -0,0 +1,57 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "rand_chacha", + srcs = glob(["**/*.rs"]), + crate_features = [ + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=rand_chacha", + "manual", + ], + version = "0.2.2", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__ppv_lite86__0_2_16//:ppv_lite86", + "@remote_parent_directory_workspace__rand_core__0_5_1//:rand_core", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_core-0.5.1.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_core-0.5.1.bazel new file mode 100644 index 000000000..ad5a48bba --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_core-0.5.1.bazel @@ -0,0 +1,58 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "rand_core", + srcs = glob(["**/*.rs"]), + crate_features = [ + "alloc", + "getrandom", + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=rand_core", + "manual", + ], + version = "0.5.1", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__getrandom__0_1_16//:getrandom", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_hc-0.2.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_hc-0.2.0.bazel new file mode 100644 index 000000000..ca1d1d24f --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rand_hc-0.2.0.bazel @@ -0,0 +1,53 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "rand_hc", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=rand_hc", + "manual", + ], + version = "0.2.0", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__rand_core__0_5_1//:rand_core", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rng-0.1.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rng-0.1.0.bazel new file mode 100644 index 000000000..139a33e09 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.rng-0.1.0.bazel @@ -0,0 +1,53 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "restricted", # no license +]) + +# Generated Targets + +rust_library( + name = "rng", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=rng", + "manual", + ], + version = "0.1.0", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__rand__0_7_3//:rand", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smallvec-0.4.5.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smallvec-0.4.5.bazel new file mode 100644 index 000000000..ca9e6ee7c --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smallvec-0.4.5.bazel @@ -0,0 +1,58 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "reciprocal", # MPL-2.0 from expression "MPL-2.0" +]) + +# Generated Targets + +# Unsupported target "bench" with type "bench" omitted + +rust_library( + name = "smallvec", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "std", + ], + crate_root = "lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=smallvec", + "manual", + ], + version = "0.4.5", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smawk-0.3.1.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smawk-0.3.1.bazel new file mode 100644 index 000000000..9b6077efe --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.smawk-0.3.1.bazel @@ -0,0 +1,60 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +rust_library( + name = "smawk", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=smawk", + "manual", + ], + version = "0.3.1", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "agreement" with type "test" omitted + +# Unsupported target "complexity" with type "test" omitted + +# Unsupported target "monge" with type "test" omitted + +# Unsupported target "version-numbers" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.strsim-0.8.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.strsim-0.8.0.bazel new file mode 100644 index 000000000..55006dd97 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.strsim-0.8.0.bazel @@ -0,0 +1,56 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "benches" with type "bench" omitted + +rust_library( + name = "strsim", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=strsim", + "manual", + ], + version = "0.8.0", + # buildifier: leave-alone + deps = [ + ], +) + +# Unsupported target "lib" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.11.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.11.0.bazel new file mode 100644 index 000000000..f6692da06 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.11.0.bazel @@ -0,0 +1,61 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "linear" with type "bench" omitted + +# Unsupported target "layout" with type "example" omitted + +# Unsupported target "termwidth" with type "example" omitted + +rust_library( + name = "textwrap", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=textwrap", + "manual", + ], + version = "0.11.0", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__unicode_width__0_1_10//:unicode_width", + ], +) + +# Unsupported target "version-numbers" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.13.4.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.13.4.bazel new file mode 100644 index 000000000..81ffb6143 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.textwrap-0.13.4.bazel @@ -0,0 +1,65 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT" +]) + +# Generated Targets + +# Unsupported target "linear" with type "bench" omitted + +rust_library( + name = "textwrap", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "smawk", + "unicode-width", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=textwrap", + "manual", + ], + version = "0.13.4", + # buildifier: leave-alone + deps = [ + "@remote_parent_directory_workspace__smawk__0_3_1//:smawk", + "@remote_parent_directory_workspace__unicode_width__0_1_10//:unicode_width", + ], +) + +# Unsupported target "indent" with type "test" omitted + +# Unsupported target "version-numbers" with type "test" omitted diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.unicode-width-0.1.10.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.unicode-width-0.1.10.bazel new file mode 100644 index 000000000..4e6715732 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.unicode-width-0.1.10.bazel @@ -0,0 +1,55 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "unicode_width", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=unicode-width", + "manual", + ], + version = "0.1.10", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.vec_map-0.8.2.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.vec_map-0.8.2.bazel new file mode 100644 index 000000000..64f102588 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.vec_map-0.8.2.bazel @@ -0,0 +1,52 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets + +rust_library( + name = "vec_map", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=vec_map", + "manual", + ], + version = "0.8.2", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.wasi-0.9.0+wasi-snapshot-preview1.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.wasi-0.9.0+wasi-snapshot-preview1.bazel new file mode 100644 index 000000000..8646545af --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.wasi-0.9.0+wasi-snapshot-preview1.bazel @@ -0,0 +1,56 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # Apache-2.0 from expression "Apache-2.0 OR (Apache-2.0 OR MIT)" +]) + +# Generated Targets + +rust_library( + name = "wasi", + srcs = glob(["**/*.rs"]), + crate_features = [ + "default", + "std", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2018", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=wasi", + "manual", + ], + version = "0.9.0+wasi-snapshot-preview1", + # buildifier: leave-alone + deps = [ + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-0.3.9.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-0.3.9.bazel new file mode 100644 index 000000000..019900d38 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-0.3.9.bazel @@ -0,0 +1,100 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_features = [ + "consoleapi", + "errhandlingapi", + "fileapi", + "handleapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.3.9", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi", + srcs = glob(["**/*.rs"]), + crate_features = [ + "consoleapi", + "errhandlingapi", + "fileapi", + "handleapi", + "minwinbase", + "minwindef", + "processenv", + "winbase", + ], + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=winapi", + "manual", + ], + version = "0.3.9", + # buildifier: leave-alone + deps = [ + ":winapi_build_script", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 000000000..b3007741d --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-i686-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,80 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_i686_pc_windows_gnu_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi_i686_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=winapi-i686-pc-windows-gnu", + "manual", + ], + version = "0.4.0", + # buildifier: leave-alone + deps = [ + ":winapi_i686_pc_windows_gnu_build_script", + ], +) diff --git a/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel new file mode 100644 index 000000000..34278f6d3 --- /dev/null +++ b/examples/remote/parent_directory_workspace/cargo/remote/BUILD.winapi-x86_64-pc-windows-gnu-0.4.0.bazel @@ -0,0 +1,80 @@ +""" +@generated +cargo-raze crate build file. + +DO NOT EDIT! Replaced on runs of cargo-raze +""" + +# buildifier: disable=load +load("@bazel_skylib//lib:selects.bzl", "selects") + +# buildifier: disable=load +load( + "@rules_rust//rust:defs.bzl", + "rust_binary", + "rust_library", + "rust_proc_macro", + "rust_test", +) + +package(default_visibility = [ + # Public for visibility by "@raze__crate__version//" targets. + # + # Prefer access through "//remote/parent_directory_workspace/cargo", which limits external + # visibility to explicit Cargo.toml dependencies. + "//visibility:public", +]) + +licenses([ + "notice", # MIT from expression "MIT OR Apache-2.0" +]) + +# Generated Targets +# buildifier: disable=out-of-order-load +# buildifier: disable=load-on-top +load( + "@rules_rust//cargo:cargo_build_script.bzl", + "cargo_build_script", +) + +cargo_build_script( + name = "winapi_x86_64_pc_windows_gnu_build_script", + srcs = glob(["**/*.rs"]), + build_script_env = { + }, + crate_root = "build.rs", + data = glob(["**"]), + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "manual", + ], + version = "0.4.0", + visibility = ["//visibility:private"], + deps = [ + ], +) + +rust_library( + name = "winapi_x86_64_pc_windows_gnu", + srcs = glob(["**/*.rs"]), + crate_root = "src/lib.rs", + data = [], + edition = "2015", + rustc_flags = [ + "--cap-lints=allow", + ], + tags = [ + "cargo-raze", + "crate-name=winapi-x86_64-pc-windows-gnu", + "manual", + ], + version = "0.4.0", + # buildifier: leave-alone + deps = [ + ":winapi_x86_64_pc_windows_gnu_build_script", + ], +) diff --git a/examples/remote/parent_directory_workspace/dep/Cargo.toml b/examples/remote/parent_directory_workspace/dep/Cargo.toml new file mode 100644 index 000000000..5d045a0b0 --- /dev/null +++ b/examples/remote/parent_directory_workspace/dep/Cargo.toml @@ -0,0 +1,4 @@ +[workspace] +members = [ + "rng", +] diff --git a/examples/remote/parent_directory_workspace/dep/rng/BUILD.bazel b/examples/remote/parent_directory_workspace/dep/rng/BUILD.bazel new file mode 100644 index 000000000..eb99f790b --- /dev/null +++ b/examples/remote/parent_directory_workspace/dep/rng/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_rust//rust:defs.bzl", "rust_library") +load("//remote/parent_directory/workspace/cargo:crates.bzl", "crate_deps") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "rng", + srcs = ["src/lib.rs"], + edition = "2018", + deps = crate_deps([ + "rand", + ]), +) diff --git a/examples/remote/parent_directory_workspace/dep/rng/Cargo.toml b/examples/remote/parent_directory_workspace/dep/rng/Cargo.toml new file mode 100644 index 000000000..a2a098c9e --- /dev/null +++ b/examples/remote/parent_directory_workspace/dep/rng/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "rng" +version = "0.1.0" +edition = "2018" + +[dependencies] +rand = "0.7.3" diff --git a/examples/remote/parent_directory_workspace/dep/rng/src/lib.rs b/examples/remote/parent_directory_workspace/dep/rng/src/lib.rs new file mode 100644 index 000000000..a50e0a2ec --- /dev/null +++ b/examples/remote/parent_directory_workspace/dep/rng/src/lib.rs @@ -0,0 +1,7 @@ +use rand::{thread_rng, Rng}; + +/// Generate a random number +pub fn random_number() -> i32 { + let mut rng = thread_rng(); + rng.gen() +} diff --git a/examples/remote/parent_directory_workspace/main/Cargo.lock b/examples/remote/parent_directory_workspace/main/Cargo.lock new file mode 100644 index 000000000..575c8e978 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/Cargo.lock @@ -0,0 +1,234 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap 0.11.0", + "unicode-width", + "vec_map", +] + +[[package]] +name = "ferris-says" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9515ec2dd9606ec230f6b2d1f25fd9e808a2f2af600143f7efe7e5865505b7aa" +dependencies = [ + "smallvec", + "textwrap 0.13.4", + "unicode-width", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "printer" +version = "0.1.0" +dependencies = [ + "ferris-says", + "rng", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "remote_num_printer" +version = "0.1.0" +dependencies = [ + "clap", + "printer", +] + +[[package]] +name = "rng" +version = "0.1.0" +dependencies = [ + "rand", +] + +[[package]] +name = "smallvec" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90c5e5fe535e48807ab94fc611d323935f39d4660c52b26b96446a7b33aef10" + +[[package]] +name = "smawk" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f67ad224767faa3c7d8b6d91985b78e70a1324408abcb1cfcc2be4c06bc06043" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "textwrap" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd05616119e612a8041ef58f2b578906cc2531a6069047ae092cfb86a325d835" +dependencies = [ + "smawk", + "unicode-width", +] + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/examples/remote/parent_directory_workspace/main/Cargo.toml b/examples/remote/parent_directory_workspace/main/Cargo.toml new file mode 100644 index 000000000..ce2eac5a4 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/Cargo.toml @@ -0,0 +1,15 @@ +[workspace] +members = [ + "printer", + "remote_num_printer", +] + +[workspace.metadata.raze] +workspace_path = "//remote/parent_directory_workspace/cargo" +bazel_workspace_path = "remote/parent_directory_workspace" +additional_workspace_paths = ["../dep"] +gen_workspace_prefix = "remote_parent_directory_workspace" +genmode = "Remote" +default_gen_buildrs = true +experimental_api = true +render_package_aliases = false diff --git a/examples/remote/parent_directory_workspace/main/printer/BUILD.bazel b/examples/remote/parent_directory_workspace/main/printer/BUILD.bazel new file mode 100644 index 000000000..ad76cbf5b --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/printer/BUILD.bazel @@ -0,0 +1,11 @@ +load("@rules_rust//rust:defs.bzl", "rust_library") +load("//remote/parent_directory_workspace/cargo:crates.bzl", "all_crate_deps") + +package(default_visibility = ["//visibility:public"]) + +rust_library( + name = "printer", + srcs = ["src/lib.rs"], + edition = "2018", + deps = all_crate_deps(), +) diff --git a/examples/remote/parent_directory_workspace/main/printer/Cargo.toml b/examples/remote/parent_directory_workspace/main/printer/Cargo.toml new file mode 100644 index 000000000..b29105e7e --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/printer/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "printer" +version = "0.1.0" +edition = "2018" + +[dependencies] +rng = { path = "../../dep/rng" } +ferris-says = "0.2.0" diff --git a/examples/remote/parent_directory_workspace/main/printer/src/lib.rs b/examples/remote/parent_directory_workspace/main/printer/src/lib.rs new file mode 100644 index 000000000..c76741ce4 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/printer/src/lib.rs @@ -0,0 +1,18 @@ +use ferris_says; + +use std::io::{stdout, BufWriter}; + +use rng; + +/// Have ferris say a number +pub fn print_number(num: i32) { + let number = format!("{}", num); + let stdout = stdout(); + let mut writer = BufWriter::new(stdout.lock()); + ferris_says::say(number.as_bytes(), number.len(), &mut writer).unwrap(); +} + +/// Have ferris say a random number +pub fn print_random_number() { + print_number(rng::random_number()); +} diff --git a/examples/remote/parent_directory_workspace/main/remote_num_printer/BUILD.bazel b/examples/remote/parent_directory_workspace/main/remote_num_printer/BUILD.bazel new file mode 100644 index 000000000..a887549d8 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/remote_num_printer/BUILD.bazel @@ -0,0 +1,13 @@ +load("@rules_rust//rust:defs.bzl", "rust_binary") +load("//remote/parent_directory_workspace/cargo:crates.bzl", "all_crate_deps") + +package(default_visibility = ["//visibility:public"]) + +rust_binary( + name = "remote_number_printer", + srcs = ["src/main.rs"], + edition = "2018", + deps = [ + "//remote/parent_directory_workspace/main/printer", + ] + all_crate_deps(), +) diff --git a/examples/remote/parent_directory_workspace/main/remote_num_printer/Cargo.toml b/examples/remote/parent_directory_workspace/main/remote_num_printer/Cargo.toml new file mode 100644 index 000000000..0b1a01d62 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/remote_num_printer/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "remote_num_printer" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[[bin]] +name = "remote-number-printer" +path = "src/main.rs" + +[dependencies] +clap = "2.33.3" +printer = { path = "../printer" } diff --git a/examples/remote/parent_directory_workspace/main/remote_num_printer/src/main.rs b/examples/remote/parent_directory_workspace/main/remote_num_printer/src/main.rs new file mode 100644 index 000000000..0a8971257 --- /dev/null +++ b/examples/remote/parent_directory_workspace/main/remote_num_printer/src/main.rs @@ -0,0 +1,26 @@ +use clap::{App, Arg}; + +use printer; + +fn main() { + let matches = App::new("Number Printer") + .about("Print some numbers") + .arg(Arg::with_name("rng").help("Print a random number")) + .arg( + Arg::with_name("num") + .help("Print this number") + .takes_value(true), + ) + .get_matches(); + + let num = match matches.value_of("num") { + Some(value) => value.parse::().unwrap(), + None => 1337, + }; + + if matches.is_present("rng") { + printer::print_random_number(); + } else { + printer::print_number(num); + } +} diff --git a/examples/repositories.bzl b/examples/repositories.bzl index 71ecc2811..934269357 100644 --- a/examples/repositories.bzl +++ b/examples/repositories.bzl @@ -3,17 +3,19 @@ load("@cargo_raze_examples//remote/binary_dependencies/cargo:crates.bzl", "remote_binary_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/build_dependencies/cargo:crates.bzl", "remote_build_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/cargo_workspace/cargo:crates.bzl", "remote_cargo_workspace_fetch_remote_crates") +load("@cargo_raze_examples//remote/parent_directory_workspace/cargo:crates.bzl", "remote_parent_directory_workspace_fetch_remote_crates") load("@cargo_raze_examples//remote/complicated_cargo_library/cargo:crates.bzl", "remote_complicated_cargo_library_fetch_remote_crates") load("@cargo_raze_examples//remote/dev_dependencies/cargo:crates.bzl", "remote_dev_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/no_deps/cargo:crates.bzl", "remote_no_deps_fetch_remote_crates") load("@cargo_raze_examples//remote/non_cratesio/cargo:crates.bzl", "remote_non_cratesio_fetch_remote_crates") -def repositories(): +def repositories(local_path_prefix = None): """Defines all the cargo dependencies of the Cargo-raze examples""" - remote_binary_dependencies_fetch_remote_crates() - remote_cargo_workspace_fetch_remote_crates() - remote_complicated_cargo_library_fetch_remote_crates() - remote_no_deps_fetch_remote_crates() - remote_non_cratesio_fetch_remote_crates() - remote_dev_dependencies_fetch_remote_crates() - remote_build_dependencies_fetch_remote_crates() + remote_binary_dependencies_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_cargo_workspace_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_parent_directory_workspace_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_complicated_cargo_library_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_no_deps_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_non_cratesio_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_dev_dependencies_fetch_remote_crates(local_path_prefix = local_path_prefix) + remote_build_dependencies_fetch_remote_crates(local_path_prefix = local_path_prefix) diff --git a/examples/tests/BUILD.bazel b/examples/tests/BUILD.bazel index 1f721db60..20c4c4766 100644 --- a/examples/tests/BUILD.bazel +++ b/examples/tests/BUILD.bazel @@ -10,6 +10,7 @@ test_suite( tests = [ launch_test(target = "@cargo_raze_examples//remote/binary_dependencies:binary_dependencies_bin"), launch_test(target = "@cargo_raze_examples//remote/cargo_workspace/num_printer:number_printer"), + launch_test(target = "@cargo_raze_examples//remote/parent_directory_workspace/main/remote_num_printer:remote_number_printer"), launch_test(target = "@cargo_raze_examples//remote/complicated_cargo_library"), launch_test(target = "@cargo_raze_examples//remote/no_deps"), launch_test(target = "@cargo_raze_examples//remote/non_cratesio:non_cratesio_remote"), diff --git a/impl/src/bin/cargo-raze.rs b/impl/src/bin/cargo-raze.rs index c0d693e58..a77f7ef5f 100644 --- a/impl/src/bin/cargo-raze.rs +++ b/impl/src/bin/cargo-raze.rs @@ -209,8 +209,15 @@ fn fetch_raze_metadata( None }; + let cargo_workspace_root = &local_metadata.workspace_root; + let additional_workspaces: Vec<_> = settings + .additional_workspace_paths + .iter() + .map(|path| cargo_workspace_root.join(path)) + .collect(); let raze_metadata = metadata_fetcher.fetch_metadata( - local_metadata.workspace_root.as_ref(), + cargo_workspace_root.as_ref(), + &additional_workspaces, binary_dep_info, reused_lockfile, )?; diff --git a/impl/src/context.rs b/impl/src/context.rs index a0482a927..34dd4dc8a 100644 --- a/impl/src/context.rs +++ b/impl/src/context.rs @@ -82,6 +82,7 @@ pub struct GitRepo { pub struct SourceDetails { pub git_data: Option, pub download_url: Option, + pub local_repository_path: Option, } #[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)] diff --git a/impl/src/metadata.rs b/impl/src/metadata.rs index 80fc9f256..fe5f586d4 100644 --- a/impl/src/metadata.rs +++ b/impl/src/metadata.rs @@ -114,17 +114,33 @@ impl LockfileGenerator for CargoLockfileGenerator { } } +/// A struct containing all metadata about an additional Cargo workspace +#[derive(Debug, Clone)] +pub struct AdditionalWorkspaceMetadata { + pub metadata: Metadata, + /// Relative path to this workspace from the main Cargo workspace + pub relative_path: Utf8PathBuf, + /// The path to this workspace in the temporary directory. + pub temp_dir_path: Utf8PathBuf, +} + /// A struct containing all metadata about a project with which to plan generated output files for #[derive(Debug, Clone)] pub struct RazeMetadata { // `cargo metadata` output of the current project pub metadata: Metadata, + // `cargo metadata` output from any additional Cargo workspaces + pub additional_workspace_metadata: Vec, + // The absolute path to the current project's cargo workspace root. Note that the workspace // root in `metadata` will be inside of a temporary directory. For details see: // https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package pub cargo_workspace_root: Utf8PathBuf, + // Absolute paths to additional cargo workspace roots which contain path dependencies. + //pub additional_workspaces: Vec, + // The metadata of a lockfile that was generated as a result of fetching metadata pub lockfile: Option, @@ -156,64 +172,87 @@ fn make_symlink(src: &Utf8Path, dest: &Utf8Path) -> Result<()> { .with_context(|| "Failed to create symlink for generating metadata") } -/// A workspace metadata fetcher that uses the Cargo commands to gather information about a Cargo -/// project and it's transitive dependencies for planning and rendering of Bazel BUILD files. -pub struct RazeMetadataFetcher { - registry_url: Url, - index_url: Url, - metadata_fetcher: Box, - lockfile_generator: Box, - settings: Option, +/// Returns the shared parent directory of two paths, potentially an empty path if they share no +/// components. +fn common_parent_directory(a: &Utf8Path, b: &Utf8Path) -> Utf8PathBuf { + let mut result = Utf8PathBuf::new(); + for (l, r) in a.components().zip(b.components()) { + if l == r { + result.push(l); + } else { + break; + } + } + result } -impl RazeMetadataFetcher { - pub fn new>( - cargo_bin_path: P, - registry_url: Url, - index_url: Url, - settings: Option, - ) -> RazeMetadataFetcher { - let cargo_bin_pathbuf: Utf8PathBuf = cargo_bin_path.into(); - RazeMetadataFetcher { - registry_url, - index_url, - metadata_fetcher: Box::new(CargoMetadataFetcher { - cargo_bin_path: cargo_bin_pathbuf.clone(), - }), - lockfile_generator: Box::new(CargoLockfileGenerator { - cargo_bin_path: cargo_bin_pathbuf, - }), - settings, - } +struct TempWorkspaceInfo<'a> { + pub metadata: &'a Metadata, + pub all_info: &'a AllTempWorkspaceInfo, +} + +impl TempWorkspaceInfo<'_> { + /// Returns the relative path to this workspace from the root of the temp directory. + pub fn relative_path(&self) -> &Utf8Path { + self + .metadata + .workspace_root + .strip_prefix(&self.all_info.parent_source_directory) + .expect("We constructed this path as a prefix of the other one") } - pub fn new_with_settings(settings: Option) -> RazeMetadataFetcher { - RazeMetadataFetcher::new( - cargo_bin_path(), - // UNWRAP: The default is covered by testing and should never return err - Url::parse(DEFAULT_CRATE_REGISTRY_URL).unwrap(), - Url::parse(DEFAULT_CRATE_INDEX_URL).unwrap(), - settings, - ) + /// Returns the path to this workspace within the temp directory. + pub fn temp_dir_path(&self) -> Result { + Ok(self.all_info.temp_path()?.join(self.relative_path())) } - /// Reassign the [`crate::metadata::MetadataFetcher`] associated with the Raze Metadata Fetcher - pub fn set_metadata_fetcher(&mut self, fetcher: Box) { - self.metadata_fetcher = fetcher; + /// Returns the source workspace root. + pub fn workspace_root(&self) -> &Utf8Path { + &self.metadata.workspace_root } - /// Reassign the [`crate::metadata::LockfileGenerator`] associated with the current Fetcher - pub fn set_lockfile_generator(&mut self, generator: Box) { - self.lockfile_generator = generator; + /// Copies over some top-level config files. + pub fn copy_config_files(&self) -> Result<()> { + let workspace_root = self.workspace_root(); + let temp_dir_path = self.temp_dir_path()?; + fs::create_dir_all(&temp_dir_path).context("Failed to create directory in temp dir")?; + + // There should be a `Cargo.toml` file in the workspace root + fs::copy( + workspace_root.join("Cargo.toml"), + temp_dir_path.join("Cargo.toml"), + ) + .context("Failed to copy Cargo.toml")?; + + // Optionally copy over the lock file + if self.workspace_root().join("Cargo.lock").exists() { + fs::copy( + workspace_root.join("Cargo.lock"), + temp_dir_path.join("Cargo.lock"), + ) + .context("Failed to copy Cargo.lock")?; + } + + let source_dotcargo = workspace_root.join(".cargo"); + let source_dotcargo_config = source_dotcargo.join("config.toml"); + if source_dotcargo_config.exists() { + let destination_dotcargo = temp_dir_path.join(".cargo"); + fs::create_dir(&destination_dotcargo).context("Failed to create .cargo directory")?; + let destination_dotcargo_config = destination_dotcargo.join("config.toml"); + fs::copy(&source_dotcargo_config, &destination_dotcargo_config) + .context("Failed to copy .cargo/config.toml")?; + } + + Ok(()) } - /// Symlinks the source code of all workspace members into the temp workspace - fn link_src_to_workspace(&self, no_deps_metadata: &Metadata, temp_dir: &Utf8Path) -> Result<()> { + /// Symlinks the source code of all workspace members into the temp workspace. + pub fn link_src_to_workspace(&self) -> Result<()> { let crate_member_id_re = match consts::OS { "windows" => Regex::new(r".+\(path\+file:///(.+)\)")?, _ => Regex::new(r".+\(path\+file://(.+)\)")?, }; - for member in no_deps_metadata.workspace_members.iter() { + for member in self.metadata.workspace_members.iter() { // Get a path to the workspace member directory let workspace_member_directory = { let crate_member_id_match = crate_member_id_re @@ -242,16 +281,13 @@ impl RazeMetadataFetcher { } // Copy the Cargo.toml files into the temp directory to match the directory structure on disk - let path_diff = diff_paths( - &workspace_member_directory, - &no_deps_metadata.workspace_root, - ) - .ok_or_else(|| { - anyhow!("All workspace members are expected to be under the workspace root") - })?; + let path_diff = diff_paths(&workspace_member_directory, &self.metadata.workspace_root) + .ok_or_else(|| { + anyhow!("All workspace members are expected to be under the workspace root") + })?; let diff = Utf8PathBuf::from_path_buf(path_diff) .map_err(|_e| anyhow!("Invalid UTF-8 in path diff."))?; - let new_path = temp_dir.join(diff); + let new_path = self.temp_dir_path()?.join(diff); fs::create_dir_all(&new_path)?; fs::copy( workspace_member_directory.join("Cargo.toml"), @@ -267,14 +303,14 @@ impl RazeMetadataFetcher { .map_err(|_e| anyhow!("Invalid UTF-8 in source directory."))?; // Determine the difference between the workspace root and the current file - let path_diff = diff_paths(&path, &no_deps_metadata.workspace_root).ok_or_else(|| { + let path_diff = diff_paths(&path, &self.metadata.workspace_root).ok_or_else(|| { anyhow!("All workspace members are expected to be under the workspace root") })?; let diff = Utf8PathBuf::from_path_buf(path_diff) .map_err(|_e| anyhow!("Invalid UTF-8 in source directory path diff."))?; // Create a matching directory tree for the current file within the temp workspace - let new_path = temp_dir.join(diff.as_path()); + let new_path = self.temp_dir_path()?.join(diff.as_path()); if let Some(parent) = new_path.parent() { fs::create_dir_all(parent)?; } @@ -286,44 +322,137 @@ impl RazeMetadataFetcher { Ok(()) } +} - /// Creates a copy workspace in a temporary directory for fetching the metadata of the current workspace - fn make_temp_workspace(&self, cargo_workspace_root: &Utf8Path) -> Result<(TempDir, Utf8PathBuf)> { - let temp_dir = TempDir::new()?; +/// Manages information about a set of temporary workspaces. +/// +/// We have to build up this information piece by piece, but it's much more useful to expose it as +/// a struct with information about each of the individual workspaces. This class manages +/// converting between the representations. +struct AllTempWorkspaceInfo { + temp_dir: TempDir, + metadata: Vec, + parent_source_directory: Utf8PathBuf, +} - // First gather metadata without downloading any dependencies so we can identify any path dependencies. - let no_deps_metadata = self - .metadata_fetcher - .fetch_metadata(cargo_workspace_root, /*include_deps=*/ false)?; +impl AllTempWorkspaceInfo { + pub fn new(temp_dir: TempDir, metadata: impl Iterator>) -> Result { + let metadata = metadata.collect::>>()?; + let mut parent_source_directory = Utf8PathBuf::from( + &metadata + .first() + .expect("Top-level workspace must be in this list") + .workspace_root, + ); + for m in metadata.iter() { + parent_source_directory = + common_parent_directory(&parent_source_directory, &m.workspace_root); + } + Ok(Self { + temp_dir, + metadata, + parent_source_directory, + }) + } - // There should be a `Cargo.toml` file in the workspace root - fs::copy( - no_deps_metadata.workspace_root.join("Cargo.toml"), - temp_dir.as_ref().join("Cargo.toml"), - )?; + pub fn temp_path(&self) -> Result<&Utf8Path> { + Utf8Path::from_path(self.temp_dir.as_ref()) + .ok_or_else(|| anyhow!("Invalid UTF-8 in temp path.")) + } - // Optionally copy over the lock file - if no_deps_metadata.workspace_root.join("Cargo.lock").exists() { - fs::copy( - no_deps_metadata.workspace_root.join("Cargo.lock"), - temp_dir.as_ref().join("Cargo.lock"), - )?; - } + pub fn all_workspaces(&self) -> impl Iterator> { + self.metadata.iter().map(move |metadata| TempWorkspaceInfo { + metadata, + all_info: self, + }) + } +} - let source_dotcargo = cargo_workspace_root.join(".cargo"); - let source_dotcargo_config = source_dotcargo.join("config.toml"); - if source_dotcargo_config.exists() { - let destination_dotcargo = temp_dir.path().join(".cargo"); - fs::create_dir(&destination_dotcargo)?; - let destination_dotcargo_config = destination_dotcargo.join("config.toml"); - fs::copy(&source_dotcargo_config, &destination_dotcargo_config)?; +/// A workspace metadata fetcher that uses the Cargo commands to gather information about a Cargo +/// project and it's transitive dependencies for planning and rendering of Bazel BUILD files. +pub struct RazeMetadataFetcher { + registry_url: Url, + index_url: Url, + metadata_fetcher: Box, + lockfile_generator: Box, + settings: Option, +} + +impl RazeMetadataFetcher { + pub fn new>( + cargo_bin_path: P, + registry_url: Url, + index_url: Url, + settings: Option, + ) -> RazeMetadataFetcher { + let cargo_bin_pathbuf: Utf8PathBuf = cargo_bin_path.into(); + RazeMetadataFetcher { + registry_url, + index_url, + metadata_fetcher: Box::new(CargoMetadataFetcher { + cargo_bin_path: cargo_bin_pathbuf.clone(), + }), + lockfile_generator: Box::new(CargoLockfileGenerator { + cargo_bin_path: cargo_bin_pathbuf, + }), + settings, } + } + + pub fn new_with_settings(settings: Option) -> RazeMetadataFetcher { + RazeMetadataFetcher::new( + cargo_bin_path(), + // UNWRAP: The default is covered by testing and should never return err + Url::parse(DEFAULT_CRATE_REGISTRY_URL).unwrap(), + Url::parse(DEFAULT_CRATE_INDEX_URL).unwrap(), + settings, + ) + } + + /// Reassign the [`crate::metadata::MetadataFetcher`] associated with the Raze Metadata Fetcher + pub fn set_metadata_fetcher(&mut self, fetcher: Box) { + self.metadata_fetcher = fetcher; + } + + /// Reassign the [`crate::metadata::LockfileGenerator`] associated with the current Fetcher + pub fn set_lockfile_generator(&mut self, generator: Box) { + self.lockfile_generator = generator; + } + + /// Creates a copy workspace in a temporary directory for fetching the metadata of the current workspace + fn make_temp_workspace( + &self, + cargo_workspace_root: &Utf8Path, + additional_workspaces: &[impl AsRef], + ) -> Result { + let all_workspaces = + std::iter::once(cargo_workspace_root).chain(additional_workspaces.iter().map(AsRef::as_ref)); + // First gather metadata without downloading any dependencies so we can identify any path dependencies. + let no_deps_metadata = all_workspaces.map(|workspace_root| { + self + .metadata_fetcher + .fetch_metadata(workspace_root, /*include_deps=*/ false) + }); + let temp_dir = TempDir::new().context("Failed to create temporary directory")?; + let workspace_info = AllTempWorkspaceInfo::new(temp_dir, no_deps_metadata) + .context("Failed to collect initial metadata for all Cargo workspaces")?; + + for workspace in workspace_info.all_workspaces() { + workspace.copy_config_files().with_context(|| { + format!( + "Failed to copy Cargo config files from {:?}", + workspace.workspace_root() + ) + })?; - // Copy over the Cargo.toml files of each workspace member - let temp_path = Utf8Path::from_path(temp_dir.as_ref()) - .ok_or_else(|| anyhow!("Invalid UTF-8 in temp path."))?; - self.link_src_to_workspace(&no_deps_metadata, temp_path)?; - Ok((temp_dir, no_deps_metadata.workspace_root)) + workspace.link_src_to_workspace().with_context(|| { + format!( + "Failed to symlink source files from {:?}", + workspace.workspace_root() + ) + })?; + } + Ok(workspace_info) } /// Download a crate's source code from the current registry url @@ -452,13 +581,20 @@ impl RazeMetadataFetcher { pub fn fetch_metadata( &self, cargo_workspace_root: &Utf8Path, + additional_workspaces: &[impl AsRef], binary_dep_info: Option<&HashMap>, reused_lockfile: Option, ) -> Result { - let (cargo_dir, cargo_workspace_root) = self.make_temp_workspace(cargo_workspace_root)?; - let utf8_cargo_dir = Utf8Path::from_path(cargo_dir.as_ref()) - .ok_or_else(|| anyhow!("Cargo dir has invalid UTF-8 in fetch_metadata."))?; - let cargo_root_toml = utf8_cargo_dir.join("Cargo.toml"); + let workspace_info = self + .make_temp_workspace(cargo_workspace_root, additional_workspaces) + .context("Failed to create temporary workspace")?; + + let top_level_workspace = workspace_info + .all_workspaces() + .next() + .expect("Top-level workspace must be in this list"); + let cargo_dir = top_level_workspace.temp_dir_path()?; + let cargo_root_toml = cargo_dir.join("Cargo.toml"); // Gather new lockfile data if any binary dependencies were provided let mut checksums: HashMap = HashMap::new(); @@ -468,7 +604,7 @@ impl RazeMetadataFetcher { for (name, info) in binary_dep_info.iter() { let version = info.req(); - let src_dir = self.fetch_crate_src(utf8_cargo_dir, name, version)?; + let src_dir = self.fetch_crate_src(&cargo_dir, name, version)?; checksums.insert( package_ident(name, version), self.fetch_crate_checksum(name, version)?, @@ -482,10 +618,10 @@ impl RazeMetadataFetcher { } } - let output_lockfile = self.cargo_generate_lockfile(&reused_lockfile, utf8_cargo_dir)?; + let output_lockfile = self.cargo_generate_lockfile(&reused_lockfile, &cargo_dir)?; // Load checksums from the lockfile - let workspace_toml_lock = cargo_dir.as_ref().join("Cargo.lock"); + let workspace_toml_lock = cargo_dir.join("Cargo.lock"); if workspace_toml_lock.exists() { let lockfile = Lockfile::load(workspace_toml_lock)?; for package in &lockfile.packages { @@ -498,20 +634,44 @@ impl RazeMetadataFetcher { } } - let metadata = self - .metadata_fetcher - .fetch_metadata(utf8_cargo_dir, /*include_deps=*/ true)?; + let mut all_metadata = workspace_info + .all_workspaces() + .map(|workspace| { + let dir = workspace.temp_dir_path()?; + self + .metadata_fetcher + .fetch_metadata(&dir, /*include_deps=*/ true) + }) + .collect::>>()?; + let metadata = all_metadata + .drain(0..1) + .next() + .expect("Top-level workspace must be in this list"); + let additional_workspace_metadata = all_metadata + .into_iter() + .zip(workspace_info.all_workspaces().skip(1)) + .map(|(metadata, info)| -> Result { + Ok(AdditionalWorkspaceMetadata { + metadata, + relative_path: info.relative_path().into(), + temp_dir_path: info.temp_dir_path()?, + }) + }) + .collect::>>()?; // In this function because it's metadata, even though it's not returned by `cargo-metadata` let platform_features = match self.settings.as_ref() { - Some(settings) => get_per_platform_features(cargo_dir.path(), settings, &metadata.packages)?, + Some(settings) => { + get_per_platform_features(&cargo_dir.as_std_path(), settings, &metadata.packages)? + } None => BTreeMap::new(), }; Ok(RazeMetadata { metadata, + additional_workspace_metadata, checksums, - cargo_workspace_root, + cargo_workspace_root: top_level_workspace.workspace_root().into(), lockfile: output_lockfile, features: platform_features, }) diff --git a/impl/src/planning.rs b/impl/src/planning.rs index 2de9f5572..9883620dc 100644 --- a/impl/src/planning.rs +++ b/impl/src/planning.rs @@ -59,7 +59,7 @@ impl BuildPlanner for BuildPlannerImpl { /// Retrieves metadata for local workspace and produces a build plan. fn plan_build(&self, platform_details: Option) -> Result { // Create one combined metadata object which includes all dependencies and binaries - let crate_catalog = CrateCatalog::new(&self.metadata.metadata)?; + let crate_catalog = CrateCatalog::new(&self.metadata, &self.settings)?; // Generate additional PlatformDetails let workspace_subplanner = WorkspaceSubplanner { diff --git a/impl/src/planning/crate_catalog.rs b/impl/src/planning/crate_catalog.rs index 099aa44ce..5ecc0f483 100644 --- a/impl/src/planning/crate_catalog.rs +++ b/impl/src/planning/crate_catalog.rs @@ -18,10 +18,12 @@ use std::{ }; use anyhow::{anyhow, Result}; +use camino::{Utf8Path, Utf8PathBuf}; use cargo_metadata::{Metadata, Node, Package, PackageId}; use crate::{ error::RazeError, + planning::RazeMetadata, settings::{GenMode, RazeSettings}, util, util::package_ident, @@ -39,6 +41,9 @@ pub struct CrateCatalogEntry { pub package_ident: String, // Is this a member of the root crate workspace? pub is_workspace_crate: bool, + // If this is part of a local Cargo workspace, but not the main one, this is the path to it from + // the Bazel workspace + pub path_in_additional_workspace: Option, // A list of workspace members that depend on this entry pub workspace_member_dependents: Vec, } @@ -47,6 +52,7 @@ impl CrateCatalogEntry { pub fn new( package: &Package, is_workspace_crate: bool, + path_in_additional_workspace: Option, workspace_member_dependents: Vec, ) -> Self { let sanitized_name = package.name.replace('-', "_"); @@ -58,6 +64,7 @@ impl CrateCatalogEntry { sanitized_name, sanitized_version, is_workspace_crate, + path_in_additional_workspace, workspace_member_dependents, } } @@ -160,7 +167,8 @@ pub struct CrateCatalog { impl CrateCatalog { /// Produces a CrateCatalog using the package entries from a metadata blob. - pub fn new(metadata: &Metadata) -> Result { + pub fn new(raze_metadata: &RazeMetadata, settings: &RazeSettings) -> Result { + let metadata = &raze_metadata.metadata; let resolve = metadata .resolve .as_ref() @@ -172,6 +180,40 @@ impl CrateCatalog { .filter(|node| metadata.workspace_members.contains(&node.id)) .collect(); + let find_path_in_additional_workspace = |package: &Package| -> Option { + for additional_metadata in raze_metadata.additional_workspace_metadata.iter() { + if additional_metadata + .metadata + .workspace_members + .contains(&package.id) + { + // UNWRAP: We just checked that this package is a member of this workspace. + let package = additional_metadata + .metadata + .packages + .iter() + .find(|c| &c.id == &package.id) + .unwrap(); + // UNWRAP: The Cargo.toml is in some directory. + let package_folder = package.manifest_path.parent().unwrap(); + // UNWRAP: These are both absolute paths pointing into the same temporary + // directory. + let package_relative = + pathdiff::diff_paths(&package_folder, &additional_metadata.temp_dir_path).unwrap(); + // UNWRAP: They were both UTF8 paths before, their difference will also be. + let package_relative = Utf8PathBuf::from_path_buf(package_relative).unwrap(); + let workspace_file_path: &Utf8Path = settings.bazel_workspace_path.as_str().into(); + return Some( + workspace_file_path + .join(&additional_metadata.relative_path) + .join(package_relative) + .into(), + ); + } + } + None + }; + let entries = metadata .packages .iter() @@ -179,6 +221,7 @@ impl CrateCatalog { CrateCatalogEntry::new( package, metadata.workspace_members.contains(&package.id), + find_path_in_additional_workspace(package), workspace_crates .iter() .filter_map(|node| { diff --git a/impl/src/planning/subplanners.rs b/impl/src/planning/subplanners.rs index 6a5fdb1ec..bd976f9ed 100644 --- a/impl/src/planning/subplanners.rs +++ b/impl/src/planning/subplanners.rs @@ -52,6 +52,13 @@ type CrateContextProduction = (Vec, Vec); /// Utility type alias to reduce declaration noise type DepProduction = HashMap, CrateDependencyContext>; +/// Represents the various places we can load a Bazel repository for a Rust package from. +enum RepositorySourceId<'planner> { + SourceId(SourceId), + LocalRepository(&'planner Utf8Path), + None, +} + /// An internal working planner for generating context for an individual crate. struct CrateSubplanner<'planner> { // Workspace-Wide details @@ -60,7 +67,7 @@ struct CrateSubplanner<'planner> { crate_catalog: &'planner CrateCatalog, // Crate specific content crate_catalog_entry: &'planner CrateCatalogEntry, - source_id: &'planner Option, + source_id: RepositorySourceId<'planner>, node: &'planner Node, crate_settings: Option<&'planner CrateSettings>, sha256: &'planner Option, @@ -147,13 +154,23 @@ impl<'planner> WorkspaceSubplanner<'planner> { return None; } - // UNWRAP: Safe given unwrap during serialize step of metadata - let own_source_id = own_package - .source - .as_ref() - .map(|s| SourceId::from_url(&s.to_string()).unwrap()); - let crate_settings = self.crate_settings(own_package).ok()?; + let own_source_id = if let Some(local_repository_path) = crate_settings + .as_ref() + .and_then(|s| s.local_repository_path.as_ref()) + { + RepositorySourceId::LocalRepository(&local_repository_path) + } else if let Some(path_in_additional_workspace) = own_crate_catalog_entry + .path_in_additional_workspace + .as_ref() + { + RepositorySourceId::LocalRepository(path_in_additional_workspace.as_str().into()) + } else if let Some(source) = own_package.source.as_ref() { + // UNWRAP: Safe given unwrap during serialize step of metadata + RepositorySourceId::SourceId(SourceId::from_url(&source.to_string()).unwrap()) + } else { + RepositorySourceId::None + }; let checksum_opt = self .metadata @@ -164,7 +181,7 @@ impl<'planner> WorkspaceSubplanner<'planner> { settings: self.settings, platform_details: self.platform_details, crate_catalog_entry: own_crate_catalog_entry, - source_id: &own_source_id, + source_id: own_source_id, node, crate_settings, sha256: &checksum_opt.map(|c| c.to_owned()), @@ -647,80 +664,119 @@ impl<'planner> CrateSubplanner<'planner> { package_root: &Utf8Path, binary_dep_spec: Option<&cargo_toml::Dependency>, ) -> Result { - let mut git_data = None; - let mut download_url = None; - - if let Some(source_id) = self.source_id { - if source_id.is_git() { - let manifest_parent = package.manifest_path.parent().ok_or_else(|| { - anyhow!( - "Expected manifest_path to have a parent but was {}", - package.manifest_path - ) - })?; - let path_to_crate_root = manifest_parent - .strip_prefix(package_root) - .with_context(|| { + Ok(match &self.source_id { + RepositorySourceId::SourceId(source_id) => { + if source_id.is_git() { + let manifest_parent = package.manifest_path.parent().ok_or_else(|| { anyhow!( - "Expected package root `{}` to be a prefix of manifest path dir `{}` but it wasn't", - package_root, - manifest_parent + "Expected manifest_path to have a parent but was {}", + package.manifest_path ) })?; - let path_to_crate_root = if path_to_crate_root.components().next().is_some() { - Some(path_to_crate_root.to_string()) - } else { - None - }; - git_data = Some(GitRepo { - remote: source_id.url().to_string(), - commit: source_id - .precise() - .ok_or_else(|| { - anyhow!( - "Expected source_id to have a `precise` field with a git commit, but it didn't" + let path_to_crate_root = + manifest_parent + .strip_prefix(package_root) + .with_context(|| { + anyhow!( + "Expected package root `{}` to be a prefix of manifest path dir `{}` but it wasn't", + package_root, + manifest_parent + ) + })?; + let path_to_crate_root = if path_to_crate_root.components().next().is_some() { + Some(path_to_crate_root.to_string()) + } else { + None + }; + let git_data = Some(GitRepo { + remote: source_id.url().to_string(), + commit: source_id + .precise() + .ok_or_else(|| { + anyhow!( + "Expected source_id to have a `precise` field with a git commit, but it didn't" + ) + })? + .to_owned(), + path_to_crate_root, + }); + SourceDetails { + git_data, + download_url: None, + local_repository_path: None, + } + } else if source_id.is_remote_registry() { + if let Some(source) = package.source.as_ref() { + let download_url = Some( + Self::produce_download_url( + crates_io_template, + source, + &package.name, + &package.version, ) - })? - .to_owned(), - path_to_crate_root, - }); - } - if source_id.is_remote_registry() { - if let Some(source) = package.source.as_ref() { - download_url = Some( - Self::produce_download_url(crates_io_template, source, &package.name, &package.version) .with_context(|| { format!( "Producing download URL for crate {} version {}", &package.name, &package.version ) })?, - ); + ); + SourceDetails { + git_data: None, + download_url, + local_repository_path: None, + } + } else { + bail!( + "Expected source to be present for package {} version {}", + package.name, + package.version.to_string() + ); + } } else { bail!( - "Expected source to be present for package {} version {}", + "Failed to determine download URL for {}, unsupported source ID {}", package.name, - package.version.to_string() + source_id ); } } - } else if let Some(binary_dep_spec) = binary_dep_spec { - if let Dependency::Detailed(detailed) = binary_dep_spec { - if detailed.registry.is_some() || detailed.registry_index.is_some() { - bail!("Binary deps do not support registries other than crates.io, but {} attempted to use a custom registry", package.name); + RepositorySourceId::LocalRepository(local_repository_path) => SourceDetails { + git_data: None, + download_url: None, + local_repository_path: Some(local_repository_path.into()), + }, + RepositorySourceId::None => { + if let Some(binary_dep_spec) = binary_dep_spec { + if let Dependency::Detailed(detailed) = binary_dep_spec { + if detailed.registry.is_some() || detailed.registry_index.is_some() { + bail!("Binary deps do not support registries other than crates.io, but {} attempted to use a custom registry", package.name); + } + } + let source = Source { + repr: "registry+https://github.com/rust-lang/crates.io-index".to_owned(), + }; + let download_url = Some( + Self::produce_download_url( + crates_io_template, + &source, + &package.name, + &package.version, + ) + .with_context(|| format!("Producing download URL for binary dep {}", package.name))?, + ); + SourceDetails { + git_data: None, + download_url, + local_repository_path: None, + } + } else { + bail!( + "No source ID and not a binary dep, failed to determined download URL for {}", + package.name + ); } } - let source = Source { - repr: "registry+https://github.com/rust-lang/crates.io-index".to_owned(), - }; - download_url = Some( - Self::produce_download_url(crates_io_template, &source, &package.name, &package.version) - .with_context(|| format!("Producing download URL for binary dep {}", package.name))?, - ); - } - Ok(SourceDetails { - git_data, - download_url, }) } @@ -832,8 +888,11 @@ impl<'planner> CrateSubplanner<'planner> { /// interest among others. fn find_package_root_for_manifest(&self, manifest_path: &Utf8Path) -> Result { let has_git_repo_root = { - let is_git = self.source_id.as_ref().map_or(false, SourceId::is_git); - is_git && self.settings.genmode == GenMode::Remote + if let RepositorySourceId::SourceId(source_id) = &self.source_id { + source_id.is_git() && self.settings.genmode == GenMode::Remote + } else { + false + } }; // Return manifest path itself if not git diff --git a/impl/src/rendering/templates/remote_crates.bzl.template b/impl/src/rendering/templates/remote_crates.bzl.template index f30a6b8b7..9658554d7 100644 --- a/impl/src/rendering/templates/remote_crates.bzl.template +++ b/impl/src/rendering/templates/remote_crates.bzl.template @@ -6,7 +6,7 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: di {% if experimental_api %} {% include "templates/partials/crates_macro.template" %} {% endif %} -def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(): +def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(local_path_prefix = ""): {%- if crates %} """This function defines a collection of repos and should be called in a WORKSPACE file""" {%- for crate in crates %} @@ -20,7 +20,7 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(): init_submodules = True, {%- include "templates/partials/remote_crates_patch.template" %} ) -{%- else %} +{%- elif crate.source_details.download_url %} maybe( http_archive, name = "{{workspace.gen_workspace_prefix}}__{{crate.pkg_name | replace(from="-", to="_")}}__{{crate.pkg_version | slugify | replace(from="-", to="_")}}", @@ -33,6 +33,15 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(): {%- include "templates/partials/remote_crates_patch.template" %} build_file = Label("{{workspace.workspace_path}}/remote:BUILD.{{crate.pkg_name}}-{{crate.pkg_version}}.bazel"), ) +{%- elif crate.source_details.local_repository_path %} + maybe( + native.new_local_repository, + name = "{{workspace.gen_workspace_prefix}}__{{crate.pkg_name | replace(from="-", to="_")}}__{{crate.pkg_version | slugify | replace(from="-", to="_")}}", + path = local_path_prefix + "{{ crate.source_details.local_repository_path }}", + build_file = local_path_prefix + "{{workspace.workspace_path}}/remote/BUILD.{{crate.pkg_name}}-{{crate.pkg_version}}.bazel".strip("/"), + ) +{%- else %} + fail("Not sure how to download crate {{ crate.pkg_name }}") {%- endif %} {% endfor %} {%- else %} diff --git a/impl/src/settings.rs b/impl/src/settings.rs index 697571cb8..3eb655c03 100644 --- a/impl/src/settings.rs +++ b/impl/src/settings.rs @@ -39,6 +39,25 @@ pub struct RazeSettings { /// outputs in `//foo/third_party`.) pub workspace_path: String, + /// Paths to additional Cargo workspaces that the top-level one has references to. + /// + /// This is a common workaround for not being able to nest these inside each other, see + /// https://github.com/rust-lang/cargo/issues/5042 for details. Raze needs the path to each of + /// them so it can collect metadata from all of them. + /// + /// Note: This field should be a path to a file relative to the Cargo workspace root. For more + /// context, see https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package + #[serde(default)] + pub additional_workspace_paths: Vec, + + /// Path from the root of the bazel workspace to this Cargo.toml. + /// + /// Defaults to `/`. + /// + /// Setting this is only necessary when using `additional_workspace_paths`. + #[serde(default = "default_bazel_workspace_path")] + pub bazel_workspace_path: String, + /// The relative path within each workspace member directory where aliases the member's dependencies should be rendered. /// /// By default, a new directory will be created next to the `Cargo.toml` file named `cargo` for users to refer to them @@ -248,6 +267,12 @@ pub struct CrateSettings { /// context, see https://doc.rust-lang.org/cargo/reference/workspaces.html#root-package #[serde(default)] pub additional_build_file: Option, + + /// Value for a `local_repository.path` for this package. + /// + /// This is useful to locally vendor a few packages with the remote genmode. + #[serde(default)] + pub local_repository_path: Option, } /// Describes how dependencies should be managed in tree. @@ -285,6 +310,7 @@ impl Default for CrateSettings { patch_tool: None, patches: Vec::new(), additional_build_file: None, + local_repository_path: None, } } } @@ -336,6 +362,10 @@ fn default_crate_settings_field_data_attr() -> Option { None } +fn default_bazel_workspace_path() -> String { + "/".to_owned() +} + fn default_package_aliases_dir() -> String { "cargo".to_owned() } @@ -453,6 +483,10 @@ struct RawRazeSettings { #[serde(default)] pub workspace_path: Option, #[serde(default)] + pub additional_workspace_paths: Vec, + #[serde(default)] + pub bazel_workspace_path: Option, + #[serde(default)] pub package_aliases_dir: Option, #[serde(default)] pub render_package_aliases: Option, @@ -488,6 +522,8 @@ impl RawRazeSettings { /// Checks whether or not the settings have non-package specific settings specified fn contains_primary_options(&self) -> bool { self.workspace_path.is_some() + || !self.additional_workspace_paths.is_empty() + || self.bazel_workspace_path.is_some() || self.package_aliases_dir.is_some() || self.render_package_aliases.is_some() || self.target.is_some() @@ -790,6 +826,8 @@ pub mod tests { pub fn dummy_raze_settings() -> RazeSettings { RazeSettings { workspace_path: "//cargo".to_owned(), + additional_workspace_paths: Vec::new(), + bazel_workspace_path: None, package_aliases_dir: "cargo".to_owned(), render_package_aliases: default_render_package_aliases(), target: Some("x86_64-unknown-linux-gnu".to_owned()), diff --git a/tools/examples_repository_tools.sh b/tools/examples_repository_tools.sh index 0fa61d029..f9a2f53cc 100755 --- a/tools/examples_repository_tools.sh +++ b/tools/examples_repository_tools.sh @@ -63,7 +63,8 @@ function raze() { vendor # Regenerate all outputs - MANIFESTS=$(find $EXAMPLES_DIR -mindepth 2 -maxdepth 2 -type d) + MANIFESTS=$(find $EXAMPLES_DIR -mindepth 2 -maxdepth 2 -type d -not -name parent_directory_workspace) + MANIFESTS+=($EXAMPLES_DIR/remote/parent_directory_workspace/main) for manifest in ${MANIFESTS[@]}; do echo "Running raze on ${manifest}" ${RAZE} --manifest-path=${manifest}/Cargo.toml From d4027ecdb4882b075ad7d3fc75b2db6ff9a765da Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Thu, 15 Sep 2022 17:53:56 -0700 Subject: [PATCH 2/5] Fix CI failures --- .../binary_dependencies/cargo/crates.bzl | 7 +++++++ .../build_dependencies/cargo/crates.bzl | 7 +++++++ .../remote/cargo_workspace/cargo/crates.bzl | 7 +++++++ .../cargo/crates.bzl | 7 +++++++ .../remote/dev_dependencies/cargo/crates.bzl | 7 +++++++ examples/remote/no_deps/cargo/crates.bzl | 7 +++++++ examples/remote/non_cratesio/cargo/crates.bzl | 7 +++++++ .../cargo/crates.bzl | 7 +++++++ impl/src/metadata.rs | 8 ++++---- impl/src/planning.rs | 20 +++++++++++++++---- impl/src/rendering/bazel.rs | 3 +++ .../templates/remote_crates.bzl.template | 7 +++++++ impl/src/settings.rs | 2 +- impl/src/testing.rs | 2 +- .../dummy_modified_metadata.json.template | 4 ++-- 15 files changed, 90 insertions(+), 12 deletions(-) diff --git a/examples/remote/binary_dependencies/cargo/crates.bzl b/examples/remote/binary_dependencies/cargo/crates.bzl index 030f61b53..74bbc9198 100644 --- a/examples/remote/binary_dependencies/cargo/crates.bzl +++ b/examples/remote/binary_dependencies/cargo/crates.bzl @@ -167,7 +167,14 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_binary_dependencies_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/build_dependencies/cargo/crates.bzl b/examples/remote/build_dependencies/cargo/crates.bzl index 355a8ac5b..59002058d 100644 --- a/examples/remote/build_dependencies/cargo/crates.bzl +++ b/examples/remote/build_dependencies/cargo/crates.bzl @@ -9,7 +9,14 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_build_dependencies_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/cargo_workspace/cargo/crates.bzl b/examples/remote/cargo_workspace/cargo/crates.bzl index a8be4e894..33ab9ff42 100644 --- a/examples/remote/cargo_workspace/cargo/crates.bzl +++ b/examples/remote/cargo_workspace/cargo/crates.bzl @@ -185,7 +185,14 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_cargo_workspace_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/complicated_cargo_library/cargo/crates.bzl b/examples/remote/complicated_cargo_library/cargo/crates.bzl index 017388f35..ffa9db11f 100644 --- a/examples/remote/complicated_cargo_library/cargo/crates.bzl +++ b/examples/remote/complicated_cargo_library/cargo/crates.bzl @@ -9,7 +9,14 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_complicated_cargo_library_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/dev_dependencies/cargo/crates.bzl b/examples/remote/dev_dependencies/cargo/crates.bzl index ccfabb12c..1c2cdeacf 100644 --- a/examples/remote/dev_dependencies/cargo/crates.bzl +++ b/examples/remote/dev_dependencies/cargo/crates.bzl @@ -9,7 +9,14 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_dev_dependencies_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/no_deps/cargo/crates.bzl b/examples/remote/no_deps/cargo/crates.bzl index 1642671fd..5092bc551 100644 --- a/examples/remote/no_deps/cargo/crates.bzl +++ b/examples/remote/no_deps/cargo/crates.bzl @@ -9,6 +9,13 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_no_deps_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """No crates were detected in the source Cargo.toml. This is a no-op""" pass diff --git a/examples/remote/non_cratesio/cargo/crates.bzl b/examples/remote/non_cratesio/cargo/crates.bzl index 4e51d6874..3ab942073 100644 --- a/examples/remote/non_cratesio/cargo/crates.bzl +++ b/examples/remote/non_cratesio/cargo/crates.bzl @@ -9,7 +9,14 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_non_cratesio_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/examples/remote/parent_directory_workspace/cargo/crates.bzl b/examples/remote/parent_directory_workspace/cargo/crates.bzl index 3803d37f9..3c6014bf9 100644 --- a/examples/remote/parent_directory_workspace/cargo/crates.bzl +++ b/examples/remote/parent_directory_workspace/cargo/crates.bzl @@ -177,7 +177,14 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def remote_parent_directory_workspace_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix """This function defines a collection of repos and should be called in a WORKSPACE file""" maybe( http_archive, diff --git a/impl/src/metadata.rs b/impl/src/metadata.rs index fe5f586d4..d7fc3ffa6 100644 --- a/impl/src/metadata.rs +++ b/impl/src/metadata.rs @@ -816,7 +816,7 @@ pub mod tests { })); fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .unwrap() } @@ -832,7 +832,7 @@ pub mod tests { lockfile_contents: None, })); fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .unwrap(); } @@ -858,7 +858,7 @@ pub mod tests { lockfile_contents: None, })); fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .unwrap(); } @@ -874,7 +874,7 @@ pub mod tests { let fetcher = RazeMetadataFetcher::default(); assert!(fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .is_err()); } diff --git a/impl/src/planning.rs b/impl/src/planning.rs index 9883620dc..2bf1c7be3 100644 --- a/impl/src/planning.rs +++ b/impl/src/planning.rs @@ -92,7 +92,7 @@ pub mod tests { }; use super::*; - use camino::Utf8PathBuf; + use camino::{Utf8Path, Utf8PathBuf}; use cargo_metadata::PackageId; use indoc::indoc; use itertools::Itertools; @@ -105,6 +105,7 @@ pub mod tests { metadata.resolve = None; RazeMetadata { metadata, + additional_workspace_metadata: Vec::new(), cargo_workspace_root: Utf8PathBuf::from("/some/crate"), lockfile: None, checksums: HashMap::new(), @@ -171,7 +172,7 @@ pub mod tests { })); let raze_metadata = fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .unwrap(); let mut metadata = raze_metadata.metadata; @@ -195,6 +196,7 @@ pub mod tests { RazeMetadata { metadata, + additional_workspace_metadata: Vec::new(), cargo_workspace_root: Utf8PathBuf::from("/some/crate"), lockfile: None, checksums: HashMap::new(), @@ -441,7 +443,12 @@ pub mod tests { let dir = make_basic_workspace(); let raze_metadata = fetcher - .fetch_metadata(utf8_path(dir.as_ref()), Some(&settings.binary_deps), None) + .fetch_metadata( + utf8_path(dir.as_ref()), + &[] as &[&Utf8Path], + Some(&settings.binary_deps), + None, + ) .unwrap(); for mock in mock.endpoints.iter() { @@ -800,7 +807,12 @@ pub mod tests { } fetcher - .fetch_metadata(utf8_path(crate_dir.as_ref()), None, None) + .fetch_metadata( + utf8_path(crate_dir.as_ref()), + &[] as &[&Utf8Path], + None, + None, + ) .unwrap() } diff --git a/impl/src/rendering/bazel.rs b/impl/src/rendering/bazel.rs index bbb9595ca..130a75f1d 100644 --- a/impl/src/rendering/bazel.rs +++ b/impl/src/rendering/bazel.rs @@ -559,6 +559,7 @@ mod tests { build_script_target: None, links: None, source_details: SourceDetails { + local_repository_path: None, git_data: None, download_url: Some( "https://crates.io/api/v1/crates/test-binary/1.1.1/download" @@ -606,6 +607,7 @@ mod tests { build_script_target: None, links: Some("ssh2".to_owned()), source_details: SourceDetails { + local_repository_path: None, git_data: None, download_url: Some( "https://crates.io/api/v1/crates/test-binary/1.1.1/download" @@ -663,6 +665,7 @@ mod tests { build_script_target: None, links: Some("ssh2".to_owned()), source_details: SourceDetails { + local_repository_path: None, git_data: None, download_url: Some( "https://crates.io/api/v1/crates/test-proc-macro/1.1.1/download" diff --git a/impl/src/rendering/templates/remote_crates.bzl.template b/impl/src/rendering/templates/remote_crates.bzl.template index 9658554d7..74eb54975 100644 --- a/impl/src/rendering/templates/remote_crates.bzl.template +++ b/impl/src/rendering/templates/remote_crates.bzl.template @@ -6,7 +6,14 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: di {% if experimental_api %} {% include "templates/partials/crates_macro.template" %} {% endif %} +""" +Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. +""" def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(local_path_prefix = ""): + _ = local_path_prefix {%- if crates %} """This function defines a collection of repos and should be called in a WORKSPACE file""" {%- for crate in crates %} diff --git a/impl/src/settings.rs b/impl/src/settings.rs index 3eb655c03..67a4e4333 100644 --- a/impl/src/settings.rs +++ b/impl/src/settings.rs @@ -827,7 +827,7 @@ pub mod tests { RazeSettings { workspace_path: "//cargo".to_owned(), additional_workspace_paths: Vec::new(), - bazel_workspace_path: None, + bazel_workspace_path: default_bazel_workspace_path(), package_aliases_dir: "cargo".to_owned(), render_package_aliases: default_render_package_aliases(), target: Some("x86_64-unknown-linux-gnu".to_owned()), diff --git a/impl/src/testing.rs b/impl/src/testing.rs index 81fa1c5dc..9e1673f6a 100644 --- a/impl/src/testing.rs +++ b/impl/src/testing.rs @@ -329,7 +329,7 @@ pub fn template_raze_metadata(template_path: &str) -> RazeMetadata { })); fetcher - .fetch_metadata(utf8_path(dir.as_ref()), None, None) + .fetch_metadata(utf8_path(dir.as_ref()), &[] as &[&Utf8Path], None, None) .unwrap() } diff --git a/impl/src/testing/metadata_templates/dummy_modified_metadata.json.template b/impl/src/testing/metadata_templates/dummy_modified_metadata.json.template index 551ee2c87..3b5642379 100644 --- a/impl/src/testing/metadata_templates/dummy_modified_metadata.json.template +++ b/impl/src/testing/metadata_templates/dummy_modified_metadata.json.template @@ -26,7 +26,7 @@ the package has one additional resolved dependency. "dependencies": [ { "name": "test_dep", - "source": null, + "source": "registry+https://github.com/rust-lang/crates.io-index", "req": "0.0.1", "kind": null, "rename": null, @@ -72,7 +72,7 @@ the package has one additional resolved dependency. "version": "0.0.1", "authors": [], "id": "test_dep_id", - "source": null, + "source": "registry+https://github.com/rust-lang/crates.io-index", "description": null, "dependencies": [], "license": null, From 367b135626debde5dc11bf631d4bdf14e4ec8fb0 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Fri, 16 Sep 2022 13:18:52 -0700 Subject: [PATCH 3/5] Make buildifier happy with the formatting --- .../binary_dependencies/cargo/crates.bzl | 16 ++++++++-------- .../build_dependencies/cargo/crates.bzl | 16 ++++++++-------- .../remote/cargo_workspace/cargo/crates.bzl | 16 ++++++++-------- .../cargo/crates.bzl | 16 ++++++++-------- .../remote/dev_dependencies/cargo/crates.bzl | 16 ++++++++-------- examples/remote/no_deps/cargo/crates.bzl | 18 ++++++++++-------- examples/remote/non_cratesio/cargo/crates.bzl | 16 ++++++++-------- .../cargo/crates.bzl | 16 ++++++++-------- .../templates/remote_crates.bzl.template | 19 ++++++++++--------- 9 files changed, 76 insertions(+), 73 deletions(-) diff --git a/examples/remote/binary_dependencies/cargo/crates.bzl b/examples/remote/binary_dependencies/cargo/crates.bzl index 74bbc9198..d9be6b262 100644 --- a/examples/remote/binary_dependencies/cargo/crates.bzl +++ b/examples/remote/binary_dependencies/cargo/crates.bzl @@ -167,15 +167,15 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_binary_dependencies_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_binary_dependencies__addr2line__0_14_0", diff --git a/examples/remote/build_dependencies/cargo/crates.bzl b/examples/remote/build_dependencies/cargo/crates.bzl index 59002058d..f26d5239b 100644 --- a/examples/remote/build_dependencies/cargo/crates.bzl +++ b/examples/remote/build_dependencies/cargo/crates.bzl @@ -9,15 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_build_dependencies_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_build_dependencies__addr2line__0_14_1", diff --git a/examples/remote/cargo_workspace/cargo/crates.bzl b/examples/remote/cargo_workspace/cargo/crates.bzl index 33ab9ff42..f68289761 100644 --- a/examples/remote/cargo_workspace/cargo/crates.bzl +++ b/examples/remote/cargo_workspace/cargo/crates.bzl @@ -185,15 +185,15 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_cargo_workspace_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_cargo_workspace__addr2line__0_13_0", diff --git a/examples/remote/complicated_cargo_library/cargo/crates.bzl b/examples/remote/complicated_cargo_library/cargo/crates.bzl index ffa9db11f..1162d0edd 100644 --- a/examples/remote/complicated_cargo_library/cargo/crates.bzl +++ b/examples/remote/complicated_cargo_library/cargo/crates.bzl @@ -9,15 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_complicated_cargo_library_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_complicated_cargo_library__ahash__0_3_8", diff --git a/examples/remote/dev_dependencies/cargo/crates.bzl b/examples/remote/dev_dependencies/cargo/crates.bzl index 1c2cdeacf..69f86d3d4 100644 --- a/examples/remote/dev_dependencies/cargo/crates.bzl +++ b/examples/remote/dev_dependencies/cargo/crates.bzl @@ -9,15 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_dev_dependencies_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_dev_dependencies__addr2line__0_14_1", diff --git a/examples/remote/no_deps/cargo/crates.bzl b/examples/remote/no_deps/cargo/crates.bzl index 5092bc551..1478e3752 100644 --- a/examples/remote/no_deps/cargo/crates.bzl +++ b/examples/remote/no_deps/cargo/crates.bzl @@ -9,13 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_no_deps_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """No crates were detected in the source Cargo.toml. This is a no-op""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused + + # No crates were detected in the source Cargo.toml. This is a no-op pass diff --git a/examples/remote/non_cratesio/cargo/crates.bzl b/examples/remote/non_cratesio/cargo/crates.bzl index 3ab942073..508c01148 100644 --- a/examples/remote/non_cratesio/cargo/crates.bzl +++ b/examples/remote/non_cratesio/cargo/crates.bzl @@ -9,15 +9,15 @@ load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") # bui load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # buildifier: disable=load load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: disable=load -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_non_cratesio_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_non_cratesio__aho_corasick__0_6_10", diff --git a/examples/remote/parent_directory_workspace/cargo/crates.bzl b/examples/remote/parent_directory_workspace/cargo/crates.bzl index 3c6014bf9..147602c05 100644 --- a/examples/remote/parent_directory_workspace/cargo/crates.bzl +++ b/examples/remote/parent_directory_workspace/cargo/crates.bzl @@ -177,15 +177,15 @@ def _flatten_dependency_maps(all_dependency_maps): return dependencies -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def remote_parent_directory_workspace_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix - """This function defines a collection of repos and should be called in a WORKSPACE file""" + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused maybe( http_archive, name = "remote_parent_directory_workspace__ansi_term__0_12_1", diff --git a/impl/src/rendering/templates/remote_crates.bzl.template b/impl/src/rendering/templates/remote_crates.bzl.template index 74eb54975..97534ea3c 100644 --- a/impl/src/rendering/templates/remote_crates.bzl.template +++ b/impl/src/rendering/templates/remote_crates.bzl.template @@ -6,16 +6,16 @@ load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") # buildifier: di {% if experimental_api %} {% include "templates/partials/crates_macro.template" %} {% endif %} -""" -Args: - local_path_prefix: An optional prefix to append to local paths within the Bazel repository. - Many uses should use `bazel_workspace_path` in the raze settings instead, this is only - for unusual sitations which use the same fetch_remote_crates from multiple repositories. -""" def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(local_path_prefix = ""): - _ = local_path_prefix + """This function defines a collection of repos and should be called in a WORKSPACE file. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ + _unused = local_path_prefix # @unused {%- if crates %} - """This function defines a collection of repos and should be called in a WORKSPACE file""" {%- for crate in crates %} {%- if crate.source_details.git_data %} maybe( @@ -52,7 +52,8 @@ def {{workspace.gen_workspace_prefix}}_fetch_remote_crates(local_path_prefix = " {%- endif %} {% endfor %} {%- else %} - """No crates were detected in the source Cargo.toml. This is a no-op""" + + # No crates were detected in the source Cargo.toml. This is a no-op pass {% endif %} {%- else %} From 14a81b4d77e3f38e8810bb9c968b342233802011 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Fri, 16 Sep 2022 13:23:55 -0700 Subject: [PATCH 4/5] One more buildifier fix --- examples/repositories.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/repositories.bzl b/examples/repositories.bzl index 934269357..00a3b19bb 100644 --- a/examples/repositories.bzl +++ b/examples/repositories.bzl @@ -3,11 +3,11 @@ load("@cargo_raze_examples//remote/binary_dependencies/cargo:crates.bzl", "remote_binary_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/build_dependencies/cargo:crates.bzl", "remote_build_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/cargo_workspace/cargo:crates.bzl", "remote_cargo_workspace_fetch_remote_crates") -load("@cargo_raze_examples//remote/parent_directory_workspace/cargo:crates.bzl", "remote_parent_directory_workspace_fetch_remote_crates") load("@cargo_raze_examples//remote/complicated_cargo_library/cargo:crates.bzl", "remote_complicated_cargo_library_fetch_remote_crates") load("@cargo_raze_examples//remote/dev_dependencies/cargo:crates.bzl", "remote_dev_dependencies_fetch_remote_crates") load("@cargo_raze_examples//remote/no_deps/cargo:crates.bzl", "remote_no_deps_fetch_remote_crates") load("@cargo_raze_examples//remote/non_cratesio/cargo:crates.bzl", "remote_non_cratesio_fetch_remote_crates") +load("@cargo_raze_examples//remote/parent_directory_workspace/cargo:crates.bzl", "remote_parent_directory_workspace_fetch_remote_crates") def repositories(local_path_prefix = None): """Defines all the cargo dependencies of the Cargo-raze examples""" From 664c798d572d652ea2655a2068551058ae22ab27 Mon Sep 17 00:00:00 2001 From: Brian Silverman Date: Fri, 16 Sep 2022 13:25:33 -0700 Subject: [PATCH 5/5] Fix yet another buildifier warning I wish I could find the flags to get these to show up locally instead of doing it with CI every time... --- examples/repositories.bzl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/repositories.bzl b/examples/repositories.bzl index 00a3b19bb..3fc95f3af 100644 --- a/examples/repositories.bzl +++ b/examples/repositories.bzl @@ -10,7 +10,13 @@ load("@cargo_raze_examples//remote/non_cratesio/cargo:crates.bzl", "remote_non_c load("@cargo_raze_examples//remote/parent_directory_workspace/cargo:crates.bzl", "remote_parent_directory_workspace_fetch_remote_crates") def repositories(local_path_prefix = None): - """Defines all the cargo dependencies of the Cargo-raze examples""" + """Defines all the cargo dependencies of the Cargo-raze examples. + + Args: + local_path_prefix: An optional prefix to append to local paths within the Bazel repository. + Many uses should use `bazel_workspace_path` in the raze settings instead, this is only + for unusual sitations which use the same fetch_remote_crates from multiple repositories. + """ remote_binary_dependencies_fetch_remote_crates(local_path_prefix = local_path_prefix) remote_cargo_workspace_fetch_remote_crates(local_path_prefix = local_path_prefix) remote_parent_directory_workspace_fetch_remote_crates(local_path_prefix = local_path_prefix)