diff --git a/tools/codeblocks.py b/tools/codeblocks.py index cb07956e73..7db82b49e9 100644 --- a/tools/codeblocks.py +++ b/tools/codeblocks.py @@ -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)) diff --git a/tools/utils.py b/tools/utils.py index 0fa8cc742e..b0472b6f2e 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -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) diff --git a/tools/vs.py b/tools/vs.py index cdad83cd10..43d25ec87f 100644 --- a/tools/vs.py +++ b/tools/vs.py @@ -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)) diff --git a/tools/vs2012.py b/tools/vs2012.py index 63457e0a0a..76850279bb 100644 --- a/tools/vs2012.py +++ b/tools/vs2012.py @@ -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')