From b6951f64b899b9e66dbc213472f6991dd353d4b6 Mon Sep 17 00:00:00 2001 From: Bernard Xiong Date: Fri, 24 Apr 2015 11:43:38 +0800 Subject: [PATCH] [tools] Using object name to decide whether use alias name in Keil MDK. --- tools/keil.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/tools/keil.py b/tools/keil.py index 9d6b14b81..214b3928d 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -66,9 +66,19 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path): file = SubElement(files, 'File') file_name = SubElement(file, 'FileName') name = os.path.basename(path) - if ProjectFiles.count(name): + + if name.find('.cpp') != -1: + obj_name = name.replace('.cpp', '.o') + elif name.find('.c') != -1: + obj_name = name.replace('.c', '.o') + elif name.find('.s') != -1: + obj_name = name.replace('.s', '.o') + elif name.find('.S') != -1: + obj_name = name.replace('.s', '.o') + + if ProjectFiles.count(obj_name): name = basename + '_' + name - ProjectFiles.append(name) + ProjectFiles.append(obj_name) file_name.text = name.decode(fs_encoding) file_type = SubElement(file, 'FileType') file_type.text = '%d' % _get_filetype(name) @@ -98,9 +108,19 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path): file = SubElement(files, 'File') file_name = SubElement(file, 'FileName') name = os.path.basename(path) - if ProjectFiles.count(name): + + if name.find('.cpp') != -1: + obj_name = name.replace('.cpp', '.o') + elif name.find('.c') != -1: + obj_name = name.replace('.c', '.o') + elif name.find('.s') != -1: + obj_name = name.replace('.s', '.o') + elif name.find('.S') != -1: + obj_name = name.replace('.s', '.o') + + if ProjectFiles.count(obj_name): name = basename + '_' + name - ProjectFiles.append(name) + ProjectFiles.append(obj_name) file_name.text = name.decode(fs_encoding) file_type = SubElement(file, 'FileType') file_type.text = '%d' % _get_filetype(name) -- GitLab