aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules/aidl/interface.bzl5
-rw-r--r--rules/aidl/interface_test.bzl72
-rw-r--r--rules/cc/cc_aidl_code_gen.bzl1
3 files changed, 75 insertions, 3 deletions
diff --git a/rules/aidl/interface.bzl b/rules/aidl/interface.bzl
index 19f7f2d2..a80afedb 100644
--- a/rules/aidl/interface.bzl
+++ b/rules/aidl/interface.bzl
@@ -261,13 +261,14 @@ def create_aidl_binding_for_backends(
# frozen version specified via versions or versions_with_info.
# next_version being equal to "" means this is an unstable version and
# we should use srcs instead
+ if version != "":
+ aidl_flags = aidl_flags + ["--version=" + version]
+
if srcs == None:
if version == "":
fail("need srcs for unversioned interface")
-
strip_import_prefix = "aidl_api/{}/{}".format(name, version)
srcs = native.glob([strip_import_prefix + "/**/*.aidl"])
- aidl_flags = aidl_flags + ["--version=" + version]
aidl_library(
name = aidl_library_name,
diff --git a/rules/aidl/interface_test.bzl b/rules/aidl/interface_test.bzl
index 7dd3638f..87410eb8 100644
--- a/rules/aidl/interface_test.bzl
+++ b/rules/aidl/interface_test.bzl
@@ -17,6 +17,7 @@ load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//build/bazel/rules/aidl:interface.bzl", "aidl_interface")
+load("//build/bazel/rules/aidl:library.bzl", "AidlGenInfo")
load("//build/bazel/rules/test_common:rules.bzl", "target_under_test_exist_test")
def _ndk_backend_test_impl(ctx):
@@ -136,6 +137,74 @@ def _ndk_config_test():
return test_name
+def _aidl_library_has_flags_test_impl(ctx):
+ env = analysistest.begin(ctx)
+ target_under_test = analysistest.target_under_test(env)
+
+ asserts.true(
+ env,
+ AidlGenInfo in target_under_test,
+ "",
+ )
+ asserts.equals(
+ env,
+ ctx.attr.expected_flags,
+ target_under_test[AidlGenInfo].flags,
+ "",
+ )
+
+ return analysistest.end(env)
+
+aidl_library_has_flags_test = analysistest.make(
+ _aidl_library_has_flags_test_impl,
+ attrs = {
+ "expected_flags": attr.string_list(),
+ },
+)
+
+def _test_aidl_interface_passes_flags_to_aidl_libraries():
+ name = "aidl_interface_passes_version_flags_to_aidl_libraries"
+ aidl_interface(
+ name = name,
+ srcs = ["Foo.aidl"],
+ tags = ["manual"],
+ versions = ["1", "2"],
+ )
+
+ target_v1_test_name = name + "_test-V1"
+ aidl_library_has_flags_test(
+ name = target_v1_test_name,
+ target_under_test = name + "-V1",
+ expected_flags = [
+ "--structured",
+ "--version=1",
+ ],
+ )
+ target_v2_test_name = name + "_test-V2"
+ aidl_library_has_flags_test(
+ name = target_v2_test_name,
+ target_under_test = name + "-V2",
+ expected_flags = [
+ "--structured",
+ "--version=2",
+ ],
+ )
+ target_v_next_test_name = name + "_test-V_next"
+ aidl_library_has_flags_test(
+ name = target_v_next_test_name,
+ target_under_test = name + "-V3",
+ expected_flags = [
+ "--structured",
+ "--version=3",
+ ],
+ )
+
+ return [
+ target_v1_test_name,
+ target_v2_test_name,
+ target_v_next_test_name,
+ ]
+
def _next_version_for_unversioned_stable_interface_test():
name = "unversioned_stable_interface_next_version"
test_name = name + "_test"
@@ -270,6 +339,7 @@ def aidl_interface_test_suite(name):
_next_version_for_unversioned_stable_interface_test(),
_next_version_for_versioned_stable_interface_test(),
] +
- _test_aidl_interface_generated_header_filter()
+ _test_aidl_interface_generated_header_filter() +
+ _test_aidl_interface_passes_flags_to_aidl_libraries()
),
)
diff --git a/rules/cc/cc_aidl_code_gen.bzl b/rules/cc/cc_aidl_code_gen.bzl
index ca579eaa..ef4e659a 100644
--- a/rules/cc/cc_aidl_code_gen.bzl
+++ b/rules/cc/cc_aidl_code_gen.bzl
@@ -177,6 +177,7 @@ def _compile_aidl_srcs(ctx, aidl_info, lang):
executable = ctx.executable._aidl,
arguments = [args],
progress_message = "Compiling AIDL binding",
+ mnemonic = "CcAidlCodeGen",
)
return ret