[Tools] Fix the walk_children issue
This commit is contained in:
parent
d6aa42285a
commit
3802754f05
|
@ -31,17 +31,20 @@ import xml.etree.ElementTree as etree
|
||||||
from xml.etree.ElementTree import SubElement
|
from xml.etree.ElementTree import SubElement
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
from utils import xml_indent
|
from utils import xml_indent
|
||||||
|
|
||||||
|
import utils
|
||||||
|
|
||||||
fs_encoding = sys.getfilesystemencoding()
|
fs_encoding = sys.getfilesystemencoding()
|
||||||
|
|
||||||
def CB_AddHeadFiles(program, elem, project_path):
|
def CB_AddHeadFiles(program, elem, project_path):
|
||||||
building.source_ext = []
|
utils.source_ext = []
|
||||||
building.source_ext = ["h"]
|
utils.source_ext = ["h"]
|
||||||
for item in program:
|
for item in program:
|
||||||
building.walk_children(item)
|
utils.walk_children(item)
|
||||||
building.source_list.sort()
|
utils.source_list.sort()
|
||||||
# print building.source_list
|
# print utils.source_list
|
||||||
|
|
||||||
for f in building.source_list:
|
for f in utils.source_list:
|
||||||
path = _make_path_relative(project_path, f)
|
path = _make_path_relative(project_path, f)
|
||||||
Unit = SubElement(elem, 'Unit')
|
Unit = SubElement(elem, 'Unit')
|
||||||
Unit.set('filename', path.decode(fs_encoding))
|
Unit.set('filename', path.decode(fs_encoding))
|
||||||
|
|
|
@ -103,3 +103,24 @@ def xml_indent(elem, level=0):
|
||||||
else:
|
else:
|
||||||
if level and (not elem.tail or not elem.tail.strip()):
|
if level and (not elem.tail or not elem.tail.strip()):
|
||||||
elem.tail = i
|
elem.tail = i
|
||||||
|
|
||||||
|
|
||||||
|
source_ext = ["c", "h", "s", "S", "cpp", "xpm"]
|
||||||
|
source_list = []
|
||||||
|
|
||||||
|
def walk_children(child):
|
||||||
|
global source_list
|
||||||
|
global source_ext
|
||||||
|
|
||||||
|
# print child
|
||||||
|
full_path = child.rfile().abspath
|
||||||
|
file_type = full_path.rsplit('.',1)[1]
|
||||||
|
#print file_type
|
||||||
|
if file_type in source_ext:
|
||||||
|
if full_path not in source_list:
|
||||||
|
source_list.append(full_path)
|
||||||
|
|
||||||
|
children = child.all_children()
|
||||||
|
if children != []:
|
||||||
|
for item in children:
|
||||||
|
walk_children(item)
|
||||||
|
|
13
tools/vs.py
13
tools/vs.py
|
@ -26,6 +26,7 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import string
|
import string
|
||||||
import building
|
import building
|
||||||
|
import utils
|
||||||
|
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
from xml.etree.ElementTree import SubElement
|
from xml.etree.ElementTree import SubElement
|
||||||
|
@ -59,14 +60,14 @@ def VS_AddGroup(ProjectFiles, parent, name, files, libs, project_path):
|
||||||
File.set('RelativePath', path.decode(fs_encoding))
|
File.set('RelativePath', path.decode(fs_encoding))
|
||||||
|
|
||||||
def VS_AddHeadFilesGroup(program, elem, project_path):
|
def VS_AddHeadFilesGroup(program, elem, project_path):
|
||||||
building.source_ext = []
|
utils.source_ext = []
|
||||||
building.source_ext = ["h"]
|
utils.source_ext = ["h"]
|
||||||
for item in program:
|
for item in program:
|
||||||
building.walk_children(item)
|
utils.walk_children(item)
|
||||||
building.source_list.sort()
|
utils.source_list.sort()
|
||||||
# print building.source_list
|
# print utils.source_list
|
||||||
|
|
||||||
for f in building.source_list:
|
for f in utils.source_list:
|
||||||
path = _make_path_relative(project_path, f)
|
path = _make_path_relative(project_path, f)
|
||||||
File = SubElement(elem, 'File')
|
File = SubElement(elem, 'File')
|
||||||
File.set('RelativePath', path.decode(fs_encoding))
|
File.set('RelativePath', path.decode(fs_encoding))
|
||||||
|
|
|
@ -32,6 +32,8 @@ import xml.etree.ElementTree as etree
|
||||||
from xml.etree.ElementTree import SubElement
|
from xml.etree.ElementTree import SubElement
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
from utils import xml_indent
|
from utils import xml_indent
|
||||||
|
import utils
|
||||||
|
|
||||||
fs_encoding = sys.getfilesystemencoding()
|
fs_encoding = sys.getfilesystemencoding()
|
||||||
|
|
||||||
#reference
|
#reference
|
||||||
|
@ -123,12 +125,12 @@ def VS_add_ItemGroup(parent, file_type, files, project_path):
|
||||||
ObjName.text = ''.join('$(IntDir)'+objpath+'\\')
|
ObjName.text = ''.join('$(IntDir)'+objpath+'\\')
|
||||||
|
|
||||||
def VS_add_HeadFiles(program, elem, project_path):
|
def VS_add_HeadFiles(program, elem, project_path):
|
||||||
building.source_ext = []
|
utils.source_ext = []
|
||||||
building.source_ext = ["h"]
|
utils.source_ext = ["h"]
|
||||||
for item in program:
|
for item in program:
|
||||||
building.walk_children(item)
|
utils.walk_children(item)
|
||||||
building.source_list.sort()
|
utils.source_list.sort()
|
||||||
# print building.source_list
|
# print utils.source_list
|
||||||
ItemGroup = SubElement(elem, 'ItemGroup')
|
ItemGroup = SubElement(elem, 'ItemGroup')
|
||||||
|
|
||||||
filter_h_ItemGroup = SubElement(filter_project, 'ItemGroup')
|
filter_h_ItemGroup = SubElement(filter_project, 'ItemGroup')
|
||||||
|
|
Loading…
Reference in New Issue