Skip to content

Commit fd713d5

Browse files
authored
Move crate_universe examples to test dir (#3981)
The examples are currently not very readable examples and are primarily used as integration tests. This change refactors them to leave space for a more useful example to be added in the near future. closes #2842
1 parent 2f07767 commit fd713d5

643 files changed

Lines changed: 5058 additions & 23703 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.bazelci/presubmit.yml

Lines changed: 284 additions & 196 deletions
Large diffs are not rendered by default.

.bazelignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.direnv
22
bzlmod
33
crate_universe/private/bootstrap
4+
crate_universe/tests/integration
45
docs
56
examples
67
extensions

.gitattributes

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
**/cargo-bazel-lock.json linguist-generated
33
crate_universe/3rdparty/crates/** linguist-generated
44
crate_universe/test_data/metadata/*/metadata.json linguist-generated
5-
examples/hello_world/third-party/crates/** linguist-generated
5+
crate_universe/tests/integration/vendor/3rdparty/crates/** linguist-generated
6+
crate_universe/tests/integration/vendor/local_manifests/crates/** linguist-generated
7+
crate_universe/tests/integration/vendor/local_pkgs/crates/** linguist-generated
8+
crate_universe/tests/integration/vendor/remote_manifests/crates/** linguist-generated
9+
crate_universe/tests/integration/vendor/remote_pkgs/crates/** linguist-generated
610
examples/crate_universe_unnamed/vendor_remote_manifests/crates/** linguist-generated
711
examples/crate_universe_unnamed/vendor_remote_pkgs/crates/** linguist-generated
8-
examples/crate_universe/vendor_external/crates/** linguist-generated
9-
examples/crate_universe/vendor_local_manifests/crates/** linguist-generated
10-
examples/crate_universe/vendor_local_pkgs/crates/** linguist-generated
11-
examples/crate_universe/vendor_remote_manifests/crates/** linguist-generated
12-
examples/crate_universe/vendor_remote_pkgs/crates/** linguist-generated
12+
examples/hello_world/third-party/crates/** linguist-generated
1313
examples/sys/basic/3rdparty/crates/** linguist-generated
1414
examples/sys/complex/3rdparty/crates/** linguist-generated
1515
extensions/bindgen/3rdparty/crates/** linguist-generated

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
/bzlmod/hello_world/bazel-*
99
/examples/bazel-*
1010
/examples/cargo_manifest_dir/external_crate/bazel-*
11-
/examples/crate_universe/bazel-*
12-
/examples/crate_universe/*/bazel-*
11+
/crate_universe/tests/integration/*/bazel-*
12+
/crate_universe/tests/integration/vendor/*/bazel-*
1313
/test/cc_common_link/bazel-*
1414
/test/cc_common_link/with_global_alloc/bazel-*
1515
/test/no_std/bazel-*

crate_universe/defs.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ call above or [crates_repository::generator_urls](#crates_repository-generator_u
3939
4040
The [`crates_repository`](#crates_repository) rule (the primary repository rule of `rules_rust`'s cargo support) supports a number of different
4141
ways users can express and organize their dependencies. The most common are listed below though there are more to be found in
42-
the [./examples/crate_universe](https://github.com/bazelbuild/rules_rust/tree/main/examples/crate_universe) directory.
42+
the [crate_universe/tests/integration](https://github.com/bazelbuild/rules_rust/tree/main/crate_universe/tests/integration) directory.
4343
4444
### Cargo Workspaces
4545
@@ -272,15 +272,15 @@ Some build scripts can be made to work by pulling in some extra files and making
272272
273273
Commonly this is done by passing the file to the `build_script_data` annotation for the crate, and using `build_script_env` to tell the build script where the file is. That env var may often use `$(execroot)` to get the path to the label, or `$${pwd}/` as a prefix if the path given is relative to the execroot (as will frequently happen when using a toolchain).A
274274
275-
There is an example of this in the "complicated dependencies" section of https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/WORKSPACE.bazel which builds boring-sys.
275+
There is an example of this in the complicated_dependencies integration test at https://github.com/bazelbuild/rules_rust/tree/main/crate_universe/tests/integration/complicated_dependencies which builds boring-sys.
276276
277277
### Building with Bazel and supplying via an override
278278
279279
Some build scripts have hooks to allow replacing parts that are complicated to build with output prepared by Bazel.
280280
281281
We can use those hooks by specifying paths (generally using the `build_script_data` and `build_script_env` annotations) and pointing them at labels which Bazel will then build. These env vars may often use `$(execroot)` to get the path to the label, or `$${pwd}/` as a prefix if the path given is relative to the execroot (as will frequently happen when using a toolchain).
282282
283-
There is an example of this in the "complicated dependencies" section of https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/WORKSPACE.bazel which builds boring-sys.
283+
There is an example of this in the complicated_dependencies integration test at https://github.com/bazelbuild/rules_rust/tree/main/crate_universe/tests/integration/complicated_dependencies which builds boring-sys.
284284
285285
---
286286

crate_universe/extensions.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ We don't have such easy facilities available in bazel besides specifying it as a
191191
To mimic cargo's bindeps feature we use the unstable feature called [artifact-dependencies](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html?highlight=feature#artifact-dependencies)
192192
which integrates well with bazel concepts.
193193
194-
You could use the syntax specified in the above document to place it in `Cargo.toml`. For that you can consult the following [example](https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/MODULE.bazel#L279-L291).
194+
You could use the syntax specified in the above document to place it in `Cargo.toml`. For that you can consult the following [example](https://github.com/bazelbuild/rules_rust/blob/main/crate_universe/tests/integration/cargo_bindeps/MODULE.bazel).
195195
196196
This method has the following consequences:
197197
* if you use shared dependency tree with your project these binary dependencies will interfere with yours (may conflict)

crate_universe/test_data/cargo_bazel_lockfile/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## `multi_package-cargo-bazel-lock.json`
44

5-
This was copied from `examples/crate_universe/multi_package/cargo-bazel-lock.json` at commit 53daac71c0755680c29f4c55ac5238cc063e8b31.
5+
This was copied from `crate_universe/tests/integration/multi_package/cargo-bazel-lock.json` at commit 53daac71c0755680c29f4c55ac5238cc063e8b31.
66

77
It's intended to be an example of a realistic and meaningfully complex lockfile.
88

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)