xref: /aosp_15_r20/build/bazel/rules/aidl/testing/BUILD (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1"""
2Copyright (C) 2022 The Android Open Source Project
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8    http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15"""
16
17load("//build/bazel/rules/aidl:aidl_interface.bzl", "aidl_interface")
18
19test_scope = [
20    "//build/bazel/rules/aidl/testing:aidl_interface_test-java",
21    "//build/bazel/rules/aidl/testing:aidl_interface_test-V1",
22    "//build/bazel/rules/aidl/testing:aidl_interface_test-V1-java",
23    "//build/bazel/rules/aidl/testing:aidl_interface_test-V2",
24    "//build/bazel/rules/aidl/testing:aidl_interface_test-V2-java",
25    "//build/bazel/rules/aidl/testing:aidl_interface_test-latest",
26    "//build/bazel/rules/aidl/testing:aidl_interface_test-latest-java",
27]
28
29aidl_interface(
30    name = "foo",
31    srcs = ["Test.aidl"],
32    tags = ["manual"],
33)
34
35aidl_interface(
36    name = "aidl_interface_test",
37    java_config = {
38        "enabled": True,
39    },
40    tags = ["manual"],
41    versions_with_info = [
42        {
43            "version": "1",
44            "deps": [":foo-V1"],
45        },
46        {
47            "version": "2",
48            "deps": [":foo-V1"],
49        },
50    ],
51)
52
53genquery(
54    name = "generated_target_V1_has_correct_srcs_query",
55    expression = 'kind("source file", deps(//build/bazel/rules/aidl/testing:aidl_interface_test-V1))',
56    scope = test_scope,
57)
58
59genquery(
60    name = "generated_target_V2_has_correct_srcs_query",
61    expression = 'kind("source file", deps(//build/bazel/rules/aidl/testing:aidl_interface_test-V2))',
62    scope = test_scope,
63)
64
65sh_test(
66    name = "generated_targets_have_correct_srcs_test",
67    size = "small",
68    srcs = ["generated_targets_have_correct_srcs.sh"],
69    data = [
70        ":generated_target_V1_has_correct_srcs_query",
71        ":generated_target_V2_has_correct_srcs_query",
72    ],
73    tags = [
74        "manual",
75        "no_windows",
76    ],
77    visibility = ["//build/bazel/rules/aidl:__subpackages__"],
78    deps = ["@bazel_tools//tools/bash/runfiles"],
79)
80
81genquery(
82    name = "aidl_library_V1_produced_by_default_query",
83    expression = "kind(aidl_library, //build/bazel/rules/aidl/testing:aidl_interface_test-V1)",
84    scope = test_scope,
85)
86
87genquery(
88    name = "aidl_library_V2_produced_by_default_query",
89    expression = "kind(aidl_library, //build/bazel/rules/aidl/testing:aidl_interface_test-V2)",
90    scope = test_scope,
91)
92
93genquery(
94    name = "aidl_library_latest_produced_by_default_query",
95    expression = "kind(alias, //build/bazel/rules/aidl/testing:aidl_interface_test-latest)",
96    scope = test_scope,
97)
98
99genquery(
100    name = "java_backend_V1_produced_by_default_query",
101    expression = "kind(java_aidl_library, //build/bazel/rules/aidl/testing:aidl_interface_test-V1-java)",
102    scope = test_scope,
103)
104
105genquery(
106    name = "java_backend_V2_produced_by_default_query",
107    expression = "kind(java_aidl_library, //build/bazel/rules/aidl/testing:aidl_interface_test-V2-java)",
108    scope = test_scope,
109)
110
111genquery(
112    name = "java_backend_latest_produced_by_default_query",
113    expression = "kind(alias, //build/bazel/rules/aidl/testing:aidl_interface_test-latest-java)",
114    scope = test_scope,
115)
116
117genquery(
118    name = "java_backend_unversioned_produced_by_default_query",
119    expression = "kind(alias, //build/bazel/rules/aidl/testing:aidl_interface_test-java)",
120    scope = test_scope,
121)
122
123sh_test(
124    name = "interface_macro_produces_all_targets_test",
125    size = "small",
126    srcs = ["interface_macro_produces_all_targets.sh"],
127    data = [
128        ":aidl_library_V1_produced_by_default_query",
129        ":aidl_library_V2_produced_by_default_query",
130        ":aidl_library_latest_produced_by_default_query",
131        #TODO(b/85574832) re-enable Java-backends
132    ],
133    tags = [
134        "manual",
135        "no_windows",
136    ],
137    visibility = ["//build/bazel/rules/aidl:__subpackages__"],
138    deps = ["@bazel_tools//tools/bash/runfiles"],
139)
140