1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package {
18    // See: http://go/android-license-faq
19    // A large-scale-change added 'default_applicable_licenses' to import
20    // all of the 'license_kinds' from "system_tools_hidl_license"
21    // to get the below license kinds:
22    //   SPDX-license-identifier-Apache-2.0
23    default_applicable_licenses: ["system_tools_hidl_license"],
24}
25
26genrule_defaults {
27    name: "hidl2aidl_test_gen_defaults",
28    tools: ["hidl2aidl"],
29    cmd: "$(location hidl2aidl) -f -o $(genDir)/ " +
30        "-rhidl2aidl.test:system/tools/hidl/hidl2aidl/test " +
31        "hidl2aidl.test@1.2 && " +
32        "$(location hidl2aidl) -f -o $(genDir)/ " +
33        "-rhidl2aidl.test:system/tools/hidl/hidl2aidl/test " +
34        "hidl2aidl.test.extension@1.2 && " +
35        "$(location hidl2aidl) -o $(genDir)/ " +
36        "-rhidl2aidl.test:system/tools/hidl/hidl2aidl/test " +
37        "hidl2aidl.test@2.0 && " +
38        "mv $(genDir)/include/hidl2aidl/test/translate-ndk.h $(genDir)/hidl2aidl/test/ && " +
39        "mv $(genDir)/include/hidl2aidl/test/translate-cpp.h $(genDir)/hidl2aidl/test/ &&" +
40        "mv $(genDir)/include/hidl2aidl/test/extension/translate-ndk.h $(genDir)/hidl2aidl/test/extension/ && " +
41        "mv $(genDir)/include/hidl2aidl/test/extension/translate-cpp.h $(genDir)/hidl2aidl/test/extension/ ",
42    srcs: [
43        "1.0/IBar.hal",
44        "1.0/IFoo.hal",
45        "1.0/types.hal",
46        "1.1/IFoo.hal",
47        "1.1/types.hal",
48        "1.2/IFoo.hal",
49        "2.0/IFoo.hal",
50        "extension/1.2/IFoo.hal",
51        "extension/1.2/types.hal",
52    ],
53}
54
55genrule {
56    name: "hidl2aidl_test_gen_aidl",
57    defaults: ["hidl2aidl_test_gen_defaults"],
58    out: [
59        "hidl2aidl/test/ArrayFoo.aidl",
60        "hidl2aidl/test/VectorFoo.aidl",
61        "hidl2aidl/test/FooFlag.aidl",
62        "hidl2aidl/test/IBar.aidl",
63        "hidl2aidl/test/IBarInner.aidl",
64        "hidl2aidl/test/IFoo.aidl",
65        "hidl2aidl/test/IFooBigStruct.aidl",
66        "hidl2aidl/test/NameCollision.aidl",
67        "hidl2aidl/test/OnlyIn10.aidl",
68        "hidl2aidl/test/OnlyIn11.aidl",
69        "hidl2aidl/test/Outer.aidl",
70        "hidl2aidl/test/OuterInner.aidl",
71        "hidl2aidl/test/OverrideMe.aidl",
72        "hidl2aidl/test/SafeUnionBar.aidl",
73        "hidl2aidl/test/SafeUnionBarInnerStructBar.aidl",
74        "hidl2aidl/test/UnionFoo.aidl",
75        "hidl2aidl/test/Value.aidl",
76        "hidl2aidl/test2/IFoo.aidl",
77        "hidl2aidl/test/extension/IFoo.aidl",
78        "hidl2aidl/test/extension/FooFlag.aidl",
79        "hidl2aidl/test/extension/ArrayFoo.aidl",
80    ],
81}
82
83genrule {
84    name: "hidl2aidl_translate_ndk_test_gen_src",
85    defaults: ["hidl2aidl_test_gen_defaults"],
86    out: [
87        "hidl2aidl/test/translate-ndk.cpp",
88        "hidl2aidl/test/extension/translate-ndk.cpp",
89    ],
90}
91
92genrule {
93    name: "hidl2aidl_translate_ndk_test_gen_headers",
94    defaults: ["hidl2aidl_test_gen_defaults"],
95    out: [
96        "hidl2aidl/test/translate-ndk.h",
97        "hidl2aidl/test/extension/translate-ndk.h",
98    ],
99}
100
101genrule {
102    name: "hidl2aidl_translate_cpp_test_gen_src",
103    defaults: ["hidl2aidl_test_gen_defaults"],
104    out: [
105        "hidl2aidl/test/translate-cpp.cpp",
106        "hidl2aidl/test/extension/translate-cpp.cpp",
107    ],
108}
109
110genrule {
111    name: "hidl2aidl_translate_cpp_test_gen_headers",
112    defaults: ["hidl2aidl_test_gen_defaults"],
113    out: [
114        "hidl2aidl/test/translate-cpp.h",
115        "hidl2aidl/test/extension/translate-cpp.h",
116    ],
117}
118
119genrule {
120    name: "hidl2aidl_translate_java_test_gen_src",
121    defaults: ["hidl2aidl_test_gen_defaults"],
122    out: [
123        "hidl2aidl/test/Translate.java",
124        "hidl2aidl/test/extension/Translate.java",
125    ],
126}
127
128aidl_interface {
129    name: "hidl2aidl_test_gen",
130    owner: "test",
131    stability: "vintf",
132    srcs: [":hidl2aidl_test_gen_aidl"],
133    backend: {
134        java: {
135            sdk_version: "module_current",
136        },
137    },
138    flags: [
139        "-Werror",
140        "-Wno-mixed-oneway",
141    ],
142}
143
144cc_test_library {
145    name: "hidl2aidl_test_comp_cc",
146    srcs: [
147        "cpp_test_compile.cpp",
148        "ndk_test_compile.cpp",
149    ],
150    shared_libs: [
151        "hidl2aidl_test_gen-V1-cpp",
152        "hidl2aidl_test_gen-V1-ndk_platform",
153        "libbinder",
154        "libbinder_ndk",
155        "libutils",
156    ],
157    gtest: false,
158}
159
160cc_test {
161    name: "hidl2aidl_translate_ndk_test",
162    test_suites: ["general-tests"],
163
164    cflags: [
165        "-Wall",
166        "-Wextra",
167        "-Werror",
168        "-g",
169    ],
170    srcs: [
171        ":hidl2aidl_translate_ndk_test_gen_src",
172        "translate_ndk_test.cpp",
173    ],
174    generated_headers: [
175        "hidl2aidl_translate_ndk_test_gen_headers",
176    ],
177    shared_libs: [
178        "libbinder_ndk",
179        "libhidlbase",
180        "liblog",
181    ],
182    static_libs: [
183        "hidl2aidl_test_gen-V1-ndk_platform",
184        "hidl2aidl.test@1.0",
185        "hidl2aidl.test@1.1",
186        "hidl2aidl.test@1.2",
187        "hidl2aidl.test.extension@1.2",
188    ],
189    host_required: [
190        "hidl2aidl",
191    ],
192}
193
194cc_test {
195    name: "hidl2aidl_translate_cpp_test",
196    test_suites: ["general-tests"],
197
198    cflags: [
199        "-Wall",
200        "-Wextra",
201        "-Werror",
202        "-g",
203        "-DHIDL2AIDLTESTING",
204    ],
205    srcs: [
206        ":hidl2aidl_translate_cpp_test_gen_src",
207        "translate_cpp_test.cpp",
208    ],
209    generated_headers: [
210        "hidl2aidl_translate_cpp_test_gen_headers",
211    ],
212    shared_libs: [
213        "libbinder",
214        "libhidlbase",
215        "libutils",
216        "liblog",
217    ],
218    static_libs: [
219        "hidl2aidl_test_gen-V1-cpp",
220        "hidl2aidl.test@1.0",
221        "hidl2aidl.test@1.1",
222        "hidl2aidl.test@1.2",
223        "hidl2aidl.test.extension@1.2",
224    ],
225    host_required: [
226        "hidl2aidl",
227    ],
228}
229
230android_test {
231    name: "hidl2aidl_translate_java_test",
232    platform_apis: true,
233    // Turn off Java optimization tools to speed up our test iterations.
234    optimize: {
235        enabled: false,
236    },
237    dex_preopt: {
238        enabled: false,
239    },
240    srcs: [
241        ":hidl2aidl_translate_java_test_gen_src",
242        "TranslateJavaTest.java",
243    ],
244    static_libs: [
245        "androidx.test.core",
246        "androidx.test.runner",
247        "hidl2aidl_test_gen-V1-java",
248        "hidl2aidl.test-V1.0-java",
249        "hidl2aidl.test-V1.1-java",
250        "hidl2aidl.test-V1.2-java",
251        "hidl2aidl.test.extension-V1.2-java",
252    ],
253    host_required: [
254        "hidl2aidl",
255    ],
256    test_suites: ["general-tests"],
257}
258
259phony {
260    name: "hidl2aidl_test",
261    required: [
262        "hidl2aidl_test_comp_cc",
263        "hidl2aidl_test_gen-V1-java",
264        "hidl2aidl_translate_ndk_test",
265        "hidl2aidl_translate_cpp_test",
266    ],
267}
268
269hidl_package_root {
270    name: "hidl2aidl.test",
271}
272