diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-05-22 17:27:24 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-03 16:08:54 +0200 |
commit | 74cdbc24d1118fa5d54d2c8fc6eec50038418d02 (patch) | |
tree | 1cace0ad849387086e60a79d93ad9bb5cdec5a5e | |
parent | 39a2d58f8d97409127d5d0ae94a4fc42bc3b78c9 (diff) |
qmi-codegen: include the input file when looking for common types
-rwxr-xr-x | build-aux/qmi-codegen/qmi-codegen | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/build-aux/qmi-codegen/qmi-codegen b/build-aux/qmi-codegen/qmi-codegen index 4f1f83e..8f4c978 100755 --- a/build-aux/qmi-codegen/qmi-codegen +++ b/build-aux/qmi-codegen/qmi-codegen @@ -42,6 +42,8 @@ def codegen_main(): raise RuntimeError('Input JSON file is mandatory') if opts.output == None: raise RuntimeError('Output file pattern is mandatory') + if opts.include == None: + opts.include = [] # Prepare output file names output_file_c = open(opts.output + ".c", 'w') @@ -53,20 +55,23 @@ def codegen_main(): utils.add_header_start(output_file_h, os.path.basename(opts.output)) utils.add_source_start(output_file_c, os.path.basename(opts.output)) + # Load all common types + common_object_list_json = [] + opts.include.append(opts.input) + for include in opts.include: + include_file = open(include) + include_contents = include_file.read() + include_list = json.loads(include_contents) + for obj in include_list: + if 'common-ref' in obj: + common_object_list_json.append(obj) + include_file.close() + # Load database file contents database_file = open(opts.input) database_file_contents = database_file.read() database_file.close() - # Load all common types - common_object_list_json = [] - if opts.include != None: - for include in opts.include: - include_file = open(include) - include_contents = include_file.read() - common_object_list_json.extend(json.loads(include_contents)) - include_file.close() - # Get our message collection object_list_json = json.loads(database_file_contents) message_list = MessageList(object_list_json, common_object_list_json) |