Skip to content

Commit 30fde71

Browse files
committed
Move crate_universe examples to test dir
1 parent e890f0d commit 30fde71

649 files changed

Lines changed: 2633 additions & 20674 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: 485 additions & 56 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/test/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/test/integration/vendor_external/crates/** linguist-generated
6+
crate_universe/test/integration/vendor_local_manifests/crates/** linguist-generated
7+
crate_universe/test/integration/vendor_local_pkgs/crates/** linguist-generated
8+
crate_universe/test/integration/vendor_remote_manifests/crates/** linguist-generated
9+
crate_universe/test/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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
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/test/integration/*/bazel-*
1312
/test/cc_common_link/bazel-*
1413
/test/cc_common_link/with_global_alloc/bazel-*
1514
/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/test/integration](https://github.com/bazelbuild/rules_rust/tree/main/crate_universe/test/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/test/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/test/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/test/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)
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
module(
2+
name = "cu_test_alias_rule",
3+
version = "0.0.0",
4+
)
5+
6+
bazel_dep(name = "rules_rust", version = "0.0.0")
7+
local_path_override(
8+
module_name = "rules_rust",
9+
path = "../../../..",
10+
)
11+
12+
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
13+
use_repo(rust, "rust_toolchains")
14+
15+
register_toolchains("@rust_toolchains//:all")
16+
17+
alias_rule_global_alias_annotation_none = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
18+
alias_rule_global_alias_annotation_none.annotation(
19+
alias_rule = "",
20+
crate = "test_data_passing_crate",
21+
repositories = ["alias_rule_global_alias_annotation_none"],
22+
)
23+
alias_rule_global_alias_annotation_none.render_config(
24+
default_alias_rule_name = "alias",
25+
repositories = ["alias_rule_global_alias_annotation_none"],
26+
)
27+
alias_rule_global_alias_annotation_none.spec(
28+
package = "test_data_passing_crate",
29+
repositories = ["alias_rule_global_alias_annotation_none"],
30+
version = "0.1.0",
31+
)
32+
alias_rule_global_alias_annotation_none.from_specs(
33+
name = "alias_rule_global_alias_annotation_none",
34+
cargo_lockfile = "//:Cargo.lock",
35+
lockfile = "//:cargo-bazel-lock_global_alias_annotation_none.json",
36+
)
37+
use_repo(
38+
alias_rule_global_alias_annotation_none,
39+
"alias_rule_global_alias_annotation_none",
40+
)
41+
42+
alias_rule_global_alias_annotation_opt = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
43+
alias_rule_global_alias_annotation_opt.annotation(
44+
alias_rule = "opt",
45+
crate = "test_data_passing_crate",
46+
repositories = ["alias_rule_global_alias_annotation_opt"],
47+
)
48+
alias_rule_global_alias_annotation_opt.spec(
49+
package = "test_data_passing_crate",
50+
repositories = ["alias_rule_global_alias_annotation_opt"],
51+
version = "0.1.0",
52+
)
53+
alias_rule_global_alias_annotation_opt.render_config(
54+
default_alias_rule_name = "alias",
55+
repositories = ["alias_rule_global_alias_annotation_opt"],
56+
)
57+
alias_rule_global_alias_annotation_opt.from_specs(
58+
name = "alias_rule_global_alias_annotation_opt",
59+
cargo_lockfile = "//:Cargo.lock",
60+
lockfile = "//:cargo-bazel-lock_global_alias_annotation_opt.json",
61+
)
62+
use_repo(
63+
alias_rule_global_alias_annotation_opt,
64+
"alias_rule_global_alias_annotation_opt",
65+
)
66+
67+
alias_rule_global_opt_annotation_none = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
68+
alias_rule_global_opt_annotation_none.annotation(
69+
alias_rule = "",
70+
crate = "test_data_passing_crate",
71+
repositories = ["alias_rule_global_opt_annotation_none"],
72+
)
73+
alias_rule_global_opt_annotation_none.spec(
74+
package = "test_data_passing_crate",
75+
repositories = ["alias_rule_global_opt_annotation_none"],
76+
version = "0.1.0",
77+
)
78+
alias_rule_global_opt_annotation_none.render_config(
79+
default_alias_rule_name = "opt",
80+
repositories = ["alias_rule_global_opt_annotation_none"],
81+
)
82+
alias_rule_global_opt_annotation_none.from_specs(
83+
name = "alias_rule_global_opt_annotation_none",
84+
cargo_lockfile = "//:Cargo.lock",
85+
lockfile = "//:cargo-bazel-lock_global_opt_annotation_none.json",
86+
)
87+
use_repo(
88+
alias_rule_global_opt_annotation_none,
89+
"alias_rule_global_opt_annotation_none",
90+
)
91+
92+
alias_rule_global_opt_annotation_alias = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
93+
alias_rule_global_opt_annotation_alias.annotation(
94+
alias_rule = "alias",
95+
crate = "test_data_passing_crate",
96+
repositories = ["alias_rule_global_opt_annotation_alias"],
97+
)
98+
alias_rule_global_opt_annotation_alias.spec(
99+
package = "test_data_passing_crate",
100+
repositories = ["alias_rule_global_opt_annotation_alias"],
101+
version = "0.1.0",
102+
)
103+
alias_rule_global_opt_annotation_alias.render_config(
104+
default_alias_rule_name = "opt",
105+
repositories = ["alias_rule_global_opt_annotation_alias"],
106+
)
107+
alias_rule_global_opt_annotation_alias.from_specs(
108+
name = "alias_rule_global_opt_annotation_alias",
109+
cargo_lockfile = "//:Cargo.lock",
110+
lockfile = "//:cargo-bazel-lock_global_opt_annotation_alias.json",
111+
)
112+
use_repo(
113+
alias_rule_global_opt_annotation_alias,
114+
"alias_rule_global_opt_annotation_alias",
115+
)
116+
117+
alias_rule_global_opt_annotation_dbg = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
118+
alias_rule_global_opt_annotation_dbg.annotation(
119+
alias_rule = "dbg",
120+
crate = "test_data_passing_crate",
121+
repositories = ["alias_rule_global_opt_annotation_dbg"],
122+
)
123+
alias_rule_global_opt_annotation_dbg.spec(
124+
package = "test_data_passing_crate",
125+
repositories = ["alias_rule_global_opt_annotation_dbg"],
126+
version = "0.1.0",
127+
)
128+
alias_rule_global_opt_annotation_dbg.spec(
129+
package = "test_data_passing_crate",
130+
repositories = ["alias_rule_global_opt_annotation_dbg"],
131+
version = "0.1.0",
132+
)
133+
alias_rule_global_opt_annotation_dbg.render_config(
134+
default_alias_rule_name = "opt",
135+
repositories = ["alias_rule_global_opt_annotation_dbg"],
136+
)
137+
alias_rule_global_opt_annotation_dbg.from_specs(
138+
name = "alias_rule_global_opt_annotation_dbg",
139+
cargo_lockfile = "//:Cargo.lock",
140+
lockfile = "//:cargo-bazel-lock_global_opt_annotation_dbg.json",
141+
)
142+
use_repo(
143+
alias_rule_global_opt_annotation_dbg,
144+
"alias_rule_global_opt_annotation_dbg",
145+
)
146+
147+
alias_rule_global_dbg_annotation_fastbuild = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
148+
alias_rule_global_dbg_annotation_fastbuild.annotation(
149+
alias_rule = "fastbuild",
150+
crate = "test_data_passing_crate",
151+
repositories = ["alias_rule_global_dbg_annotation_fastbuild"],
152+
)
153+
alias_rule_global_dbg_annotation_fastbuild.spec(
154+
package = "test_data_passing_crate",
155+
repositories = ["alias_rule_global_dbg_annotation_fastbuild"],
156+
version = "0.1.0",
157+
)
158+
alias_rule_global_dbg_annotation_fastbuild.spec(
159+
package = "test_data_passing_crate",
160+
repositories = ["alias_rule_global_dbg_annotation_fastbuild"],
161+
version = "0.1.0",
162+
)
163+
alias_rule_global_dbg_annotation_fastbuild.render_config(
164+
default_alias_rule_name = "dbg",
165+
repositories = ["alias_rule_global_dbg_annotation_fastbuild"],
166+
)
167+
alias_rule_global_dbg_annotation_fastbuild.from_specs(
168+
name = "alias_rule_global_dbg_annotation_fastbuild",
169+
cargo_lockfile = "//:Cargo.lock",
170+
lockfile = "//:cargo-bazel-lock_global_dbg_annotation_fastbuild.json",
171+
)
172+
use_repo(
173+
alias_rule_global_dbg_annotation_fastbuild,
174+
"alias_rule_global_dbg_annotation_fastbuild",
175+
)
176+
177+
alias_rule_global_custom_annotation_none = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
178+
alias_rule_global_custom_annotation_none.annotation(
179+
alias_rule = "",
180+
crate = "test_data_passing_crate",
181+
repositories = ["alias_rule_global_custom_annotation_none"],
182+
)
183+
alias_rule_global_custom_annotation_none.spec(
184+
package = "test_data_passing_crate",
185+
repositories = ["alias_rule_global_custom_annotation_none"],
186+
version = "0.1.0",
187+
)
188+
alias_rule_global_custom_annotation_none.render_config(
189+
default_alias_rule_bzl = "//:alias_rules.bzl",
190+
default_alias_rule_name = "alias_rule",
191+
repositories = ["alias_rule_global_custom_annotation_none"],
192+
)
193+
alias_rule_global_custom_annotation_none.from_specs(
194+
name = "alias_rule_global_custom_annotation_none",
195+
cargo_lockfile = "//:Cargo.lock",
196+
lockfile = "//:cargo-bazel-lock_global_custom_annotation_none.json",
197+
)
198+
use_repo(
199+
alias_rule_global_custom_annotation_none,
200+
"alias_rule_global_custom_annotation_none",
201+
)

0 commit comments

Comments
 (0)