Skip to content

Commit d91ac45

Browse files
committed
crate_universe rule
This rule dynamically looks up crate dependencies as a repository rule. See #2 for context.
1 parent fee3b3c commit d91ac45

Some content is hidden

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

50 files changed

+9535
-2
lines changed

WORKSPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ examples_repositories()
6363

6464
load("@examples//:examples_deps.bzl", examples_deps = "deps")
6565

66-
examples_deps()
66+
examples_deps(is_top_level = True)
6767

6868
load("@examples//:examples_transitive_deps.bzl", examples_transitive_deps = "transitive_deps")
6969

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing
2+
3+
## Tour of the codebase
4+
5+
We start at `workspace.bzl`, which invokes the resolver.
6+
7+
The resolver:
8+
* `config.rs`: Deserializes the Config
9+
* `parser.rs`: Parses the Config, any `Cargo.toml` files, and any additional packages, into a single unified `Cargo.toml` file
10+
* `resolver.rs`: Resolves all of the crates.
11+
* `consolidator.rs`: Patches in any WORKSPACE-specified overrides, and deals with platform-specific concerns.
12+
* `renderer.rs`: Generates BUILD files for each crate, as well as functions that can be called from BUILD files.
13+
14+
The code started off as a very hacky Week of Code project, and there are some clear remnants of that in the codebase - nothing is sacred, feel free to improve anything!
15+
16+
Some areas have unit testing, there are a few (very brittle) integration tests, and some examples.
17+
18+
## How to test local changes
19+
20+
To use a local version, first build it:
21+
```console
22+
resolver $ cargo build
23+
```
24+
25+
Then run a bazel build with this environment variable:
26+
```console
27+
RULES_RUST_RESOLVER_URL_OVERRIDE=file:///path/to/resolver/target/debug/resolver bazel build //whatever
28+
```
29+
30+
To get verbose logging, edit `workspace.bzl` to set `RUST_LOG` to `debug` or `trace` instead of `info`. In particular, that will print out the generated Cargo.toml, and the path to the generated workspace file.
31+
32+
Note that you may need to `bazel shutdown` between bazel commands. Hopefully not, but if you're seeing stale results, try it out. This only affects local development.
33+
34+
## Testing
35+
36+
To test with the `resolver` built from source:
37+
38+
```bash
39+
bin/test
40+
```

0 commit comments

Comments
 (0)