diff options
| author | Bernard Xiong <[email protected]> | 2018-11-10 18:29:08 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2018-11-10 18:29:08 +0800 |
| commit | d687cfb22841ba0e1ccf4c946f672dfaeae239cb (patch) | |
| tree | af7d6547eef20e642e1230c141585507f839924e /tools/keil.py | |
| parent | b69baa965809420fc3fcd19dd55fc1126a68c08d (diff) | |
[Tools] Change building script for Py3
Diffstat (limited to 'tools/keil.py')
| -rw-r--r-- | tools/keil.py | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/tools/keil.py b/tools/keil.py index 48aec80a41..59da254430 100644 --- a/tools/keil.py +++ b/tools/keil.py @@ -159,12 +159,12 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path): if ProjectFiles.count(obj_name): name = basename + '_' + name ProjectFiles.append(obj_name) - file_name.text = name.decode(fs_encoding) + file_name.text = name # name.decode(fs_encoding) file_type = SubElement(file, 'FileType') file_type.text = '%d' % _get_filetype(name) file_path = SubElement(file, 'FilePath') - file_path.text = path.decode(fs_encoding) + file_path.text = path # path.decode(fs_encoding) return group @@ -173,7 +173,7 @@ def MDK45Project(tree, target, script): project_path = os.path.dirname(os.path.abspath(target)) root = tree.getroot() - out = file(target, 'wb') + out = open(target, 'w') out.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n') CPPPATH = [] @@ -191,51 +191,51 @@ def MDK45Project(tree, target, script): group_tree = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path) # for local CPPPATH/CPPDEFINES - if (group_tree != None) and (group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPDEFINES')): + if (group_tree != None) and ('LOCAL_CPPPATH' in group or 'LOCAL_CCFLAGS' in group or 'LOCAL_CPPDEFINES' in group): GroupOption = SubElement(group_tree, 'GroupOption') GroupArmAds = SubElement(GroupOption, 'GroupArmAds') Cads = SubElement(GroupArmAds, 'Cads') VariousControls = SubElement(Cads, 'VariousControls') MiscControls = SubElement(VariousControls, 'MiscControls') - if group.has_key('LOCAL_CCFLAGS'): + if 'LOCAL_CCFLAGS' in group: MiscControls.text = group['LOCAL_CCFLAGS'] else: MiscControls.text = ' ' Define = SubElement(VariousControls, 'Define') - if group.has_key('LOCAL_CPPDEFINES'): + if 'LOCAL_CPPDEFINES' in group: Define.text = ', '.join(set(group['LOCAL_CPPDEFINES'])) else: Define.text = ' ' Undefine = SubElement(VariousControls, 'Undefine') Undefine.text = ' ' IncludePath = SubElement(VariousControls, 'IncludePath') - if group.has_key('LOCAL_CPPPATH'): + if 'LOCAL_CPPPATH' in group: IncludePath.text = ';'.join([_make_path_relative(project_path, os.path.normpath(i)) for i in group['LOCAL_CPPPATH']]) else: IncludePath.text = ' ' # get each include path - if group.has_key('CPPPATH') and group['CPPPATH']: + if 'CPPPATH' in group and group['CPPPATH']: if CPPPATH: CPPPATH += group['CPPPATH'] else: CPPPATH += group['CPPPATH'] # get each group's definitions - if group.has_key('CPPDEFINES') and group['CPPDEFINES']: + if 'CPPDEFINES' in group and group['CPPDEFINES']: if CPPDEFINES: CPPDEFINES += group['CPPDEFINES'] else: CPPDEFINES = group['CPPDEFINES'] # get each group's link flags - if group.has_key('LINKFLAGS') and group['LINKFLAGS']: + if 'LINKFLAGS' in group and group['LINKFLAGS']: if LINKFLAGS: LINKFLAGS += ' ' + group['LINKFLAGS'] else: LINKFLAGS += group['LINKFLAGS'] - if group.has_key('LIBS') and group['LIBS']: + if 'LIBS' in group and group['LIBS']: for item in group['LIBS']: lib_path = '' for path_item in group['LIBPATH']: @@ -260,7 +260,7 @@ def MDK45Project(tree, target, script): Misc.text = LINKFLAGS xml_indent(root) - out.write(etree.tostring(root, encoding='utf-8')) + out.write(etree.tostring(root, encoding='utf-8').decode()) out.close() def MDK4Project(target, script): @@ -294,10 +294,10 @@ def MDK5Project(target, script): shutil.copy2('template.uvoptx', 'project.uvoptx') def MDKProject(target, script): - template = file('template.Uv2', "rb") + template = open('template.Uv2', "r") lines = template.readlines() - project = file(target, "wb") + project = open(target, "w") project_path = os.path.dirname(os.path.abspath(target)) line_index = 5 @@ -323,21 +323,21 @@ def MDKProject(target, script): # print group['name'] # get each include path - if group.has_key('CPPPATH') and group['CPPPATH']: + if 'CPPPATH' in group and group['CPPPATH']: if CPPPATH: CPPPATH += group['CPPPATH'] else: CPPPATH += group['CPPPATH'] # get each group's definitions - if group.has_key('CPPDEFINES') and group['CPPDEFINES']: + if 'CPPDEFINES' in group and group['CPPDEFINES']: if CPPDEFINES: CPPDEFINES += group['CPPDEFINES'] else: CPPDEFINES = group['CPPDEFINES'] # get each group's link flags - if group.has_key('LINKFLAGS') and group['LINKFLAGS']: + if 'LINKFLAGS' in group and group['LINKFLAGS']: if LINKFLAGS: LINKFLAGS += ' ' + group['LINKFLAGS'] else: |
