mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-28 18:10:21 +00:00
[tools] Python 3 compatibility support
This commit is contained in:
28
tools/vs.py
28
tools/vs.py
@@ -45,9 +45,12 @@ def VS_AddGroup(ProjectFiles, parent, name, files, libs, project_path):
|
||||
|
||||
path = _make_path_relative(project_path, path)
|
||||
path = os.path.join(path, name)
|
||||
|
||||
try:
|
||||
path = path.decode(fs_encoding)
|
||||
except:
|
||||
path = path
|
||||
File = SubElement(Filter, 'File')
|
||||
File.set('RelativePath', path.decode(fs_encoding))
|
||||
File.set('RelativePath', path)
|
||||
|
||||
for lib in libs:
|
||||
name = os.path.basename(lib)
|
||||
@@ -57,7 +60,11 @@ def VS_AddGroup(ProjectFiles, parent, name, files, libs, project_path):
|
||||
path = os.path.join(path, name)
|
||||
|
||||
File = SubElement(Filter, 'File')
|
||||
File.set('RelativePath', path.decode(fs_encoding))
|
||||
try:
|
||||
path = path.decode(fs_encoding)
|
||||
except:
|
||||
path = path
|
||||
File.set('RelativePath', path)
|
||||
|
||||
def VS_AddHeadFilesGroup(program, elem, project_path):
|
||||
utils.source_ext = []
|
||||
@@ -70,7 +77,11 @@ def VS_AddHeadFilesGroup(program, elem, project_path):
|
||||
for f in utils.source_list:
|
||||
path = _make_path_relative(project_path, f)
|
||||
File = SubElement(elem, 'File')
|
||||
File.set('RelativePath', path.decode(fs_encoding))
|
||||
try:
|
||||
path = path.decode(fs_encoding)
|
||||
except:
|
||||
path = path
|
||||
File.set('RelativePath', path)
|
||||
|
||||
def VSProject(target, script, program):
|
||||
project_path = os.path.dirname(os.path.abspath(target))
|
||||
@@ -158,12 +169,17 @@ def VSProject(target, script, program):
|
||||
for path in lib_path:
|
||||
inc = _make_path_relative(project_path, os.path.normpath(path))
|
||||
paths.add(inc) #.replace('\\', '/')
|
||||
|
||||
|
||||
paths = [i for i in paths]
|
||||
paths.sort()
|
||||
lib_paths = ';'.join(paths)
|
||||
elem.set('AdditionalLibraryDirectories', lib_paths)
|
||||
|
||||
xml_indent(root)
|
||||
out.write(etree.tostring(root, encoding='utf-8'))
|
||||
text = etree.tostring(root, encoding='utf-8')
|
||||
try:
|
||||
text = text.decode(encoding="utf-8")
|
||||
except:
|
||||
text = text
|
||||
out.write(text)
|
||||
out.close()
|
||||
|
||||
Reference in New Issue
Block a user