提交 3802754f 编写于 作者: B bernard

[Tools] Fix the walk_children issue

上级 d6aa4228
......@@ -31,17 +31,20 @@ import xml.etree.ElementTree as etree
from xml.etree.ElementTree import SubElement
from utils import _make_path_relative
from utils import xml_indent
import utils
fs_encoding = sys.getfilesystemencoding()
def CB_AddHeadFiles(program, elem, project_path):
building.source_ext = []
building.source_ext = ["h"]
utils.source_ext = []
utils.source_ext = ["h"]
for item in program:
building.walk_children(item)
building.source_list.sort()
# print building.source_list
utils.walk_children(item)
utils.source_list.sort()
# print utils.source_list
for f in building.source_list:
for f in utils.source_list:
path = _make_path_relative(project_path, f)
Unit = SubElement(elem, 'Unit')
Unit.set('filename', path.decode(fs_encoding))
......
......@@ -103,3 +103,24 @@ def xml_indent(elem, level=0):
else:
if level and (not elem.tail or not elem.tail.strip()):
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)
......@@ -26,6 +26,7 @@ import os
import sys
import string
import building
import utils
import xml.etree.ElementTree as etree
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))
def VS_AddHeadFilesGroup(program, elem, project_path):
building.source_ext = []
building.source_ext = ["h"]
utils.source_ext = []
utils.source_ext = ["h"]
for item in program:
building.walk_children(item)
building.source_list.sort()
# print building.source_list
utils.walk_children(item)
utils.source_list.sort()
# print utils.source_list
for f in building.source_list:
for f in utils.source_list:
path = _make_path_relative(project_path, f)
File = SubElement(elem, 'File')
File.set('RelativePath', path.decode(fs_encoding))
......
......@@ -32,6 +32,8 @@ import xml.etree.ElementTree as etree
from xml.etree.ElementTree import SubElement
from utils import _make_path_relative
from utils import xml_indent
import utils
fs_encoding = sys.getfilesystemencoding()
#reference
......@@ -123,12 +125,12 @@ def VS_add_ItemGroup(parent, file_type, files, project_path):
ObjName.text = ''.join('$(IntDir)'+objpath+'\\')
def VS_add_HeadFiles(program, elem, project_path):
building.source_ext = []
building.source_ext = ["h"]
utils.source_ext = []
utils.source_ext = ["h"]
for item in program:
building.walk_children(item)
building.source_list.sort()
# print building.source_list
utils.walk_children(item)
utils.source_list.sort()
# print utils.source_list
ItemGroup = SubElement(elem, 'ItemGroup')
filter_h_ItemGroup = SubElement(filter_project, 'ItemGroup')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册