xref: /aosp_15_r20/hardware/interfaces/automotive/vehicle/tools/generate_emu_metadata/Android.bp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1/*
2 * Copyright (C) 2024 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    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21java_binary_host {
22    name: "EnumMetadataGenerator",
23    srcs: ["src/**/*.java"],
24    manifest: "manifest.txt",
25    static_libs: [
26        "javaparser",
27        "javaparser-symbol-solver",
28        "json-prebuilt",
29        "androidx.annotation_annotation",
30    ],
31}
32
33// A rule to convert VHAL property AIDL files to java files.
34gensrcs {
35    name: "gen_vehicle_property_java_file",
36    srcs: [
37        ":android.hardware.automotive.vehicle.property-files",
38    ],
39    tools: ["aidl"],
40    cmd: "$(location aidl) --lang=java --structured --stability=vintf $(in) -I hardware/interfaces/automotive/vehicle/aidl_property --out $(genDir)/hardware/interfaces/automotive/vehicle/aidl_property",
41    output_extension: "java",
42}
43
44// A target to check whether android.hardware.automotive.vehicle-types-meta.json
45// needs to be updated. The output is just an empty cpp file to be included
46// in the higher-level build target.
47// It will generate generated.json at output directory based on VHAL property
48// java files and check it against
49// android.hardware.automotive.vehicle-types-meta.json. If not the same, the
50// build will fail.
51genrule {
52    name: "check_generated_enum_metadata_json",
53    tools: ["EnumMetadataGenerator"],
54    srcs: [
55        ":android.hardware.automotive.vehicle-types-meta",
56        ":gen_vehicle_property_java_file",
57    ],
58    cmd: "$(location EnumMetadataGenerator) --check_against $(location :android.hardware.automotive.vehicle-types-meta) --output_empty_file $(out) --output_json $(genDir)/generate_enum_metadata.json --input_files $(locations :gen_vehicle_property_java_file)",
59    out: ["generate_enum_metadata_checked.cpp"],
60}
61