| load("@bazel_skylib//:bzl_library.bzl", "bzl_library") |
| load("//common:crubit_wrapper_macros_oss.bzl", "crubit_rust_test") |
| load( |
| "//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_cli_flag_aspect_hint.bzl", |
| "rust_bindings_from_cc_cli_flag", |
| ) |
| load( |
| "//rs_bindings_from_cc/test/golden:golden_test.bzl", |
| "golden_test", |
| ) |
| |
| package(default_applicable_licenses = ["//:license"]) |
| |
| TESTS = [name[:-2] for name in glob( |
| ["*.h"], |
| exclude = [ |
| "*namespaces_json.h", |
| ], |
| )] |
| |
| # Maps a test to the list of tests it depends on. |
| # |
| # Valid keys: |
| # basenames of tests (e.g. "types" is a valid key, because we |
| # have rs_bindings_from_cc/test/golden/types.h. |
| # Valid values: a list of: |
| # basenames of tests (e.g. "types") |
| # other Bazel targets (e.g. "//foo/bar:baz") |
| DEPS = { |
| "user_of_unsupported": ["unsupported"], |
| "user_of_imported_type": ["trivial_type"], |
| "user_of_base_class": ["inheritance"], |
| "includes": [ |
| "comment", |
| "namespace", |
| "types", |
| "unions", |
| "unsupported", |
| ], |
| "types": ["//support/rs_std:rs_char"], |
| "definition_of_forward_declaration": [ |
| "forward_declaration", |
| ], |
| } |
| |
| TAGS = {} |
| |
| rust_bindings_from_cc_cli_flag( |
| name = "disable_source_location_in_doc_comment", |
| flags = "--generate_source_location_in_doc_comment=False", |
| ) |
| |
| [cc_library( |
| name = name + "_cc", |
| hdrs = [name + ".h"], |
| aspect_hints = [ |
| "//features:experimental", |
| ":disable_source_location_in_doc_comment", |
| ], |
| copts = ["-Wno-google3-inline-namespace"], |
| deps = [ |
| ((d + "_cc") if d in TESTS else d) |
| for d in (DEPS[name] if name in DEPS else []) |
| ], |
| ) for name in TESTS] |
| |
| [golden_test( |
| name = name + "_test", |
| basename = name, |
| cc_library = name + "_cc", |
| golden_cc = name + "_rs_api_impl.cc", |
| golden_rs = name + "_rs_api.rs", |
| tags = [tag for tag in (TAGS[name] if name in TAGS else [])], |
| ) for name in TESTS] |
| |
| [crubit_rust_test( |
| name = name + "_rs_test", |
| srcs = ["empty_rs_test.rs"], |
| cc_deps = ["%s_cc" % name], |
| ) for name in TESTS] |
| |
| cc_library( |
| name = "namespaces_json", |
| hdrs = ["namespaces_json.h"], |
| aspect_hints = [ |
| ":disable_source_location_in_doc_comment", |
| "//features:experimental", |
| ], |
| copts = ["-Wno-google3-inline-namespace"], |
| ) |
| |
| golden_test( |
| name = "namespaces_json_test", |
| basename = "namespaces_json", |
| cc_library = "namespaces_json", |
| golden_namespaces = "namespaces_json.json", |
| ) |
| |
| bzl_library( |
| name = "golden_test", |
| srcs = ["golden_test.bzl"], |
| visibility = ["//visibility:private"], |
| deps = [ |
| "//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_aspect", |
| "//rs_bindings_from_cc/bazel_support:rust_bindings_from_cc_utils_bzl", |
| ], |
| ) |