diff --git a/tools/codeblocks.py b/tools/codeblocks.py index cb07956e73b17494d6de572b0e065e947275d95f..7db82b49e9f5dc839da71db9bcc19bedae20d5fe 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 0fa8cc742e46345a2efe70f1df4c2206c303a907..b0472b6f2e75917414e12f592888d49c65823e35 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 cdad83cd10eb30425b1016345e38887f4aafe375..43d25ec87f36f70f16d4f1b617bfdca6fe65399a 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 63457e0a0a43223c4719a5e8b37320784fb243dd..76850279bbc676e825c82f5b112a7d61e17e4a0a 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')