blob: 93d408e53ca773989cf062b9a9b3765fcd99a382 [file] [log] [blame]
Keith Mok57baaaf2023-06-13 22:33:10 +00001#!/usr/bin/python3
Yu Shan63e24d72022-06-24 17:53:32 +00002
3# Copyright (C) 2022 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17"""A script to generate Java files and CPP header files based on annotations in VehicleProperty.aidl
18
19 Need ANDROID_BUILD_TOP environmental variable to be set. This script will update
20 ChangeModeForVehicleProperty.h and AccessForVehicleProperty.h under generated_lib/cpp and
Tyler Trephana1828f92023-10-06 02:39:13 +000021 ChangeModeForVehicleProperty.java, AccessForVehicleProperty.java, EnumForVehicleProperty.java under generated_lib/java.
Yu Shan63e24d72022-06-24 17:53:32 +000022
23 Usage:
24 $ python generate_annotation_enums.py
25"""
Yu Shan41dd7f12023-06-07 13:25:43 -070026import argparse
27import filecmp
Yu Shan63e24d72022-06-24 17:53:32 +000028import os
29import re
30import sys
Yu Shan41dd7f12023-06-07 13:25:43 -070031import tempfile
Yu Shan63e24d72022-06-24 17:53:32 +000032
Yu Shan41dd7f12023-06-07 13:25:43 -070033PROP_AIDL_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl_property/android/hardware/' +
34 'automotive/vehicle/VehicleProperty.aidl')
35CHANGE_MODE_CPP_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/cpp/' +
36 'ChangeModeForVehicleProperty.h')
37ACCESS_CPP_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/cpp/' +
38 'AccessForVehicleProperty.h')
39CHANGE_MODE_JAVA_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/java/' +
40 'ChangeModeForVehicleProperty.java')
41ACCESS_JAVA_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/java/' +
42 'AccessForVehicleProperty.java')
Tyler Trephana1828f92023-10-06 02:39:13 +000043ENUM_JAVA_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/java/' +
44 'EnumForVehicleProperty.java')
Yu Shan7881e822023-12-15 13:12:01 -080045VERSION_CPP_FILE_PATH = ('hardware/interfaces/automotive/vehicle/aidl/generated_lib/cpp/' +
46 'VersionForVehicleProperty.h')
Yu Shan41dd7f12023-06-07 13:25:43 -070047SCRIPT_PATH = 'hardware/interfaces/automotive/vehicle/tools/generate_annotation_enums.py'
Yu Shan63e24d72022-06-24 17:53:32 +000048
Yu Shan41dd7f12023-06-07 13:25:43 -070049TAB = ' '
50RE_ENUM_START = re.compile('\s*enum VehicleProperty \{')
51RE_ENUM_END = re.compile('\s*\}\;')
52RE_COMMENT_BEGIN = re.compile('\s*\/\*\*?')
53RE_COMMENT_END = re.compile('\s*\*\/')
54RE_CHANGE_MODE = re.compile('\s*\* @change_mode (\S+)\s*')
Yu Shan7881e822023-12-15 13:12:01 -080055RE_VERSION = re.compile('\s*\* @version (\S+)\s*')
Yu Shan41dd7f12023-06-07 13:25:43 -070056RE_ACCESS = re.compile('\s*\* @access (\S+)\s*')
Yu Shan8ddd65d2023-06-28 17:02:29 -070057RE_DATA_ENUM = re.compile('\s*\* @data_enum (\S+)\s*')
58RE_UNIT = re.compile('\s*\* @unit (\S+)\s+')
Yu Shan41dd7f12023-06-07 13:25:43 -070059RE_VALUE = re.compile('\s*(\w+)\s*=(.*)')
Yu Shan63e24d72022-06-24 17:53:32 +000060
61LICENSE = """/*
Tyler Trephana1828f92023-10-06 02:39:13 +000062 * Copyright (C) 2023 The Android Open Source Project
Yu Shan63e24d72022-06-24 17:53:32 +000063 *
64 * Licensed under the Apache License, Version 2.0 (the "License");
65 * you may not use this file except in compliance with the License.
66 * You may obtain a copy of the License at
67 *
68 * http://www.apache.org/licenses/LICENSE-2.0
69 *
70 * Unless required by applicable law or agreed to in writing, software
71 * distributed under the License is distributed on an "AS IS" BASIS,
72 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
73 * See the License for the specific language governing permissions and
74 * limitations under the License.
75 */
76
77/**
78 * DO NOT EDIT MANUALLY!!!
79 *
80 * Generated by tools/generate_annotation_enums.py.
81 */
82
Aaqib Ismail2e8915d2023-01-30 13:04:05 -080083// clang-format off
84
Yu Shan63e24d72022-06-24 17:53:32 +000085"""
86
Yu Shan7881e822023-12-15 13:12:01 -080087CHANGE_MODE_CPP_HEADER = """#pragma once
Yu Shan63e24d72022-06-24 17:53:32 +000088
89#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
90#include <aidl/android/hardware/automotive/vehicle/VehiclePropertyChangeMode.h>
91
92#include <unordered_map>
93
94namespace aidl {
95namespace android {
96namespace hardware {
97namespace automotive {
98namespace vehicle {
99
100std::unordered_map<VehicleProperty, VehiclePropertyChangeMode> ChangeModeForVehicleProperty = {
101"""
102
Yu Shan7881e822023-12-15 13:12:01 -0800103CPP_FOOTER = """
Yu Shan63e24d72022-06-24 17:53:32 +0000104};
105
106} // namespace vehicle
107} // namespace automotive
108} // namespace hardware
109} // namespace android
110} // aidl
Yu Shan63e24d72022-06-24 17:53:32 +0000111"""
112
Yu Shan7881e822023-12-15 13:12:01 -0800113ACCESS_CPP_HEADER = """#pragma once
Yu Shan63e24d72022-06-24 17:53:32 +0000114
115#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
116#include <aidl/android/hardware/automotive/vehicle/VehiclePropertyAccess.h>
117
118#include <unordered_map>
119
120namespace aidl {
121namespace android {
122namespace hardware {
123namespace automotive {
124namespace vehicle {
125
126std::unordered_map<VehicleProperty, VehiclePropertyAccess> AccessForVehicleProperty = {
127"""
128
Yu Shan7881e822023-12-15 13:12:01 -0800129VERSION_CPP_HEADER = """#pragma once
Yu Shan63e24d72022-06-24 17:53:32 +0000130
Yu Shan7881e822023-12-15 13:12:01 -0800131#include <aidl/android/hardware/automotive/vehicle/VehicleProperty.h>
Yu Shan63e24d72022-06-24 17:53:32 +0000132
Yu Shan7881e822023-12-15 13:12:01 -0800133#include <unordered_map>
134
135namespace aidl {
136namespace android {
137namespace hardware {
138namespace automotive {
139namespace vehicle {
140
141std::unordered_map<VehicleProperty, int32_t> VersionForVehicleProperty = {
Yu Shan63e24d72022-06-24 17:53:32 +0000142"""
143
144CHANGE_MODE_JAVA_HEADER = """package android.hardware.automotive.vehicle;
145
146import java.util.Map;
147
148public final class ChangeModeForVehicleProperty {
149
150 public static final Map<Integer, Integer> values = Map.ofEntries(
151"""
152
Yu Shan7881e822023-12-15 13:12:01 -0800153JAVA_FOOTER = """
Yu Shan63e24d72022-06-24 17:53:32 +0000154 );
155
156}
157"""
158
159ACCESS_JAVA_HEADER = """package android.hardware.automotive.vehicle;
160
161import java.util.Map;
162
163public final class AccessForVehicleProperty {
164
165 public static final Map<Integer, Integer> values = Map.ofEntries(
166"""
167
Tyler Trephana1828f92023-10-06 02:39:13 +0000168ENUM_JAVA_HEADER = """package android.hardware.automotive.vehicle;
169
170import java.util.List;
171import java.util.Map;
172
173public final class EnumForVehicleProperty {
174
175 public static final Map<Integer, List<Class<?>>> values = Map.ofEntries(
176"""
177
Yu Shan63e24d72022-06-24 17:53:32 +0000178
Yu Shan8ddd65d2023-06-28 17:02:29 -0700179class PropertyConfig:
180 """Represents one VHAL property definition in VehicleProperty.aidl."""
Yu Shan63e24d72022-06-24 17:53:32 +0000181
Yu Shan8ddd65d2023-06-28 17:02:29 -0700182 def __init__(self):
183 self.name = None
184 self.description = None
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800185 self.comment = None
Yu Shan8ddd65d2023-06-28 17:02:29 -0700186 self.change_mode = None
187 self.access_modes = []
188 self.enum_types = []
189 self.unit_type = None
Yu Shan7881e822023-12-15 13:12:01 -0800190 self.version = None
Yu Shan63e24d72022-06-24 17:53:32 +0000191
Yu Shan8ddd65d2023-06-28 17:02:29 -0700192 def __repr__(self):
193 return self.__str__()
194
195 def __str__(self):
196 return ('PropertyConfig{{' +
197 'name: {}, description: {}, change_mode: {}, access_modes: {}, enum_types: {}' +
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800198 ', unit_type: {}, version: {}, comment: {}}}').format(self.name, self.description,
199 self.change_mode, self.access_modes, self.enum_types, self.unit_type,
200 self.version, self.comment)
Yu Shan8ddd65d2023-06-28 17:02:29 -0700201
202
203class FileParser:
204
205 def __init__(self):
206 self.configs = None
207
208 def parseFile(self, input_file):
209 """Parses the input VehicleProperty.aidl file into a list of property configs."""
Yu Shan63e24d72022-06-24 17:53:32 +0000210 processing = False
211 in_comment = False
Yu Shan8ddd65d2023-06-28 17:02:29 -0700212 configs = []
213 config = None
214 with open(input_file, 'r') as f:
Yu Shan63e24d72022-06-24 17:53:32 +0000215 for line in f.readlines():
216 if RE_ENUM_START.match(line):
217 processing = True
Yu Shan63e24d72022-06-24 17:53:32 +0000218 elif RE_ENUM_END.match(line):
219 processing = False
220 if not processing:
221 continue
222 if RE_COMMENT_BEGIN.match(line):
223 in_comment = True
Yu Shan8ddd65d2023-06-28 17:02:29 -0700224 config = PropertyConfig()
225 description = ''
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800226 continue
227
Yu Shan63e24d72022-06-24 17:53:32 +0000228 if RE_COMMENT_END.match(line):
229 in_comment = False
230 if in_comment:
Yu Shan8ddd65d2023-06-28 17:02:29 -0700231 match = RE_CHANGE_MODE.match(line)
232 if match:
233 config.change_mode = match.group(1).replace('VehiclePropertyChangeMode.', '')
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800234 continue
Yu Shan8ddd65d2023-06-28 17:02:29 -0700235 match = RE_ACCESS.match(line)
236 if match:
237 config.access_modes.append(match.group(1).replace('VehiclePropertyAccess.', ''))
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800238 continue
Yu Shan8ddd65d2023-06-28 17:02:29 -0700239 match = RE_UNIT.match(line)
240 if match:
241 config.unit_type = match.group(1)
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800242 continue
Yu Shan8ddd65d2023-06-28 17:02:29 -0700243 match = RE_DATA_ENUM.match(line)
244 if match:
245 config.enum_types.append(match.group(1))
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800246 continue
Yu Shan7881e822023-12-15 13:12:01 -0800247 match = RE_VERSION.match(line)
248 if match:
249 if config.version != None:
250 raise Exception('Duplicate version annotation for property: ' + prop_name)
251 config.version = match.group(1)
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800252 continue
253
254 sline = line.strip()
255 if sline.startswith('*'):
256 # Remove the '*'.
257 sline = sline[1:].strip()
258
259 if not config.description:
260 # We reach an empty line of comment, the description part is ending.
261 if sline == '':
262 config.description = description
263 else:
264 if description != '':
265 description += ' '
266 description += sline
267 else:
268 if not config.comment:
269 if sline != '':
270 # This is the first line for comment.
271 config.comment = sline
272 else:
273 if sline != '':
274 # Concat this line with the previous line's comment with a space.
275 config.comment += ' ' + sline
276 else:
277 # Treat empty line comment as a new line.
278 config.comment += '\n'
Yu Shan63e24d72022-06-24 17:53:32 +0000279 else:
280 match = RE_VALUE.match(line)
281 if match:
282 prop_name = match.group(1)
Yu Shan41dd7f12023-06-07 13:25:43 -0700283 if prop_name == 'INVALID':
Yu Shan63e24d72022-06-24 17:53:32 +0000284 continue
Yu Shan8ddd65d2023-06-28 17:02:29 -0700285 if not config.change_mode:
Yu Shan41dd7f12023-06-07 13:25:43 -0700286 raise Exception(
Yu Shan8ddd65d2023-06-28 17:02:29 -0700287 'No change_mode annotation for property: ' + prop_name)
288 if not config.access_modes:
289 raise Exception(
290 'No access_mode annotation for property: ' + prop_name)
Yu Shan7881e822023-12-15 13:12:01 -0800291 if not config.version:
292 raise Exception(
293 'no version annotation for property: ' + prop_name)
Yu Shan8ddd65d2023-06-28 17:02:29 -0700294 config.name = prop_name
295 configs.append(config)
296
297 self.configs = configs
298
299 def convert(self, output, header, footer, cpp, field):
300 """Converts the property config file to C++/Java output file."""
301 counter = 0
302 content = LICENSE + header
303 for config in self.configs:
304 if field == 'change_mode':
305 if cpp:
306 annotation = "VehiclePropertyChangeMode::" + config.change_mode
307 else:
308 annotation = "VehiclePropertyChangeMode." + config.change_mode
309 elif field == 'access_mode':
310 if cpp:
311 annotation = "VehiclePropertyAccess::" + config.access_modes[0]
312 else:
313 annotation = "VehiclePropertyAccess." + config.access_modes[0]
Tyler Trephana1828f92023-10-06 02:39:13 +0000314 elif field == 'enum_types':
315 if len(config.enum_types) < 1:
316 continue;
317 if not cpp:
318 annotation = "List.of(" + ', '.join([class_name + ".class" for class_name in config.enum_types]) + ")"
Yu Shan7881e822023-12-15 13:12:01 -0800319 elif field == 'version':
320 if cpp:
321 annotation = config.version
Yu Shan8ddd65d2023-06-28 17:02:29 -0700322 else:
323 raise Exception('Unknown field: ' + field)
324 if counter != 0:
325 content += '\n'
326 if cpp:
327 content += (TAB + TAB + '{VehicleProperty::' + config.name + ', ' +
328 annotation + '},')
329 else:
330 content += (TAB + TAB + 'Map.entry(VehicleProperty.' + config.name + ', ' +
331 annotation + '),')
332 counter += 1
Yu Shan63e24d72022-06-24 17:53:32 +0000333
Yu Shan41dd7f12023-06-07 13:25:43 -0700334 # Remove the additional ',' at the end for the Java file.
Yu Shan63e24d72022-06-24 17:53:32 +0000335 if not cpp:
336 content = content[:-1]
337
338 content += footer
339
340 with open(output, 'w') as f:
341 f.write(content)
342
Yu Shan8ddd65d2023-06-28 17:02:29 -0700343 def outputAsCsv(self, output):
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800344 content = 'name,description,change mode,access mode,enum type,unit type,comment\n'
Yu Shan8ddd65d2023-06-28 17:02:29 -0700345 for config in self.configs:
346 enum_types = None
347 if not config.enum_types:
348 enum_types = '/'
349 else:
350 enum_types = '/'.join(config.enum_types)
351 unit_type = config.unit_type
352 if not unit_type:
353 unit_type = '/'
354 access_modes = ''
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800355 comment = config.comment
356 if not comment:
357 comment = ''
358 content += '"{}","{}","{}","{}","{}","{}", "{}"\n'.format(
Yu Shan8ddd65d2023-06-28 17:02:29 -0700359 config.name,
360 # Need to escape quote as double quote.
361 config.description.replace('"', '""'),
362 config.change_mode,
363 '/'.join(config.access_modes),
364 enum_types,
Yu Shan0ebf5bb2023-12-18 15:42:43 -0800365 unit_type,
366 comment.replace('"', '""'))
Yu Shan8ddd65d2023-06-28 17:02:29 -0700367
368 with open(output, 'w+') as f:
369 f.write(content)
370
Yu Shan63e24d72022-06-24 17:53:32 +0000371
Yu Shan41dd7f12023-06-07 13:25:43 -0700372def createTempFile():
373 f = tempfile.NamedTemporaryFile(delete=False);
374 f.close();
375 return f.name
376
377
Yu Shan7881e822023-12-15 13:12:01 -0800378class GeneratedFile:
379
380 def __init__(self, type):
381 self.type = type
382 self.cpp_file_path = None
383 self.java_file_path = None
384 self.cpp_header = None
385 self.java_header = None
386 self.cpp_footer = None
387 self.java_footer = None
388 self.cpp_output_file = None
389 self.java_output_file = None
390
391 def setCppFilePath(self, cpp_file_path):
392 self.cpp_file_path = cpp_file_path
393
394 def setJavaFilePath(self, java_file_path):
395 self.java_file_path = java_file_path
396
397 def setCppHeader(self, cpp_header):
398 self.cpp_header = cpp_header
399
400 def setCppFooter(self, cpp_footer):
401 self.cpp_footer = cpp_footer
402
403 def setJavaHeader(self, java_header):
404 self.java_header = java_header
405
406 def setJavaFooter(self, java_footer):
407 self.java_footer = java_footer
408
409 def convert(self, file_parser, check_only, temp_files):
410 if self.cpp_file_path:
411 output_file = GeneratedFile._getOutputFile(self.cpp_file_path, check_only, temp_files)
412 file_parser.convert(output_file, self.cpp_header, self.cpp_footer, True, self.type)
413 self.cpp_output_file = output_file
414
415 if self.java_file_path:
416 output_file = GeneratedFile._getOutputFile(self.java_file_path, check_only, temp_files)
417 file_parser.convert(output_file, self.java_header, self.java_footer, False, self.type)
418 self.java_output_file = output_file
419
420 def cmp(self):
421 if self.cpp_file_path:
422 if not filecmp.cmp(self.cpp_output_file, self.cpp_file_path):
423 return False
424
425 if self.java_file_path:
426 if not filecmp.cmp(self.java_output_file, self.java_file_path):
427 return False
428
429 return True
430
431 @staticmethod
432 def _getOutputFile(file_path, check_only, temp_files):
433 if not check_only:
434 return file_path
435
436 temp_file = createTempFile()
437 temp_files.append(temp_file)
438 return temp_file
439
440
Yu Shan63e24d72022-06-24 17:53:32 +0000441def main():
Yu Shan41dd7f12023-06-07 13:25:43 -0700442 parser = argparse.ArgumentParser(
443 description='Generate Java and C++ enums based on annotations in VehicleProperty.aidl')
444 parser.add_argument('--android_build_top', required=False, help='Path to ANDROID_BUILD_TOP')
Yu Shanb1fc8c92023-08-30 11:51:04 -0700445 parser.add_argument('--preupload_files', nargs='*', required=False, help='modified files')
Yu Shan41dd7f12023-06-07 13:25:43 -0700446 parser.add_argument('--check_only', required=False, action='store_true',
447 help='only check whether the generated files need update')
Yu Shan8ddd65d2023-06-28 17:02:29 -0700448 parser.add_argument('--output_csv', required=False,
449 help='Path to the parsing result in CSV style, useful for doc generation')
Yu Shan41dd7f12023-06-07 13:25:43 -0700450 args = parser.parse_args();
451 android_top = None
452 output_folder = None
453 if args.android_build_top:
454 android_top = args.android_build_top
455 vehiclePropertyUpdated = False
456 for preuload_file in args.preupload_files:
457 if preuload_file.endswith('VehicleProperty.aidl'):
458 vehiclePropertyUpdated = True
459 break
460 if not vehiclePropertyUpdated:
461 return
462 else:
463 android_top = os.environ['ANDROID_BUILD_TOP']
Yu Shan63e24d72022-06-24 17:53:32 +0000464 if not android_top:
Tyler Trephana1828f92023-10-06 02:39:13 +0000465 print('ANDROID_BUILD_TOP is not in environmental variable, please run source and lunch ' +
Yu Shan41dd7f12023-06-07 13:25:43 -0700466 'at the android root')
Yu Shan63e24d72022-06-24 17:53:32 +0000467
468 aidl_file = os.path.join(android_top, PROP_AIDL_FILE_PATH)
Yu Shan8ddd65d2023-06-28 17:02:29 -0700469 f = FileParser();
470 f.parseFile(aidl_file)
471
472 if args.output_csv:
473 f.outputAsCsv(args.output_csv)
474 return
Yu Shan63e24d72022-06-24 17:53:32 +0000475
Yu Shan7881e822023-12-15 13:12:01 -0800476 generated_files = []
477
478 change_mode = GeneratedFile('change_mode')
479 change_mode.setCppFilePath(os.path.join(android_top, CHANGE_MODE_CPP_FILE_PATH))
480 change_mode.setJavaFilePath(os.path.join(android_top, CHANGE_MODE_JAVA_FILE_PATH))
481 change_mode.setCppHeader(CHANGE_MODE_CPP_HEADER)
482 change_mode.setCppFooter(CPP_FOOTER)
483 change_mode.setJavaHeader(CHANGE_MODE_JAVA_HEADER)
484 change_mode.setJavaFooter(JAVA_FOOTER)
485 generated_files.append(change_mode)
486
487 access_mode = GeneratedFile('access_mode')
488 access_mode.setCppFilePath(os.path.join(android_top, ACCESS_CPP_FILE_PATH))
489 access_mode.setJavaFilePath(os.path.join(android_top, ACCESS_JAVA_FILE_PATH))
490 access_mode.setCppHeader(ACCESS_CPP_HEADER)
491 access_mode.setCppFooter(CPP_FOOTER)
492 access_mode.setJavaHeader(ACCESS_JAVA_HEADER)
493 access_mode.setJavaFooter(JAVA_FOOTER)
494 generated_files.append(access_mode)
495
496 enum_types = GeneratedFile('enum_types')
497 enum_types.setJavaFilePath(os.path.join(android_top, ENUM_JAVA_FILE_PATH))
498 enum_types.setJavaHeader(ENUM_JAVA_HEADER)
499 enum_types.setJavaFooter(JAVA_FOOTER)
500 generated_files.append(enum_types)
501
502 version = GeneratedFile('version')
503 version.setCppFilePath(os.path.join(android_top, VERSION_CPP_FILE_PATH))
504 version.setCppHeader(VERSION_CPP_HEADER)
505 version.setCppFooter(CPP_FOOTER)
506 generated_files.append(version)
507
Yu Shan41dd7f12023-06-07 13:25:43 -0700508 temp_files = []
509
Yu Shan41dd7f12023-06-07 13:25:43 -0700510 try:
Yu Shan7881e822023-12-15 13:12:01 -0800511 for generated_file in generated_files:
512 generated_file.convert(f, args.check_only, temp_files)
Yu Shan41dd7f12023-06-07 13:25:43 -0700513
514 if not args.check_only:
515 return
516
Yu Shan7881e822023-12-15 13:12:01 -0800517 for generated_file in generated_files:
518 if not generated_file.cmp():
519 print('The generated enum files for VehicleProperty.aidl requires update, ')
520 print('Run \npython ' + android_top + '/' + SCRIPT_PATH)
521 sys.exit(1)
Yu Shan41dd7f12023-06-07 13:25:43 -0700522 except Exception as e:
523 print('Error parsing VehicleProperty.aidl')
524 print(e)
525 sys.exit(1)
526 finally:
527 for file in temp_files:
528 os.remove(file)
Yu Shan63e24d72022-06-24 17:53:32 +0000529
530
Yu Shan41dd7f12023-06-07 13:25:43 -0700531if __name__ == '__main__':
Yu Shan63e24d72022-06-24 17:53:32 +0000532 main()