diff --git a/build-tools/capi_parser/readme.md b/build-tools/capi_parser/readme.md index 01325c718..03fb46edd 100644 --- a/build-tools/capi_parser/readme.md +++ b/build-tools/capi_parser/readme.md @@ -41,7 +41,7 @@ options: ## 5.统计工具使用指令 -注意:工作路都在interface_sdk_c下(也就是C仓下) +注意:工作路径在interface_sdk_c下(也就是C仓下) 1)统计工具(C仓-含gn文件) 在工作路径下执行:py main.py路径(相对工作路径) -N collect -P 目录文件路径 生成文件名:result_total.xlsx--扫描结果api数据 @@ -51,6 +51,14 @@ options: 生成文件名:parser_direct_data.xlsx--扫描结果api数据 3)统计工具(获取到文件级的kit、子系统和文件当前接口数) -在工作路径下执行:py main.py路径(相对工作路径) -N collect_h -P 参数随意 -O 输出json文件路径名或者不加-O -生成文件名(不加-O):file_api_json.json--文件级接口数据; +在工作路径下执行:py main.py路径(相对工作路径) -N collect_file -O 输出json文件路径名或者不加-O +生成文件名(不加-O):api_kit_c.json--文件级接口数据; 生成文件名(加-O):传入json文件路径名 + +## 5.diff工具使用指令 +注意:工作路径在interface_sdk_c下(也就是C仓下) +在工作路径下执行:py main.py路径(相对工作路径) -N diff -old 旧文件目录路径 -new 新文件目录路径 -O 输出文件路径 +生成文件名:在对应的输出文件路径会生成三个文件: +1)diff.xlsx --diff结果数据表格 +2)diff_result.txt --diff结果数据txt文件 +3)diff合集 --目录文件,里面是按kit名生成的md表格数据(其中NA或者nullOfKit是对应没有kit的数据) diff --git a/build-tools/capi_parser/src/bin/write_md.py b/build-tools/capi_parser/src/bin/write_md.py index 4b7eba8f7..dc99b9c6f 100644 --- a/build-tools/capi_parser/src/bin/write_md.py +++ b/build-tools/capi_parser/src/bin/write_md.py @@ -38,7 +38,7 @@ def sort_by_kit(result_info_list: list, output_path): write_data_in_md(first_kit_name, sorted_data, output_path) sort_by_kit_list.extend(sorted_data) first_kit_name = obj_element.kit_name - same_element = [] + same_element = [obj_element] if same_element: sorted_data = sort_by_file_path(same_element) write_data_in_md(first_kit_name, sorted_data, output_path) @@ -66,7 +66,7 @@ def sort_by_file_path(result_info_list_kit: list): sorted_data = sort_by_type(same_element) sorted_by_file_list.extend(sorted_data) first_file_name = obj_element.api_file_path - same_element = [] + same_element = [obj_element] if same_element: sorted_data = sort_by_type(same_element) sorted_by_file_list.extend(sorted_data) diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index bdde214ef..0683ba981 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -35,16 +35,16 @@ def get_modification_type_dict(): 'API删除': 0, 'API废弃': 0, 'API修改': 0, - 'API修改(原型修改)': 0, - 'API修改(约束变化)': 0 + 'API修改(原型修改)': 0, + 'API修改(约束变化)': 0 } return modification_type_dict def get_compatible_dict(): compatible_dict = { - '兼容': 0, - '不兼容': 0 + '兼容性': 0, + '非兼容性': 0 } return compatible_dict @@ -59,18 +59,16 @@ def get_api_change_obj(api_data): compatible_dict = get_compatible_dict() change_data_obj = ApiChangeData() key = 0 + api_unique_id = '' for element in api_data: - if element.is_api_change: - change_type = 'API变更' - else: - change_type = '非API变更' + api_unique_id = element.unique_id if 0 == key: change_data_obj.set_api_name(element.api_node_name) change_data_obj.set_kit_name(element.kit_name) change_data_obj.set_sub_system(element.sub_system) change_data_obj.set_is_api_change(element.is_api_change) change_data_obj.set_diff_type(element.diff_type.name) - change_data_obj.set_change_type(change_type) + change_data_obj.set_change_type(element.api_modification_type) change_data_obj.set_old_all_text(element.old_api_full_text) change_data_obj.set_new_all_text(element.new_api_full_text) change_data_obj.set_compatible_total(element.is_compatible) @@ -79,25 +77,26 @@ def get_api_change_obj(api_data): old_all_text = '{}#&#{}'.format(change_data_obj.old_all_text, element.old_api_full_text) new_all_text = '{}#&#{}'.format(change_data_obj.new_all_text, element.new_api_full_text) diff_type_all = '{}#&#{}'.format(change_data_obj.get_diff_type(), element.diff_type.name) - change_type_all = '{}#&#{}'.format(change_data_obj.get_change_type(), change_type) + change_type_all = '{}#&#{}'.format(change_data_obj.get_change_type(), element.api_modification_type) compatible_data_all = '{}#&#{}'.format(change_data_obj.get_compatible_total(), element.is_compatible) change_data_obj.set_old_all_text(old_all_text) change_data_obj.set_new_all_text(new_all_text) change_data_obj.set_diff_type(diff_type_all) change_data_obj.set_change_type(change_type_all) change_data_obj.set_compatible_total(compatible_data_all) - if element.is_compatible and (0 == compatible_dict.get('兼容')): - compatible_dict['兼容'] = 1 - elif not element.is_compatible and (0 == compatible_dict.get('不兼容')): - compatible_dict['不兼容'] = 1 + if element.is_compatible and (0 == compatible_dict.get('兼容性')): + compatible_dict['兼容性'] = 1 + elif not element.is_compatible and (0 == compatible_dict.get('非兼容性')): + compatible_dict['非兼容性'] = 1 if element.api_modification_type in modification_type_dict: modification_type_dict[element.api_modification_type] = 1 - if 1 == modification_type_dict.get('API修改(原型修改)') or 1 == modification_type_dict.get('API修改(约束变化)'): + if 1 == modification_type_dict.get('API修改(原型修改)') or 1 == modification_type_dict.get('API修改(约束变化)'): modification_type_dict['API修改'] = 1 compatible_str = change_to_json(compatible_dict) modification_type_str = change_to_json(modification_type_dict) change_data_obj.set_compatible(compatible_str) change_data_obj.set_change_num(modification_type_str) + change_data_obj.set_unique_id(api_unique_id) return change_data_obj @@ -125,7 +124,8 @@ def collect_node_api_change(api_change_info_list): api_change_info.change_num, api_change_info.old_all_text, api_change_info.new_all_text, - api_change_info.compatible_total + api_change_info.compatible_total, + api_change_info.unique_id ] change_data.append(info_data) @@ -160,6 +160,7 @@ def disposal_result_data(result_info_list): api_result = '是' if diff_info.is_api_change else '否' info_data.append(api_result) info_data.append(diff_info.api_modification_type) + info_data.append(diff_info.unique_id) data.append(info_data) return data @@ -171,19 +172,19 @@ def generate_excel(result_info_list, api_change_data, output_path): ws = wb['Sheet'] ws.title = 'api差异' ws.append(['操作标记', '差异项-旧版本', '差异项-新版本', '兼容', - '.h文件', '归属子系统', 'kit', 'API变化', 'API修改类型']) + '.h文件', '归属子系统', 'kit', 'API变化', 'API修改类型', '接口全路径']) for title in data: d = title[0], title[1], title[2], title[3], title[4],\ - title[5], title[6], title[7], title[8] + title[5], title[6], title[7], title[8], title[9] ws.append(d) change_data_list = collect_node_api_change(api_change_data) ws_of_change = wb.create_sheet('api变更次数统计') ws_of_change.append(['api名称', 'kit名称', '归属子系统', '是否是api', '操作标记', '变更类型', - '兼容性', '变更次数', '差异性-旧版本', '差异性-新版本', '兼容性列表']) + '兼容性', '变更次数', '差异性-旧版本', '差异性-新版本', '兼容性列表', '接口全路径']) for element in change_data_list: change_data = element[0], element[1], element[2], element[3], element[4], element[5],\ - element[6], element[7], element[8], element[9], element[10], + element[6], element[7], element[8], element[9], element[10], element[11] ws_of_change.append(change_data) output_path_xlsx = os.path.abspath(os.path.join(output_path, 'diff.xlsx')) wb.save(output_path_xlsx) diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py index 82729055a..4f937f991 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py @@ -51,6 +51,7 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo): diff_info.set_kit_name(old_info['kit_name']) diff_info.set_sub_system(old_info['sub_system']) diff_info.set_class_name(old_info.get('class_name')) + diff_info.set_unique_id(old_info.get('unique_id')) if 'content' in old_info['node_content']: old_content = '类名:{};\nAPI命称:{};\n差异内容:{};\n位置:{},{}\n'.format(diff_info.class_name, diff_info.api_name, @@ -73,6 +74,7 @@ def wrap_diff_info(old_info, new_info, diff_info: DiffInfo): diff_info.set_kit_name(new_info['kit_name']) diff_info.set_sub_system(new_info['sub_system']) diff_info.set_class_name(new_info.get('class_name')) + diff_info.set_unique_id(new_info.get('unique_id')) if 'content' in new_info['node_content']: new_content = '类名:{};\nAPI命称:{};\n差异内容:{};\n位置:{},{}\n'.format(diff_info.class_name, diff_info.api_name, diff --git a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py index 233638c20..05e59c2c9 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py +++ b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py @@ -21,47 +21,47 @@ import openpyxl def compare_json_file(generate_json, original_json): # 获取对比结果 - with open(generate_json, 'r', encoding='utf-8') as js1: - data1 = json.load(js1) - with open(original_json, 'r') as js2: - data2 = json.load(js2) + with open(generate_json, 'r', encoding='utf-8') as g_js: + generate_data_dict = json.load(g_js) + with open(original_json, 'r') as o_js: + original_data_dict = json.load(o_js) compare_result = [] - only_file1 = [] # 装file1独有的 - result_api = filter_compare(data1) + generate_data_only = [] # 装解析生成的json独有的数据 + result_api = filter_compare(generate_data_dict) for it in result_api: - name1 = it["name"] + result_name = it["name"] key = 0 - for item in data2: - if item["name"] == name1: + for item in original_data_dict: + if item["name"] == result_name: key = 1 compare_result.append(it) break if key == 0: - only_file1.append(it) - only_file2 = get_difference_data(compare_result, data2) # 获取file2独有的 - js1.close() - js2.close() - return compare_result, only_file1, only_file2 + generate_data_only.append(it) + original_data_only = get_difference_data(compare_result, original_data_dict) # 获取提供的json独有的数据 + g_js.close() + o_js.close() + return compare_result, generate_data_only, original_data_only def get_difference_data(compare_result, original_data): - only_file2 = [] + original_data_only = [] for item in original_data: - name2 = item["name"] + original_name = item["name"] key = 0 for it in compare_result: - name1 = it["name"] - if name2 == name1: + compare_name = it["name"] + if original_name == compare_name: key = 1 break if key == 0: - only_file2.append(item) - return only_file2 + original_data_only.append(item) + return original_data_only -def filter_compare(data1): # 获取函数和变量 +def filter_compare(analytic_data): # 获取函数和变量 result_api = [] - for it in data1: + for it in analytic_data: get_result_api(it, result_api) return result_api @@ -132,7 +132,8 @@ def collated_api_data(api_data: list): api.get('decorator'), api.get('kit_name'), api.get('location_path'), - api.get('sub_system') + api.get('sub_system'), + api.get('unique_id') ] collated_data_total.append(collated_data) return collated_data_total @@ -142,7 +143,7 @@ def generate_excel(array, name, generate_json_unique, original_json_unique): first_line_infor = ['模块名', '类名', '方法名', '函数', '类型', '起始版本', '废弃版本', 'syscap', '错误码', '是否为系统API', '模型限制', '权限', '是否支持跨平台', '是否支持卡片应用', '是否支持高阶API', - '装饰器', 'kit', '文件路径', '子系统'] + '装饰器', 'kit', '文件路径', '子系统', '接口全路径'] workbook = openpyxl.Workbook() work_sheet1 = workbook.active work_sheet1.title = '对比结果' @@ -165,7 +166,7 @@ def write_information_to_worksheet(work_sheet, information_data): write_data = data[0], data[1], data[2], data[3], data[4], \ data[5], data[6], data[7], data[8], data[9], \ data[10], data[11], data[12], data[13], data[14], \ - data[15], data[16], data[17], data[18] + data[15], data[16], data[17], data[18], data[19] work_sheet.append(write_data) @@ -190,30 +191,29 @@ def write_original_infor_to_worksheet(work_sheet, original_data): work_sheet.append(write_data) -def del_repetition_value(only_file_list, compare_list): +def del_repetition_value(generate_data_only_list, compare_list): data = [] - for item in only_file_list: + for item in generate_data_only_list: if item not in compare_list: data.append(item) return data -def get_json_file(json_file_new, json_file): # 获取生成的json文件 - json_file1 = r'{}'.format(json_file_new) # 获取要对比的json文件 - json_file2 = json_file - head_name = os.path.splitext(json_file1) # 去掉文件名后缀 +def get_json_file(generate_json_file, original_json_file): # 获取生成的json文件 + generate_json_file_path = r'{}'.format(generate_json_file) # 获取要对比的json文件 + head_name = os.path.splitext(generate_json_file_path) # 去掉文件名后缀 head_name = head_name[0] + '.xlsx' # 加后缀 - result_list = [] - only_file1 = [] - only_file2 = [] - for item in json_file2: # 对比每一个json(目录下的) + compare_result_list = [] + generate_data_only = [] + original_data_only = [] + for item in original_json_file: # 对比每一个json(目录下的) # 对比两个json文件 - result_list_part, only_file1_part, only_file2_part = compare_json_file(json_file1, item) - result_list.extend(result_list_part) - only_file1.extend(only_file1_part) - only_file2.extend(only_file2_part) - only_file1_new = del_repetition_value(only_file1, result_list) - return result_list, head_name, only_file1_new, only_file2 # 返回对比数据,和所需表格名 + result_list_part, generate_data, original_data = compare_json_file(generate_json_file_path, item) + compare_result_list.extend(result_list_part) + generate_data_only.extend(generate_data) + original_data_only.extend(original_data) + generate_data_only_new = del_repetition_value(generate_data_only, compare_result_list) + return compare_result_list, head_name, generate_data_only_new, original_data_only # 返回对比数据,和所需表格名 def get_api_data(parser_data, excel_file_name): diff --git a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py index 39bf9a665..70c446b0f 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py @@ -55,8 +55,6 @@ def processing_root_parent(cursor_parent): def processing_no_child(cursor, data, last_data): # 处理没有子节点的节点 - if last_data and 'module_name' in last_data: - data['module_name'] = last_data['module_name'] if cursor.kind == CursorKind.INTEGER_LITERAL: # 整型字面量类型节点,没有子节点 tokens = cursor.get_tokens() for token in tokens: @@ -195,6 +193,21 @@ special_node_process = { } +def get_api_unique_id(cursor, loc): + parent_of_cursor = cursor.semantic_parent + unique_id = '' + if parent_of_cursor: + if parent_of_cursor.kind == CursorKind.TRANSLATION_UNIT: + parent_name_str = '' + else: + parent_name_str = parent_of_cursor.spelling + if not parent_name_str: + unique_id = '{}#{}'.format(loc["location_path"], cursor.spelling) + else: + unique_id = '{}#{}#{}'.format(loc["location_path"], parent_name_str, cursor.spelling) + return unique_id + + def processing_special_node(cursor, data, key, gn_path=None): # 处理需要特殊处理的节点 if key == 0: location_path = cursor.spelling @@ -212,6 +225,7 @@ def processing_special_node(cursor, data, key, gn_path=None): # 处理需要特 relative_path = os.path.relpath(location_path, gn_path) # 获取头文件相对路 loc["location_path"] = relative_path data["location"] = loc + data["unique_id"] = get_api_unique_id(cursor, loc) if kind_name in special_node_process.keys(): node_process = special_node_process[kind_name] node_process(cursor, data) # 调用对应节点处理函数 @@ -266,7 +280,8 @@ def get_default_node_data(cursor, gn_path=None): "cross_platform": 'NA', "form": 'NA', "atomic_service": 'NA', - "decorator": 'NA' + "decorator": 'NA', + "unique_id": '' } return data @@ -306,8 +321,10 @@ def parser_data_assignment(cursor, current_file, gn_path=None, comment=None, key def ast_to_dict(cursor, current_file, last_data, gn_path=None, comment=None, key=0): # 解析数据的整理 # 通用赋值 data = parser_data_assignment(cursor, current_file, gn_path, comment, key) - if last_data and 'module_name' in last_data: + if last_data: data['module_name'] = last_data['module_name'] + data['kit_name'] = last_data['kit_name'] + data['syscap'] = last_data['syscap'] children = list(cursor.get_children()) # 判断是否有子节点,有就追加children,没有根据情况来 if len(children) > 0: if key != 0: diff --git a/build-tools/capi_parser/src/coreImpl/parser/parser.py b/build-tools/capi_parser/src/coreImpl/parser/parser.py index 67b5f0fbe..5d1960f80 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -20,7 +20,6 @@ import os import glob import re import shutil -import stat from utils.constants import StringConstant, RegularExpressions from typedef.parser.parser import ParserGetResultTable, OneFileApiMessage, NodeKind from coreImpl.parser import parse_include, generating_tables # 引入解析文件 # 引入得到结果表格文件 @@ -128,13 +127,15 @@ def change_abs(include_files, dire_path): # 获取.h绝对路径 if os.path.isabs(j_item): # 是否是绝对路径,是就拼接路径盘,不是就拼接gn目录路径 head = os.path.splitdrive(dire_path) # 获取windows盘路径 include_file = os.path.normpath(j_item) + change_path = head[1].split('interface_sdk_c') + replace_path = os.path.normpath(os.path.join(change_path[0], 'interface_sdk_c')) if 'third_party/node/src' in j_item: include_file = include_file.replace('\\\\', - '{}{}'.format(StringConstant.REPLACE_WAREHOUSE.value, '\\')) + '{}{}'.format(replace_path, '\\')) else: # 去掉绝对路径的双\\,替换为interface_sdk_c include_file = include_file.replace('\\\\interface\\sdk_c', - StringConstant.REPLACE_WAREHOUSE.value) + replace_path) if head: include_file = os.path.join(head[0], include_file) # 拼接盘和路径 abs_path.append(include_file) @@ -145,21 +146,22 @@ def change_abs(include_files, dire_path): # 获取.h绝对路径 def get_result_table(json_files, abs_path, link_path, gn_path): # 进行处理,生成表格 - result_list = [] + compare_result_list = [] head_name = "" - only_file1 = [] - only_file2 = [] - data = [] + generate_data_only = [] + original_data_only = [] + parser_file_data = [] if json_files: file_name = os.path.split(json_files[0]) # 取第一个json名,但我是用列表装的 file_name = os.path.splitext(file_name[1]) # 取下标1对应的元素(元组) - data = parse_include.get_include_file(abs_path, link_path, gn_path) # 获取解析返回的数据 - parse_json_name = change_json_file(data, file_name[0]) # 生成json文件 + parser_file_data = parse_include.get_include_file(abs_path, link_path, gn_path) # 获取解析返回的数据 + parser_json_name = change_json_file(parser_file_data, file_name[0]) # 生成json文件 # 解析完后,传两个json文件,对比两个json文件,最后生成数据表格 - result_list, head_name, only_file1, only_file2 = generating_tables.get_json_file(parse_json_name, - json_files) + (compare_result_list, head_name, generate_data_only, + original_data_only) = generating_tables.get_json_file(parser_json_name, json_files) - obj_data = ParserGetResultTable(result_list, head_name, only_file1, only_file2, data) + obj_data = ParserGetResultTable(compare_result_list, head_name, + generate_data_only, original_data_only, parser_file_data) return obj_data @@ -202,9 +204,9 @@ def link_include(directory_path, function_names, link_include_file): def main_entrance(directory_path, function_names, link_path): # 主入口 gn_file_total = find_gn_file(directory_path) # 查找gn文件 - result_list_total = [] - only_file1_total = [] - only_file2_total = [] + compare_result_list_total = [] + generate_data_only_total = [] + original_data_only_total = [] data_total = [] # 总的解析数据 for item in gn_file_total: # 处理每个gn文件 match_files, json_files, include_files = dire_func(item, function_names) @@ -213,31 +215,38 @@ def main_entrance(directory_path, function_names, link_path): # 主入口 abs_path = change_abs(include_files, dire_path) # 接收.h绝对路径 # 接收对比结果信息 data_result = get_result_table(json_files, abs_path, link_path, directory_path) - data_total.append(data_result.data) - if len(data_result.result_list) != 0: - result_list_total.extend(data_result.result_list) - only_file1_total.extend(data_result.only_file1) - only_file2_total.extend(data_result.only_file2) + data_total.append(data_result.parser_data) + if len(data_result.compare_result_list) != 0: + compare_result_list_total.extend(data_result.compare_result_list) + generate_data_only_total.extend(data_result.generate_data_only) + original_data_only_total.extend(data_result.original_data_only) elif data_result.head_name == "": print("gn文件下无json文件") else: - generating_tables.generate_excel(data_result.result_list, data_result.head_name, - data_result.only_file1, data_result.only_file2) + generate_data_only_total.extend(data_result.generate_data_only) + original_data_only_total.extend(data_result.original_data_only) print("没有匹配项") else: print("gn文件无header函数") - generating_tables.generate_excel(result_list_total, StringConstant.RESULT_HEAD_NAME.value, - only_file1_total, only_file2_total) + generating_tables.generate_excel(compare_result_list_total, StringConstant.RESULT_HEAD_NAME.value, + generate_data_only_total, original_data_only_total) - obj_data_total = ParserGetResultTable(result_list_total, '', only_file1_total, - only_file2_total, data_total) + obj_data_total = ParserGetResultTable(compare_result_list_total, '', generate_data_only_total, + original_data_only_total, data_total) return obj_data_total -def copy_std_lib(link_include_file): +def copy_std_lib(link_include_file, root_path=''): + if root_path: + include_lib = os.path.abspath(os.path.join(root_path, StringConstant.INCLUDE_LIB.value)) + else: + include_lib = StringConstant.INCLUDE_LIB.value std_include = StringConstant.STD_INCLUDE.value if not os.path.exists(std_include): - shutil.copytree(StringConstant.INCLUDE_LIB.value, std_include) + try: + shutil.copytree(include_lib, std_include) + except OSError: + pass if std_include not in link_include_file: link_include_file.append(std_include) @@ -396,6 +405,7 @@ def parser_direct(path): # 目录路径 copy_std_lib(link_include_path) dir_path = '' if os.path.isdir(path): + link_include_path.append(path) file_path_total, link_include_total = get_dir_file_path(path) file_path_list.extend(file_path_total) link_include_path.extend(link_include_total) @@ -404,6 +414,7 @@ def parser_direct(path): # 目录路径 if path.endswith('.h'): file_path_list.append(path) dir_path = os.path.dirname(path) + link_include_path.append(dir_path) data_total = parse_include.get_include_file(file_path_list, link_include_path, dir_path) generating_tables.get_api_data(data_total, StringConstant.PARSER_DIRECT_EXCEL_NAME.value) diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 1f093709a..196a4ec2a 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -256,8 +256,8 @@ api_modification_type_dict = { 'api_new_list': 'API新增', 'api_delete_list': 'API删除', 'non_api_change_list': '非API变更', - 'api_prototype_change_list': 'API修改(原型修改)', - 'api_constraint_change_list': 'API修改(约束变化)' + 'api_prototype_change_list': 'API修改(原型修改)', + 'api_constraint_change_list': 'API修改(约束变化)' } @@ -288,6 +288,7 @@ class DiffInfo: sub_system = '' class_name = '' api_node_name = '' + unique_id = '' def __init__(self, diff_type: DiffType): self.diff_type = diff_type @@ -402,6 +403,12 @@ class DiffInfo: def get_api_node_name(self): return self.api_node_name + def set_unique_id(self, unique_id): + self.unique_id = unique_id + + def get_unique_id(self): + return self.unique_id + class OutputJson: api_name: str = '' @@ -419,6 +426,7 @@ class OutputJson: kit_name = '' sub_system = '' class_name = '' + unique_id = '' def __init__(self, diff_info): self.api_name = diff_info.api_name @@ -436,6 +444,7 @@ class OutputJson: self.kit_name = diff_info.kit_name self.sub_system = diff_info.sub_system self.class_name = diff_info.class_name + self.unique_id = diff_info.unique_id class ApiChangeData: @@ -450,6 +459,7 @@ class ApiChangeData: old_all_text: str = '' new_all_text: str = '' compatible_total = False + unique_id: str = '' def set_api_name(self, api_name): self.api_name = api_name @@ -516,3 +526,9 @@ class ApiChangeData: def get_compatible_total(self): return self.compatible_total + + def set_unique_id(self, unique_id): + self.unique_id = unique_id + + def get_unique_id(self): + return self.unique_id diff --git a/build-tools/capi_parser/src/typedef/parser/parser.py b/build-tools/capi_parser/src/typedef/parser/parser.py index 12a7a7064..56bd09fcf 100644 --- a/build-tools/capi_parser/src/typedef/parser/parser.py +++ b/build-tools/capi_parser/src/typedef/parser/parser.py @@ -17,18 +17,18 @@ import enum class ParserGetResultTable: - result_list = [] + compare_result_list = [] head_name = "" - only_file1 = [] - only_file2 = [] - data = [] + generate_data_only = [] + original_data_only = [] + parser_data = [] - def __init__(self, result_list_need, head_name_need, only_file1_need, only_file2_need, data_need): - self.result_list = result_list_need + def __init__(self, compare_result_list, head_name_need, generate_data_only, original_data_only, parser_data): + self.compare_result_list = compare_result_list self.head_name = head_name_need - self.only_file1 = only_file1_need - self.only_file2 = only_file2_need - self.data = data_need + self.generate_data_only = generate_data_only + self.original_data_only = original_data_only + self.parser_data = parser_data class OneFileApiMessage: