| # Copyright 2026 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| load("//build/bazel/rules/host_tests:host_rustc_test.bzl", "wrap_host_rust_test") | |
| load("//build/bazel/rules/rust:rustc_library.bzl", "rustc_library") | |
| load("//build/bazel/rules/rust:rustc_test.bzl", "rustc_test") | |
| load("//build/bazel/rules/testing:fx_unittest_package.bzl", "fx_unittest_package") | |
| load( | |
| "//src/tests/fidl/conformance_suite:gidl_conformance_suite.bzl", | |
| "CONFORMANCE_SUITE_FIDL_TARGET", | |
| "CONFORMANCE_SUITE_GIDL_FILES", | |
| ) | |
| load("//tools/fidl/gidl:gidl.bzl", "gidl") | |
| package(default_applicable_licenses = ["//:license"]) | |
| rustc_library( | |
| name = "fidl_codec", | |
| srcs = [ | |
| "src/decode.rs", | |
| "src/encode.rs", | |
| "src/error.rs", | |
| "src/handle.rs", | |
| "src/handle/classic.rs", | |
| "src/lib.rs", | |
| "src/library.rs", | |
| "src/transaction.rs", | |
| "src/util.rs", | |
| "src/value.rs", | |
| ], | |
| crate_features = ["classic"], | |
| edition = "2024", | |
| proc_macro_deps = [ | |
| "//third_party/rust_crates/vendor:serde_derive", | |
| ], | |
| visibility = ["//src:__subpackages__"], | |
| with_unit_tests = True, | |
| deps = [ | |
| "//sdk/rust/fidl-data-zx", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fidl/rust_constants", | |
| "//third_party/rust_crates/vendor:bitflags", | |
| "//third_party/rust_crates/vendor:nom", | |
| "//third_party/rust_crates/vendor:serde", | |
| "//third_party/rust_crates/vendor:serde_json", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| ], | |
| ) | |
| rustc_library( | |
| name = "fidl_codec_fdomain", | |
| srcs = [ | |
| "src/decode.rs", | |
| "src/encode.rs", | |
| "src/error.rs", | |
| "src/handle.rs", | |
| "src/handle/fdomain.rs", | |
| "src/lib.rs", | |
| "src/library.rs", | |
| "src/transaction.rs", | |
| "src/util.rs", | |
| "src/value.rs", | |
| ], | |
| crate_features = ["fdomain"], | |
| edition = "2024", | |
| proc_macro_deps = [ | |
| "//third_party/rust_crates/vendor:serde_derive", | |
| ], | |
| visibility = ["//src:__subpackages__"], | |
| with_unit_tests = True, | |
| deps = [ | |
| "//sdk/rust/fidl-data-zx", | |
| "//src/lib/fdomain/client", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fidl/rust_constants", | |
| "//third_party/rust_crates/vendor:bitflags", | |
| "//third_party/rust_crates/vendor:nom", | |
| "//third_party/rust_crates/vendor:serde", | |
| "//third_party/rust_crates/vendor:serde_json", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| ], | |
| ) | |
| rustc_library( | |
| name = "fidl_codec_pure", | |
| srcs = [ | |
| "src/decode.rs", | |
| "src/encode.rs", | |
| "src/error.rs", | |
| "src/handle.rs", | |
| "src/handle/pure.rs", | |
| "src/lib.rs", | |
| "src/library.rs", | |
| "src/transaction.rs", | |
| "src/util.rs", | |
| "src/value.rs", | |
| ], | |
| crate_features = ["pure"], | |
| edition = "2024", | |
| proc_macro_deps = [ | |
| "//third_party/rust_crates/vendor:serde_derive", | |
| ], | |
| visibility = ["//src:__subpackages__"], | |
| with_unit_tests = True, | |
| deps = [ | |
| "//sdk/rust/fidl-data-zx", | |
| "//src/lib/fidl/rust_constants", | |
| "//third_party/rust_crates/vendor:bitflags", | |
| "//third_party/rust_crates/vendor:nom", | |
| "//third_party/rust_crates/vendor:serde", | |
| "//third_party/rust_crates/vendor:serde_json", | |
| "//third_party/rust_crates/vendor:thiserror", | |
| ], | |
| ) | |
| # @bazel2gn:skip | |
| gidl( | |
| name = "generate_conformance_test", | |
| fidl = CONFORMANCE_SUITE_FIDL_TARGET, | |
| inputs = CONFORMANCE_SUITE_GIDL_FILES, | |
| language = "rust_codec", | |
| output = "src/conformance_test.rs", | |
| type = "conformance", | |
| ) | |
| # @bazel2gn:skip | |
| rustc_test( | |
| name = "fidl_codec_rust_conformance_tests_unwrapped_bin", | |
| srcs = [":generate_conformance_test"], | |
| compile_data = [CONFORMANCE_SUITE_FIDL_TARGET], | |
| crate_name = "fidl_codec_rust_conformance_tests", | |
| crate_root = "src/conformance_test.rs", | |
| edition = "2024", | |
| rustc_env = { | |
| "CONFORMANCE_JSON_PATH": "$(execpath %s)" % CONFORMANCE_SUITE_FIDL_TARGET, | |
| }, | |
| deps = [ | |
| ":fidl_codec", | |
| "//sdk/rust/zx-status", | |
| "//sdk/rust/zx-types", | |
| "//src/lib/fidl/rust/fidl", | |
| "//src/lib/fidl/rust/gidl_util", | |
| "//third_party/rust_crates/vendor:assert_matches", | |
| ], | |
| ) | |
| # @bazel2gn:skip | |
| fx_unittest_package( | |
| name = "fidl_codec_rust_conformance_tests", | |
| unit_tests = [ | |
| "fidl_codec_rust_conformance_tests_unwrapped_bin", | |
| ":fidl_codec_fdomain_test", | |
| ":fidl_codec_pure_test", | |
| ":fidl_codec_test", | |
| ], | |
| visibility = ["//src/lib/fidl_codec:__subpackages__"], | |
| ) | |
| # We can't run tests in threads because they assert that handles are closed, | |
| # which is racy when other threads are creating handles. See the comment on | |
| # get_handle_info_valid in ./gidl_util/src/lib.rs for more details. We only | |
| # need this on host because the test runner framework uses processes. | |
| # @bazel2gn:skip | |
| wrap_host_rust_test( | |
| name = "fidl_codec_rust_conformance_tests_bin", | |
| binary_name = "fidl_codec_rust_conformance_tests_unwrapped_bin", | |
| test_args = ["--test-threads=1"], | |
| visibility = ["//src/lib/fidl_codec:__subpackages__"], | |
| ) |