summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2025-06-26 11:52:13 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2025-06-26 12:55:33 +0200
commit11a3709d3b28c2fc89778e46b4e8727ebc86ebac (patch)
tree4ae0cb86300182105141ef691017e6a5d1d8f5a3
parentb590ae80ab6c2fc1e01f1baa9f48d6da0c7d0a70 (diff)
downloadrules-rust-11a3709d3b28c2fc89778e46b4e8727ebc86ebac.tar.gz
["cargo", "build_script"]: support "extra_data"
Build scripts often require additional data; therefore, extend the rule by a field "extra_data" that will be available when running the build script.
-rw-r--r--README.md1
-rw-r--r--rules/cargo/RULES21
2 files changed, 19 insertions, 3 deletions
diff --git a/README.md b/README.md
index b24091e..6b77398 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,7 @@ provided by the "defaults" for the "HOST_ARCH".
| `"defaults"` | The Rust toolchain to use. |
| `"deps"` | Any other libraries this binary depends upon. |
| `"edition"` | The edition of the compiler to use during compilation. If unset, 2015 is used. |
+| `"extra_data"` | Extra files needed while running the build script. |
| `"name"` | The name of the crate being built. |
| `"pkg_name"` | The name of the package the crate belongs to. It is exported to the CARGO_PKG_NAME environment variable. |
| `"srcs"` | The source files of the binary. |
diff --git a/rules/cargo/RULES b/rules/cargo/RULES
index 59ef326..dd48c4d 100644
--- a/rules/cargo/RULES
+++ b/rules/cargo/RULES
@@ -8,7 +8,8 @@
, "provided by the \"defaults\" for the \"HOST_ARCH\"."
]
, "string_fields": ["name", "edition", "stage", "version", "pkg_name"]
- , "target_fields": ["crate_root", "srcs", "deps", "cargo_features"]
+ , "target_fields":
+ ["crate_root", "srcs", "deps", "cargo_features", "extra_data"]
, "field_doc":
{ "name": ["The name of the crate being built."]
, "cargo_features":
@@ -37,6 +38,7 @@
, "three elements are used for the major, minor, and patch"
, "number respectively."
]
+ , "extra_data": ["Extra files needed while running the build script."]
}
, "config_vars": ["ARCH", "HOST_ARCH", "ENV"]
, "config_doc":
@@ -68,7 +70,7 @@
{ "call rustc artifact": ["./", "../rust", "call rustc artifact"]
, "for host": ["./", "../rust", "for host"]
, "for host as rlib": ["./", "../rust", "for host as rlib"]
- , "get_runfiles": ["./", "..", "get_runfiles"]
+ , "get_artifacts": ["./", "..", "get_artifacts"]
}
, "implicit": {"defaults": [["./", "../rust", "defaults"]]}
, "expression":
@@ -134,6 +136,13 @@
, "map": {"type": "var", "name": "artifact result"}
}
]
+ , [ "extra_data"
+ , { "type": "let*"
+ , "bindings":
+ [["field_content", {"type": "FIELD", "name": "extra_data"}]]
+ , "body": {"type": "CALL_EXPRESSION", "name": "get_artifacts"}
+ }
+ ]
, [ "out_name"
, { "type": "join"
, "$1": [{"type": "var", "name": "stage"}, "out"]
@@ -143,7 +152,13 @@
, [ "out"
, { "type": "ACTION"
, "outs": [{"type": "var", "name": "out_name"}]
- , "inputs": {"type": "var", "name": "exe"}
+ , "inputs":
+ { "type": "map_union"
+ , "$1":
+ [ {"type": "var", "name": "extra_data"}
+ , {"type": "var", "name": "exe"}
+ ]
+ }
, "cmd":
[ "sh"
, "-ce"