blob: a6e4ab9b51d63ba5be20e0678a82a1aea1c6c18f [file] [log] [blame]
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "system_bt_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["system_bt_license"],
}
rust_defaults {
name: "pdl_defaults",
// LINT.IfChange
rustlibs: [
"libclap",
"libcodespan_reporting",
"libpest",
"libproc_macro2",
"libquote",
"libserde",
"libserde_json",
"libsyn",
"libtempfile",
],
proc_macros: [
"libpest_derive",
],
// LINT.ThenChange(Cargo.toml)
}
rust_binary_host {
name: "pdl",
defaults: ["pdl_defaults"],
srcs: ["src/main.rs"],
}
rust_test_host {
name: "pdl_inline_tests",
defaults: ["pdl_defaults"],
srcs: ["src/main.rs"],
test_suites: ["general-tests"],
enabled: false, // rustfmt is only available on x86.
arch: {
x86_64: {
enabled: true,
},
},
data: [
":rustfmt",
":rustfmt.toml",
"tests/generated/packet_decl_complex_big_endian.rs",
"tests/generated/packet_decl_complex_little_endian.rs",
"tests/generated/packet_decl_empty.rs",
"tests/generated/packet_decl_simple_big_endian.rs",
"tests/generated/packet_decl_simple_little_endian.rs",
"tests/generated/preamble.rs",
],
}
rust_test_host {
name: "pdl_tests",
defaults: ["pdl_defaults"],
srcs: ["tests/pdl_tests.rs"],
test_suites: ["general-tests"],
enabled: false, // rustfmt is only available on x86.
arch: {
x86_64: {
enabled: true,
},
},
data: [
":bluetooth_packetgen",
":pdl",
":rustfmt",
":rustfmt.toml",
],
}
// Defaults for PDL python backend generation.
genrule_defaults {
name: "pdl_python_generator_defaults",
tools: [
":pdl",
":pdl_python_generator",
],
}
// Generate the python parser+serializer backend for the
// little endian test file located at tests/canonical/le_test_file.pdl.
genrule {
name: "pdl_python_generator_le_test_gen",
defaults: ["pdl_python_generator_defaults"],
cmd: "$(location :pdl) $(in) |" +
" $(location :pdl_python_generator)" +
" --output $(out) --custom-type-location tests.custom_types",
tool_files: [
"tests/custom_types.py",
],
srcs: [
"tests/canonical/le_test_file.pdl",
],
out: [
"le_pdl_test.py",
],
}
// Generate the python parser+serializer backend for the
// big endian test file located at tests/canonical/be_test_file.pdl.
genrule {
name: "pdl_python_generator_be_test_gen",
defaults: ["pdl_python_generator_defaults"],
cmd: "$(location :pdl) $(in) |" +
" $(location :pdl_python_generator)" +
" --output $(out) --custom-type-location tests.custom_types",
tool_files: [
"tests/custom_types.py",
],
srcs: [
"tests/canonical/be_test_file.pdl",
],
out: [
"be_pdl_test.py",
],
}
// Test the generated python parser+serializer against
// pre-generated binary inputs.
python_test_host {
name: "pdl_python_generator_test",
main: "tests/python_generator_test.py",
srcs: [
":pdl_python_generator_be_test_gen",
":pdl_python_generator_le_test_gen",
"tests/custom_types.py",
"tests/python_generator_test.py",
],
data: [
"tests/canonical/be_test_vectors.json",
"tests/canonical/le_test_vectors.json",
],
libs: [
"typing_extensions",
],
test_options: {
unit_test: true,
},
version: {
py3: {
embedded_launcher: true,
},
},
}
// Test the python parser against the rust parser
// on selected PDL source files.
python_test_host {
name: "pdl_python_parser_test",
main: "tests/python_parser_test.py",
srcs: ["tests/python_parser_test.py"],
data: [
":BluetoothHciPackets",
":RootCanalLinkLayerPackets",
":pdl",
":pypdl",
],
}