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 8a8c56d92d04eb6590675548b68458e7b6dd1144..8596ccc6cb3d9f55bc774a69b81398d5d2eea5a0 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -67,7 +67,6 @@ def get_api_change_obj(api_data): 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_class_name(element.class_name) change_data_obj.set_diff_type(element.operation_diff_type) change_data_obj.set_change_type(element.api_modification_type) change_data_obj.set_old_all_text(element.old_api_full_text) @@ -120,7 +119,6 @@ def collect_node_api_change(api_change_info_list): api_change_info.kit_name, api_change_info.sub_system, api_change_info.is_api_change, - api_change_info.class_name, api_change_info.diff_type, api_change_info.change_type, api_change_info.compatible, @@ -154,12 +152,18 @@ def disposal_result_data(result_info_list): info_data = [ diff_info.operation_diff_type, diff_info.old_api_full_text, - diff_info.new_api_full_text, - diff_info.api_file_path, - diff_info.sub_system, - diff_info.kit_name, - diff_info.is_system_api + diff_info.new_api_full_text ] + result = '是' if diff_info.is_compatible else '否' + info_data.append(result) + info_data.append(diff_info.api_file_path) + info_data.append(diff_info.sub_system) + info_data.append(diff_info.kit_name) + 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) + info_data.append(diff_info.is_system_api) data.append(info_data) return data @@ -170,20 +174,23 @@ def generate_excel(result_info_list, api_change_data, output_path): wb = op.Workbook() ws = wb['Sheet'] ws.title = 'api差异' - ws.append(['操作标记', '差异项-旧版本', '差异项-新版本', '.h文件', '归属子系统', 'kit', '是否为系统API']) + ws.append(['操作标记', '差异项-旧版本', '差异项-新版本', '兼容', + '.h文件', '归属子系统', 'kit', 'API变化', 'API修改类型', '接口全路径', '是否为系统API']) for title in data: - d = title[0], title[1], title[2], title[3], title[4], title[5], title[6] + d = title[0], title[1], title[2], title[3], title[4],\ + title[5], title[6], title[7], title[8], title[9],\ + title[10] 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', 'api类型', '操作标记', '变更类型', + ws_of_change.append(['api名称', 'kit名称', '归属子系统', '是否是api', '操作标记', '变更类型', '兼容性', '变更次数', '差异项-旧版本', '差异项-新版本', '兼容性列表', '接口全路径', '是否为系统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[11],\ - element[12], element[13] + element[12] ws_of_change.append(change_data) output_path_xlsx = os.path.abspath(os.path.join(output_path, 'diff.xlsx')) wb.save(output_path_xlsx) @@ -247,18 +254,18 @@ def add_new_file(diff_file_path): if os.path.isdir(diff_file_path): add_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) def del_old_file(diff_file_path): if os.path.isdir(diff_file_path): del_file(diff_file_path) else: - result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_dir): @@ -295,9 +302,9 @@ def del_file(dir_path): if os.path.isdir(file_path): del_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0)) + result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0), 1) for old_info in result_map.values(): - diff_info_list.extend(judgment_entrance(old_info, None)) + diff_info_list.extend(judgment_entrance(old_info, None, 1)) def add_file(dir_path): @@ -309,9 +316,9 @@ def add_file(dir_path): if os.path.isdir(file_path): add_file(file_path) if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1)) + result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1), 1) for new_info in result_map.values(): - diff_info_list.extend(judgment_entrance(None, new_info)) + diff_info_list.extend(judgment_entrance(None, new_info, 1)) def parse_file_result(result, data_type=0): @@ -324,6 +331,7 @@ def parse_file_result(result, data_type=0): for root_node in result: if data_type != 1: parse_file_result_by_child(result_map, root_node) + result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map 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 57e22f629e7e9b7217a6864bfd6494cc72ad552c..5401e37f970cc19c1c526c3012ed0a3044a39c6e 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py @@ -198,14 +198,10 @@ special_node_process = { def get_api_unique_id(cursor, loc): - unique_id = '' - if cursor.kind == CursorKind.MACRO_DEFINITION: - unique_id = '{}#{}'.format(loc["location_path"], cursor.spelling) - return unique_id - parent_of_cursor = cursor.semantic_parent struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, NodeKind.ENUM_DECL.value] + unique_id = '' if parent_of_cursor: unique_name = cursor.spelling try: @@ -226,7 +222,7 @@ def get_api_unique_id(cursor, loc): return unique_id -def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊处理的节点 +def processing_special_node(cursor, data, key, gn_path=None): # 处理需要特殊处理的节点 if key == 0: location_path = cursor.spelling kind_name = CursorKind.TRANSLATION_UNIT.name @@ -276,7 +272,7 @@ def define_comment(cursor, current_file, data): data['comment'] = matches.group() -def get_default_node_data(cursor, gn_path): +def get_default_node_data(cursor, gn_path=None): data = { "name": cursor.spelling, "kind": '', @@ -304,7 +300,7 @@ def get_default_node_data(cursor, gn_path): return data -def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): +def parser_data_assignment(cursor, current_file, gn_path=None, comment=None, key=0): data = get_default_node_data(cursor, gn_path) get_comment(cursor, data) 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 6561aa22a246f8d086fbd160a028e9f58b0d511e..dca2f920cafb6382132f2eea95ab134005a610fa 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -126,19 +126,18 @@ def change_abs(include_files, dire_path): # 获取.h绝对路径 # 把规范路径和gn文件对应的目录路径拼接 if os.path.isabs(j_item): # 是否是绝对路径,是就拼接路径盘,不是就拼接gn目录路径 head = os.path.splitdrive(dire_path) # 获取windows盘路径 - include_file = j_item + 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(replace_path, '/')) + include_file = include_file.replace('\\\\', + '{}{}'.format(replace_path, '\\')) else: # 去掉绝对路径的双\\,替换为interface_sdk_c - include_file = include_file.replace('//interface/sdk_c', + include_file = include_file.replace('\\\\interface\\sdk_c', replace_path) if head: include_file = os.path.join(head[0], include_file) # 拼接盘和路径 - include_file = os.path.normpath(include_file) abs_path.append(include_file) else: relative_path = os.path.abspath(os.path.join(dire_path, os.path.normpath(j_item))) # ../ .解决 diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index ea2741256038f82ea1d4536ba86089ef9fbf9fb8..c7b2c8c1f872feafc2311c10ce72a295db8944f5 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -568,7 +568,6 @@ class ApiChangeData: kit_name: str = '' sub_system: str = '' is_api_change = False - class_name: str = '' diff_type: str = '' change_type: str = '' compatible = {} @@ -603,12 +602,6 @@ class ApiChangeData: def get_is_api_change(self): return self.is_api_change - def set_class_name(self, class_name): - self.class_name = class_name - - def get_class_name(self): - return self.class_name - def set_diff_type(self, diff_type): self.diff_type = diff_type