Skip to content

Commit 269dd8b

Browse files
committed
Add ARCHITECTURE.md
1 parent c21d894 commit 269dd8b

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

ARCHITECTURE.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Rules Rust - Architecture
2+
3+
In this file we describe how we think about the architecture
4+
of `rules_rust`. It's goal is to help contributors orient themselves, and to
5+
document code restrictions and assumptions.
6+
7+
In general we try to follow the common standard defined by
8+
https://docs.bazel.build/versions/master/skylark/deploying.html.
9+
10+
## //rust
11+
12+
This is the core package of the rules. It contains all the core rules such as
13+
`rust_binary` and `rust_library`. It also contains `rust_common`, a Starlark
14+
struct providing all rules_rust APIs that one might need when writing custom
15+
rules integrating with rules_rust.
16+
17+
`//rust` and all its subpackages have to be standalone. Users who only need
18+
the core rules should be able to ignore all other packages.
19+
20+
`//rust:defs.bzl` is the file that all users of `rules_rust` will be using.
21+
Everything in this file can be used (dependend on) and is supported. Typically
22+
this file reexports definitions from other files, typically from
23+
`//rust/private`. Also other packages in `rules_rust` should access core rules
24+
through the public API only. We expect dogfooding our own APIs increases their
25+
quality.
26+
27+
`//rust/private` package contains code rule implementation. This file can only
28+
depend on `//rust` and its subpackages. Exceptions are Bazel's builtin packages
29+
and public APIs of other rules (such as `rules_cc`). Depending on
30+
`//rust/private` from packages other than `//rust` is not supported, we reserve
31+
the right to change anything there and not tell anybody.
32+
33+
When core rules need custom tools (such as process wrapper, launcher, test
34+
runner, and so on), they should be stored in `//rust/tools` (for public tools)
35+
or in `//rust/private/tools` (for private tools). These should:
36+
37+
* be essential (it does not make sense to have core rules without them)
38+
* have few or no third party dependencies, and their third party dependencies
39+
should be checked in.
40+
* be usable for cross compilation
41+
* have only essential requirements on the host system (requiring that a custom
42+
library is installed on the system is frowned upon)
43+
44+
## //examples (@examples)
45+
46+
Examples package is actually a local repository. This repository can have
47+
additional dependencies on anything that helps demonstrate an example. Non
48+
trivial examples should have an accompanying README.md file.
49+
50+
The goal of examples is to demonstrate usage of `rules_rust`, not to test code.
51+
Use `//test` for testing.
52+
53+
## //test
54+
55+
Contains unit (in `//test/unit`) and integration tests. CI configuration is
56+
stored in .bazelci.

0 commit comments

Comments
 (0)