Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8b5e93cc authored by Martin Geisler's avatar Martin Geisler Committed by Gerrit Code Review
Browse files

Merge "pdl: Ensure that all generated files compile"

parents a77ee7b9 5ea1c526
Loading
Loading
Loading
Loading
+41 −17
Original line number Diff line number Diff line
@@ -38,23 +38,9 @@ rust_binary_host {
    ],
}

rust_test_host {
    name: "pdl_tests",
    defaults: ["pdl_defaults"],
    srcs: ["src/main.rs"],
    proc_macros: [
        "libpaste",
    ],
    test_suites: ["general-tests"],
    enabled: false, // rustfmt is only available on x86.
    arch: {
        x86_64: {
            enabled: true,
        },
    },
    data: [
        ":rustfmt",
        ":rustfmt.toml",
filegroup {
    name: "pdl_generated_files",
    srcs: [
        "tests/generated/packet_decl_8bit_enum_array_big_endian.rs",
        "tests/generated/packet_decl_8bit_enum_array_little_endian.rs",
        "tests/generated/packet_decl_8bit_enum_big_endian.rs",
@@ -119,6 +105,44 @@ rust_test_host {
    ],
}

rust_test_host {
    name: "pdl_tests",
    defaults: ["pdl_defaults"],
    srcs: ["src/main.rs"],
    proc_macros: [
        "libpaste",
    ],
    test_suites: ["general-tests"],
    enabled: false, // rustfmt is only available on x86.
    arch: {
        x86_64: {
            enabled: true,
        },
    },
    data: [
        ":rustfmt",
        ":rustfmt.toml",
        ":pdl_generated_files",
    ],
}

genrule {
    name: "pdl_generated_files_compile_rs",
    cmd: "$(location tests/generated_files_compile.sh) $(in) > $(out)",
    srcs: [":pdl_generated_files"],
    out: ["generated_files_compile.rs"],
    tool_files: ["tests/generated_files_compile.sh"],
}

rust_test_host {
    name: "pdl_generated_files_compile",
    srcs: [":pdl_generated_files_compile_rs"],
    test_suites: ["general-tests"],
    clippy_lints: "none",
    lints: "none",
    defaults: ["pdl_backend_defaults"],
}

genrule_defaults {
    name: "pdl_rust_generator_defaults",
    cmd: "set -o pipefail;" +
+23 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

# Run this script with a number of Rust files as input. It will combine them to
# a single file which you can compile to check the validity of the inputs.
#
# For a Cargo based workflow, you can run
#
# ./generated_files_compile.sh generated/*.rs > generated_files.rs
#
# followed by cargo test.

for input_path in "$@"; do
    echo "mod $(basename -s .rs "$input_path") {"
    cat "$input_path"
    echo "}"
done

cat <<EOF
#[test]
fn generated_files_compile() {
    // Empty test, we only want to see that things compile.
}
EOF