diff options
author | Alberto Sartori <alberto.sartori@huawei.com> | 2024-06-24 15:49:36 +0200 |
---|---|---|
committer | Klaus Aehlig <klaus.aehlig@huawei.com> | 2024-06-24 15:49:36 +0200 |
commit | f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4 (patch) | |
tree | 24d4a3a5975df2046714c6bc114d5d050bdc61fc /rules/rust/RULES | |
download | rules-rust-f87ad41f72ca4465a0c5b4ba9fd36a7b09e4d4f4.tar.gz |
Initial commit
Co-authored-by: Klaus Aehlig <klaus.aehlig@huawei.com>
Diffstat (limited to 'rules/rust/RULES')
-rw-r--r-- | rules/rust/RULES | 906 |
1 files changed, 906 insertions, 0 deletions
diff --git a/rules/rust/RULES b/rules/rust/RULES new file mode 100644 index 0000000..ebdf34e --- /dev/null +++ b/rules/rust/RULES @@ -0,0 +1,906 @@ +{ "binary": + { "doc": ["A Rust binary."] + , "string_fields": ["name", "edition", "stage", "version", "pkg_name"] + , "target_fields": + ["crate_root", "srcs", "deps", "cargo_features", "build_script"] + , "field_doc": + { "name": ["The name of the crate being built."] + , "build_script": + [ "The \"build_script\" target required to be built and run before" + , "compiling this binary." + ] + , "cargo_features": + ["List of cargo features this binary requires to be enabled."] + , "crate_root": + [ "The crate to be fed to the Rust compiler. It must evaluate to" + , "a single artifact/file." + ] + , "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." + ] + , "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."] + , "stage": + [ "The logical location of the resulting artifact. Elements are" + , "joined with \"/\"." + ] + , "version": + [ "The crate version. Elements are joined with \".\" and the first" + , "three elements are used for the major, minor, and patch" + , "number respectively." + ] + } + , "config_vars": ["ENV"] + , "config_doc": + { "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." + ] + } + , "config_transitions": + { "build_script": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + , "cargo_features": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + , "deps": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + } + , "imports": {"call rustc": "call rustc result", "to rlib": "to rlib"} + , "implicit": {"defaults": ["defaults"]} + , "expression": + { "type": "let*" + , "bindings": + [ ["crate_name", {"type": "FIELD", "name": "name"}] + , ["crate_type", "bin"] + , ["deps-transition", {"type": "CALL_EXPRESSION", "name": "to rlib"}] + , [ "stage" + , { "type": "if" + , "cond": {"type": "FIELD", "name": "stage"} + , "then": + { "type": "join" + , "$1": {"type": "FIELD", "name": "stage"} + , "separator": "/" + } + , "else": "." + } + ] + , ["crate_root", {"type": "FIELD", "name": "crate_root"}] + , ["edition", {"type": "FIELD", "name": "edition"}] + , ["srcs", {"type": "FIELD", "name": "srcs"}] + , ["deps", {"type": "FIELD", "name": "deps"}] + , ["build_script", {"type": "FIELD", "name": "build_script"}] + , ["cargo_features", {"type": "FIELD", "name": "cargo_features"}] + , ["version", {"type": "FIELD", "name": "version"}] + , ["pkg_name", {"type": "FIELD", "name": "pkg_name"}] + , ["defaults", {"type": "FIELD", "name": "defaults"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "call rustc"} + } + } +, "defaults": + { "doc": + [ "A rule to provide defaults." + , "All rust targets take their defaults for RUSTC, TARGET, compile" + , "flags etc." + ] + , "string_fields": + [ "ADD_RUSTC_FLAGS" + , "HOST" + , "LINKER" + , "PATH" + , "RUSTC" + , "RUSTC_FLAGS" + , "TARGET" + , "CARGO_CFG_TARGET_ARCH" + , "CARGO_CFG_TARGET_ENDIAN" + , "CARGO_CFG_TARGET_ENV" + , "CARGO_CFG_TARGET_FAMILY" + , "CARGO_CFG_TARGET_FEATURE" + , "CARGO_CFG_TARGET_HAS_ATOMIC" + , "CARGO_CFG_TARGET_OS" + , "CARGO_CFG_TARGET_POINTER_WIDTH" + , "CARGO_CFG_TARGET_VENDOR" + , "CARGO_CFG_UNIX" + , "CARGO_CFG_WINDOWS" + ] + , "target_fields": ["base"] + , "field_doc": + { "ADD_RUSTC_FLAGS": + [ "Additional flags for rustc. The values are appended to the ones" + , "from \"base\"." + ] + , "CARGO_CFG_TARGET_ARCH": + [ "The CPU target architecture. It overwrites the value from" + , "\"base\"." + ] + , "CARGO_CFG_TARGET_ENDIAN": + ["The CPU target endianness. It overwrites the value from \"base\"."] + , "CARGO_CFG_TARGET_ENV": + ["The target environment ABI. It overwrites the value from", "\"base\"."] + , "CARGO_CFG_TARGET_FAMILY": + ["The target family. It overwrites the value from \"base\"."] + , "CARGO_CFG_TARGET_FEATURE": + [ "List of CPU target features enabled. Elements are joined with" + , "\",\". It overwrites the value from \"base\"." + ] + , "CARGO_CFG_TARGET_HAS_ATOMIC": + [ "List of atomics types (in bits) supported by the target" + , "CPU. Elements are joined with \",\". It overwrites the value from" + , "\"base\"." + ] + , "CARGO_CFG_TARGET_OS": + [ "The target operating system. It overwrites the value from" + , "\"base\"." + ] + , "CARGO_CFG_TARGET_POINTER_WIDTH": + ["The CPU pointer width. It overwrites the value from \"base\"."] + , "CARGO_CFG_TARGET_VENDOR": + ["The target vendor. It overwrites the value from \"base\"."] + , "CARGO_CFG_UNIX": + [ "To be set on unix-like platforms. It overwrites the value from" + , "\"base\"." + ] + , "CARGO_CFG_WINDOWS": + [ "To be set on windows-like platforms. It overwrites the value" + , "from \"base\"." + ] + , "HOST": + [ "The host triple of the Rust compiler (e.g.," + , "\"x86_64-unknown-linux-gnu\"). It overwrites the value from" + , "\"base\"." + ] + , "LINKER": + [ "The value to pass to the \"--linker\" rustc flag. It overwrites" + , "the value from \"base\"." + ] + , "PATH": + [ "Environment variable for looking up compilers and" + , "linkers. Elements are joined with \":\". The values are put in" + , "front of the ones from \"base\"." + ] + , "RUSTC": + ["The Rust compiler to use. It overwrites the value from \"base\"."] + , "RUSTC_FLAGS": + ["The rustc flags to use. It overwrites the value from \"base\"."] + , "TARGET": + [ "The target triple for which the code is compiled (e.g.," + , "\"x86_64-unknown-linux-gnu\"). It overwrites the value from" + , "\"base\"." + ] + , "base": + [ "Other targets of the very same type to inherit values from. If" + , "the same field is defined both targets, depending on the field," + , "the value from \"base\" is extended or overwritten." + ] + } + , "config_vars": ["ARCH", "HOST_ARCH", "TARGET_ARCH"] + , "config_doc": + { "ARCH": + [ "Default value for both HOST_ARCH and TARGET_ARCH. It is user's" + , "responsibility to adapt the \"defaults\" according to the" + , "provided value." + ] + , "HOST_ARCH": + [ "The host CPU architecture. It is user's responsibility to" + , "adapt the \"defaults\" according to the provided value." + ] + , "TARGET_ARCH": + [ "The target CPU architecture. It is user's responsibility to" + , "adapt the \"defaults\" according to the provided value." + ] + } + , "imports": + { "default_from_base": ["./", "..", "default_from_base"] + , "flatten_from_provides": ["./", "..", "flatten_from_provides"] + } + , "expression": + { "type": "let*" + , "bindings": + [ ["base", {"type": "FIELD", "name": "base"}] + , [ "ADD_RUSTC_FLAGS" + , { "type": "++" + , "$1": + [ { "type": "let*" + , "bindings": [["key", "ADD_RUSTC_FLAGS"]] + , "body": + {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + , {"type": "FIELD", "name": "ADD_RUSTC_FLAGS"} + ] + } + ] + , [ "HOST" + , { "type": "let*" + , "bindings": + [["key", "HOST"], ["value", {"type": "FIELD", "name": "HOST"}]] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "LINKER" + , { "type": "let*" + , "bindings": + [["key", "LINKER"], ["value", {"type": "FIELD", "name": "LINKER"}]] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "PATH" + , { "type": "++" + , "$1": + [ {"type": "FIELD", "name": "PATH"} + , { "type": "let*" + , "bindings": [["key", "PATH"]] + , "body": + {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + } + ] + , [ "RUSTC" + , { "type": "let*" + , "bindings": + [["key", "RUSTC"], ["value", {"type": "FIELD", "name": "RUSTC"}]] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "RUSTC_FLAGS" + , { "type": "let*" + , "bindings": + [ ["key", "RUSTC_FLAGS"] + , ["value", {"type": "FIELD", "name": "RUSTC_FLAGS"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "TARGET" + , { "type": "let*" + , "bindings": + [["key", "TARGET"], ["value", {"type": "FIELD", "name": "TARGET"}]] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_ARCH" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_ARCH"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_ARCH"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_ENDIAN" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_ENDIAN"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_ENDIAN"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_ENV" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_ENV"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_ENV"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_FAMILY" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_FAMILY"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_FAMILY"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_FEATURE" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_FEATURE"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_FEATURE"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_HAS_ATOMIC" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_HAS_ATOMIC"] + , [ "value" + , {"type": "FIELD", "name": "CARGO_CFG_TARGET_HAS_ATOMIC"} + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_OS" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_OS"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_OS"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_POINTER_WIDTH" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_POINTER_WIDTH"] + , [ "value" + , {"type": "FIELD", "name": "CARGO_CFG_TARGET_POINTER_WIDTH"} + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_TARGET_VENDOR" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_TARGET_VENDOR"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_TARGET_VENDOR"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_UNIX" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_UNIX"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_UNIX"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + , [ "CARGO_CFG_WINDOWS" + , { "type": "let*" + , "bindings": + [ ["key", "CARGO_CFG_WINDOWS"] + , ["value", {"type": "FIELD", "name": "CARGO_CFG_WINDOWS"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "default_from_base"} + } + ] + ] + , "body": + { "type": "RESULT" + , "provides": + { "type": "env" + , "vars": + [ "ADD_RUSTC_FLAGS" + , "HOST" + , "LINKER" + , "PATH" + , "RUSTC" + , "RUSTC_FLAGS" + , "TARGET" + , "CARGO_CFG_TARGET_ARCH" + , "CARGO_CFG_TARGET_ENDIAN" + , "CARGO_CFG_TARGET_ENV" + , "CARGO_CFG_TARGET_FAMILY" + , "CARGO_CFG_TARGET_FEATURE" + , "CARGO_CFG_TARGET_HAS_ATOMIC" + , "CARGO_CFG_TARGET_OS" + , "CARGO_CFG_TARGET_POINTER_WIDTH" + , "CARGO_CFG_TARGET_VENDOR" + , "CARGO_CFG_UNIX" + , "CARGO_CFG_WINDOWS" + ] + } + } + } + } +, "library": + { "doc": + [ "A Rust library. Depending on the value of the fields \"shared\"" + , "and \"native\", the `--crate-type` is inferred as follows:" + , "" + , "|shared|native|crate-type|" + , "|------|------|----------|" + , "| null | null | rlib |" + , "| null |\"true\"| staticlib|" + , "|\"true\"| null | dylib |" + , "|\"true\"|\"true\"| cdylib |" + ] + , "string_fields": + ["name", "edition", "stage", "version", "pkg_name", "shared", "native"] + , "target_fields": + ["crate_root", "srcs", "deps", "cargo_features", "build_script", "c_hdrs"] + , "field_doc": + { "name": ["The name of the crate being built."] + , "build_script": + [ "The \"build_script\" target required to be built and run before" + , "compiling this library." + ] + , "c_hdrs": + [ "C headers that define the interface to this library." + , "This field is ignored when this library is consumed by another" + , "Rust target." + , "" + , "If non empty, a native library will be produced." + ] + , "cargo_features": + ["List of cargo features this library requires to be enabled."] + , "crate_root": + [ "The crate to be fed to the Rust compiler. It must evaluate to" + , "a single artifact/file." + ] + , "defaults": ["The Rust toolchain to use."] + , "deps": ["Any other libraries this library depends upon."] + , "edition": + [ "The edition of the compiler to use during compilation." + , "If unset, 2015 is used." + ] + , "native": + [ "If not null, a native library will be produced." + , "" + , "Note that, when this target is consumed by another Rust target," + , "it will be compiled to a Rust static library (.rlib)." + ] + , "pkg_name": + [ "The name of the package the crate belongs to. It is" + , "exported to the CARGO_PKG_NAME environment variable." + ] + , "shared": ["If not null, a shared library will be produced."] + , "srcs": ["The source files of the library."] + , "stage": + [ "The logical location of the resulting artifact." + , "Elements are joined with \"/\"." + ] + , "version": + [ "The crate version. Elements are joined with \".\" and the first" + , "three elements are used for the major, minor, and patch" + , "number respectively." + ] + } + , "config_vars": ["ENV", "RLIB"] + , "config_doc": + { "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." + ] + , "RLIB": + [ "If evaluates to true, the \"shared\" and \"native\" fields are" + , "ignored and the crate type will be set to rlib." + ] + } + , "config_transitions": + { "build_script": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + , "cargo_features": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + , "deps": [{"type": "CALL_EXPRESSION", "name": "to rlib"}] + } + , "imports": + { "call rustc": "call rustc result" + , "get_artifacts": ["./", "..", "get_artifacts"] + , "to rlib": "to rlib" + } + , "implicit": {"defaults": ["defaults"]} + , "expression": + { "type": "let*" + , "bindings": + [ ["crate_name", {"type": "FIELD", "name": "name"}] + , [ "native" + , { "type": "or" + , "$1": + [ {"type": "FIELD", "name": "c_hdrs"} + , {"type": "FIELD", "name": "native"} + ] + } + ] + , [ "crate_type" + , { "type": "if" + , "cond": {"type": "var", "name": "RLIB"} + , "then": "rlib" + , "else": + { "type": "if" + , "cond": {"type": "FIELD", "name": "shared"} + , "then": + { "type": "if" + , "cond": {"type": "var", "name": "native"} + , "then": "cdylib" + , "else": "dylib" + } + , "else": + { "type": "if" + , "cond": {"type": "var", "name": "native"} + , "then": "staticlib" + , "else": "rlib" + } + } + } + ] + , ["deps-transition", {"type": "CALL_EXPRESSION", "name": "to rlib"}] + , [ "stage" + , { "type": "if" + , "cond": {"type": "FIELD", "name": "stage"} + , "then": + { "type": "join" + , "$1": {"type": "FIELD", "name": "stage"} + , "separator": "/" + } + , "else": "." + } + ] + , [ "c_hdrs" + , { "type": "to_subdir" + , "subdir": {"type": "var", "name": "stage"} + , "flat": false + , "$1": + { "type": "let*" + , "bindings": + [ [ "field_content" + , { "type": "if" + , "cond": {"type": "var", "name": "RLIB"} + , "then": [] + , "else": {"type": "FIELD", "name": "c_hdrs"} + } + ] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "get_artifacts"} + } + } + ] + , ["crate_root", {"type": "FIELD", "name": "crate_root"}] + , ["edition", {"type": "FIELD", "name": "edition"}] + , ["srcs", {"type": "FIELD", "name": "srcs"}] + , ["deps", {"type": "FIELD", "name": "deps"}] + , ["build_script", {"type": "FIELD", "name": "build_script"}] + , ["cargo_features", {"type": "FIELD", "name": "cargo_features"}] + , ["version", {"type": "FIELD", "name": "version"}] + , ["pkg_name", {"type": "FIELD", "name": "pkg_name"}] + , ["defaults", {"type": "FIELD", "name": "defaults"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "call rustc"} + } + } +, "proc-macro": + { "doc": + [ "A Rust procedural macro. As it is executed on the host system" + , "during the compilation, it is always compiled according to the" + , "host configuration." + ] + , "string_fields": ["name", "edition", "stage", "version", "pkg_name"] + , "target_fields": + ["crate_root", "srcs", "deps", "cargo_features", "build_script"] + , "field_doc": + { "name": ["The name of the crate being built."] + , "build_script": + [ "The \"build_script\" target required to be built and run before" + , "compiling this macro." + ] + , "cargo_features": + ["List of cargo features this macro requires to be enabled."] + , "crate_root": + [ "The crate to be fed to the Rust compiler. It must evaluate to" + , "a single artifact/file." + ] + , "defaults": ["The Rust toolchain to use."] + , "deps": ["Any other libraries this macro depends upon."] + , "edition": + [ "The edition of the compiler to use during compilation. If" + , "unset, 2015 is used." + ] + , "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 procedural macro."] + , "stage": + [ "The logical location of the resulting artifact. Elements are" + , "joined with \"/\"." + ] + , "version": + [ "The crate version. Elements are joined with \".\" and the first" + , "three elements are used for the major, minor, and patch" + , "number respectively." + ] + } + , "config_vars": ["ARCH", "HOST_ARCH", "ENV"] + , "config_doc": + { "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." + ] + } + , "config_transitions": + { "build_script": [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}] + , "cargo_features": + [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}] + , "crate_root": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "defaults": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "deps": [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}] + , "srcs": [{"type": "CALL_EXPRESSION", "name": "for host"}] + } + , "imports": + { "call rustc": "call rustc result" + , "for host": "for host" + , "for host as rlib": ["./", "../rust", "for host as rlib"] + , "to rlib": "to rlib" + } + , "implicit": {"defaults": ["defaults"]} + , "expression": + { "type": "let*" + , "bindings": + [ ["crate_name", {"type": "FIELD", "name": "name"}] + , ["crate_type", "proc-macro"] + , [ "stage" + , { "type": "if" + , "cond": {"type": "FIELD", "name": "stage"} + , "then": + { "type": "join" + , "$1": {"type": "FIELD", "name": "stage"} + , "separator": "/" + } + , "else": "." + } + ] + , ["crate_root", {"type": "FIELD", "name": "crate_root"}] + , ["edition", {"type": "FIELD", "name": "edition"}] + , ["srcs", {"type": "FIELD", "name": "srcs"}] + , ["deps", {"type": "FIELD", "name": "deps"}] + , [ "deps-transition" + , {"type": "CALL_EXPRESSION", "name": "for host as rlib"} + ] + , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}] + , ["version", {"type": "FIELD", "name": "version"}] + , ["pkg_name", {"type": "FIELD", "name": "pkg_name"}] + , ["build_script", {"type": "FIELD", "name": "build_script"}] + , ["cargo_features", {"type": "FIELD", "name": "cargo_features"}] + , ["defaults", {"type": "FIELD", "name": "defaults"}] + ] + , "body": {"type": "CALL_EXPRESSION", "name": "call rustc"} + } + } +, "test": + { "doc": ["A Rust test."] + , "string_fields": + ["name", "edition", "stage", "version", "args", "pkg_name"] + , "target_fields": ["crate_root", "srcs", "deps", "cargo_features", "data"] + , "field_doc": + { "name": + [ "The name of the test being built. Note that during execution," + , "the test binary will be restaged to \"test\"." + ] + , "args": ["Additonal arguments to be passed when running the test."] + , "cargo_features": + ["List of cargo features this test requires to be enabled."] + , "crate_root": + [ "The crate to be fed to the Rust compiler. It must evaluate to" + , "a single artifact/file." + ] + , "data": ["Any files and directories the test binary needs when running."] + , "defaults": ["The Rust toolchain to use."] + , "deps": ["Any other libraries this test depends upon."] + , "edition": + [ "The edition of the compiler to use during compilation. If" + , "unset, 2015 is used." + ] + , "pkg_name": + [ "The name of the package the crate belongs to. It is" + , "exported to the CARGO_PKG_NAME environment variable." + ] + , "runner": + [ "The test runner to use, i.e., the binary that will launch the" + , "test binary and collect the output." + ] + , "srcs": ["The source files of the test."] + , "stage": + [ "The logical location of the resulting artifact. Elements are" + , "joined with \"/\"." + ] + , "version": + [ "The crate version. Elements are joined with \".\" and the first" + , "three elements are used for the major, minor, and patch" + , "number respectively." + ] + } + , "config_vars": ["RUST_TEST_LAUNCHER", "ARCH", "HOST_ARCH", "ENV"] + , "config_doc": + { "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." + ] + , "RUST_TEST_LAUNCHER": + [ "List of strings representing the launcher that is prepended to" + , "the command line for running the test binary." + ] + } + , "config_transitions": + { "cargo_features": + [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}] + , "crate_root": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "data": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "defaults": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "deps": [{"type": "CALL_EXPRESSION", "name": "for host as rlib"}] + , "runner": [{"type": "CALL_EXPRESSION", "name": "for host"}] + , "srcs": [{"type": "CALL_EXPRESSION", "name": "for host"}] + } + , "imports": + { "call rustc artifact": "call rustc artifact" + , "for host": "for host" + , "for host as rlib": ["./", "../rust", "for host as rlib"] + , "get_artifacts": ["./", "..", "get_artifacts"] + , "get_runfiles": ["./", "..", "get_runfiles"] + , "get_unique_artifact": ["./", "..", "get_unique_artifact"] + , "stage_unique_artifact": ["./", "..", "stage_unique_artifact"] + } + , "implicit": {"defaults": ["defaults"], "runner": ["runner.py"]} + , "expression": + { "type": "let*" + , "bindings": + [ ["crate_name", {"type": "FIELD", "name": "name"}] + , ["crate_type", "bin"] + , [ "stage" + , { "type": "if" + , "cond": {"type": "FIELD", "name": "stage"} + , "then": + { "type": "join" + , "$1": {"type": "FIELD", "name": "stage"} + , "separator": "/" + } + , "else": "." + } + ] + , ["crate_root", {"type": "FIELD", "name": "crate_root"}] + , ["edition", {"type": "FIELD", "name": "edition"}] + , ["srcs", {"type": "FIELD", "name": "srcs"}] + , ["deps", {"type": "FIELD", "name": "deps"}] + , ["cargo_features", {"type": "FIELD", "name": "cargo_features"}] + , ["emit", "link"] + , [ "deps-transition" + , {"type": "CALL_EXPRESSION", "name": "for host as rlib"} + ] + , ["transition", {"type": "CALL_EXPRESSION", "name": "for host"}] + , ["test", true] + , ["version", {"type": "FIELD", "name": "version"}] + , ["pkg_name", {"type": "FIELD", "name": "pkg_name"}] + , ["defaults", {"type": "FIELD", "name": "defaults"}] + , [ "artifact result" + , {"type": "CALL_EXPRESSION", "name": "call rustc artifact"} + ] + , [ "test" + , { "type": "let*" + , "bindings": + [ [ "artifact" + , { "type": "lookup" + , "key": "artifact" + , "map": {"type": "var", "name": "artifact result"} + } + ] + , ["name", "test"] + ] + , "body": + {"type": "CALL_EXPRESSION", "name": "stage_unique_artifact"} + } + ] + , [ "runner" + , { "type": "let*" + , "bindings": + [ [ "artifact" + , { "type": "let*" + , "bindings": + [ ["field_name", "runner"] + , ["field_content", {"type": "FIELD", "name": "runner"}] + ] + , "body": + {"type": "CALL_EXPRESSION", "name": "get_unique_artifact"} + } + ] + , ["name", "runner"] + ] + , "body": + {"type": "CALL_EXPRESSION", "name": "stage_unique_artifact"} + } + ] + , ["field_content", {"type": "FIELD", "name": "data"}] + , [ "test-data" + , { "type": "to_subdir" + , "subdir": "work" + , "flat": false + , "$1": + { "type": "disjoint_map_union" + , "$1": + [ {"type": "CALL_EXPRESSION", "name": "get_artifacts"} + , {"type": "CALL_EXPRESSION", "name": "get_runfiles"} + ] + } + } + ] + , [ "test-launcher" + , { "type": "singleton_map" + , "key": "test-launcher.json" + , "value": + { "type": "BLOB" + , "data": + { "type": "json_encode" + , "$1": + {"type": "var", "name": "RUST_TEST_LAUNCHER", "default": []} + } + } + } + ] + , [ "test-args" + , { "type": "singleton_map" + , "key": "test-args.json" + , "value": + { "type": "BLOB" + , "data": + {"type": "json_encode", "$1": {"type": "FIELD", "name": "args"}} + } + } + ] + , [ "test-name" + , {"type": "join", "$1": {"type": "var", "name": "crate_name"}} + ] + , [ "test-results" + , { "type": "ACTION" + , "outs": ["result", "stdout", "stderr", "time-start", "time-stop"] + , "inputs": + { "type": "map_union" + , "$1": + [ {"type": "var", "name": "test"} + , {"type": "var", "name": "runner"} + , {"type": "var", "name": "test-data"} + , {"type": "var", "name": "test-launcher"} + , {"type": "var", "name": "test-args"} + ] + } + , "cmd": ["./runner"] + , "env": + { "type": "lookup" + , "key": "env" + , "map": {"type": "var", "name": "artifact result"} + } + , "may_fail": ["test"] + , "fail_message": + { "type": "join" + , "$1": + ["rust test", {"type": "var", "name": "test-name"}, "failed"] + , "separator": " " + } + } + ] + ] + , "body": + { "type": "RESULT" + , "artifacts": {"type": "var", "name": "test-results"} + , "runfiles": + { "type": "singleton_map" + , "key": {"type": "var", "name": "test-name"} + , "value": + {"type": "TREE", "$1": {"type": "var", "name": "test-results"}} + } + } + } + , "tainted": ["test"] + } +} |