diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-07-25 17:48:54 +0200 |
---|---|---|
committer | Alberto Sartori <alberto.sartori@huawei.com> | 2024-07-26 16:38:48 +0200 |
commit | bd6ede41a6793ae1ef9a7feb4cadb8469b8fa284 (patch) | |
tree | a59b6b8e87bffa14c6dbb67e8e555240bf44bf66 | |
parent | c4c9726158431d053af919db13fa6b812f1e4773 (diff) | |
download | rules-rust-bd6ede41a6793ae1ef9a7feb4cadb8469b8fa284.tar.gz |
rules-rust: Add configuration variables documentation
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | etc/gen_readme.py | 28 |
2 files changed, 36 insertions, 3 deletions
@@ -175,3 +175,14 @@ provided by the "defaults" for the "HOST_ARCH". | `"deps"` | Any other features or "[rust, library]" this feature depends on. | | `"name"` | The feature name. The flag `--cfg feature=<name>` is passed to the Rust compiler. | +### Configuration variables + +| Variable | Description | +| -------- | ----------- | +| `"ARCH"` | Default value for both HOST_ARCH and TARGET_ARCH. It is user's responsibility to adapt the "defaults" according to the provided value. | +| `"ENV"` | Additional environment variables (besides ones provided by the "defaults" target) to be set for each action. If the same variable is set here and in the "defaults", the former is taken. | +| `"HOST_ARCH"` | The host CPU architecture. It is user's responsibility to adapt the "defaults" according to the provided value. | +| `"RLIB"` | If evaluates to true, the "shared" and "native" fields are ignored and the crate type will be set to rlib. | +| `"RUST_TEST_LAUNCHER"` | List of strings representing the launcher that is prepended to the command line for running the test binary. | +| `"TARGET_ARCH"` | The target CPU architecture. It is user's responsibility to adapt the "defaults" according to the provided value. | + diff --git a/etc/gen_readme.py b/etc/gen_readme.py index adfeb3b..4dc2cf9 100644 --- a/etc/gen_readme.py +++ b/etc/gen_readme.py @@ -2,8 +2,12 @@ import json import os from typing import List -def lines(doc:List[str]): - return '\n'.join(doc) +config_vars = {} + + +def lines(doc: List[str]): + return "\n".join(doc) + def gen_doc(dir: str, f): @@ -11,7 +15,12 @@ def gen_doc(dir: str, f): rules = json.load(r) for k, v in sorted(rules.items()): - print(f"### `[\"{os.path.basename(dir)}\", \"{k}\"]`\n\n {lines(v['doc'])}\n", file=f) + global config_vars + config_vars.update(v.get("config_doc", {})) + print( + f"### `[\"{os.path.basename(dir)}\", \"{k}\"]`\n\n {lines(v['doc'])}\n", + file=f, + ) print("| Field | Description |", file=f) print("| ----- | ----------- |", file=f) for field, doc in sorted(v["field_doc"].items()): @@ -19,6 +28,18 @@ def gen_doc(dir: str, f): print(file=f) +def print_config_vars(f): + print( + f"### Configuration variables\n", + file=f, + ) + print("| Variable | Description |", file=f) + print("| -------- | ----------- |", file=f) + for v, doc in sorted(config_vars.items()): + print(f"| `\"{v}\"` | {' '.join(doc)} |", file=f) + print(file=f) + + def main(): with open("README.md", "w") as f: print( @@ -57,6 +78,7 @@ your `repos.json`. ) gen_doc("rules/rust", f) gen_doc("rules/cargo", f) + print_config_vars(f) main() |