[tools] Python 3 compatibility support

This commit is contained in:
tangyuxin
2021-04-05 11:59:54 +08:00
parent 1e4a463f36
commit 510955ba42
12 changed files with 135 additions and 56 deletions

View File

@@ -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()