From fa1eaa1c5e3a7f255dd096af92476639729681de Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Sat, 27 Jul 2019 17:42:34 +0800 Subject: [PATCH] [tools] Fix the lib issue in Keil project generation --- tools/keil.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/keil.py b/tools/keil.py index b096917a42..7d4913dcf8 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -56,7 +56,6 @@ def _get_filetype(fn): def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path): group = SubElement(parent, 'Group') - group.text = name group_name = SubElement(group, 'GroupName') group_name.text = name @@ -92,6 +91,8 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path): file_path.text = path.decode(fs_encoding) + return group + def MDK4AddLibToGroup(ProjectFiles, group, name, filename, project_path): name = os.path.basename(filename) path = os.path.dirname (filename) @@ -125,6 +126,8 @@ def MDK4AddLibToGroup(ProjectFiles, group, name, filename, project_path): file_path.text = path.decode(fs_encoding) + return group + def MDK4AddGroup(ProjectFiles, parent, name, files, project_path): # don't add an empty group if len(files) == 0: @@ -243,16 +246,13 @@ def MDK45Project(tree, target, script): full_path = os.path.join(path_item, item + '.lib') if os.path.isfile(full_path): # has this library lib_path = full_path + break if lib_path != '': - need_create = 1 - for neighbor in groups.iter('Group'): - if neighbor.text == group['name']: - MDK4AddLibToGroup(ProjectFiles, neighbor, group['name'], lib_path, project_path) - need_create = 0 - break - if (need_create != 0): - MDK4AddGroupForFN(ProjectFiles, groups, group['name'], lib_path, project_path) + if group_tree != None: + MDK4AddLibToGroup(ProjectFiles, group_tree, group['name'], lib_path, project_path) + else: + group_tree = MDK4AddGroupForFN(ProjectFiles, groups, group['name'], lib_path, project_path) # write include path, definitions and link flags IncludePath = tree.find('Targets/Target/TargetOption/TargetArmAds/Cads/VariousControls/IncludePath')