From 877d1b38b0776919118c458f05dffeb9b5145115 Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Sat, 1 Dec 2012 07:01:55 +0000 Subject: [PATCH] support header files addition for vs script git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2461 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- tools/building.py | 2 +- tools/vs.py | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/building.py b/tools/building.py index 032e9dd8b9..6ae8d32e5f 100644 --- a/tools/building.py +++ b/tools/building.py @@ -308,7 +308,7 @@ def EndBuilding(target, program = None): IARProject('project.ewp', Projects) if GetOption('target') == 'vs': - VSProject('project.vcproj', Projects) + VSProject('project.vcproj', Projects, program) if GetOption('copy') and program != None: MakeCopy(program) diff --git a/tools/vs.py b/tools/vs.py index ce0787856c..1cb0f1a809 100644 --- a/tools/vs.py +++ b/tools/vs.py @@ -24,7 +24,20 @@ def VS_AddGroup(ProjectFiles, parent, name, files, project_path): File = SubElement(Filter, 'File') File.set('RelativePath', path.decode(fs_encoding)) -def VSProject(target, script): +def VS_AddHeadFilesGroup(program, elem, project_path): + building.source_ext = [] + building.source_ext = ["h"] + for item in program: + building.walk_children(item) + building.source_list.sort() + # print building.source_list + + for f in building.source_list: + path = _make_path_relative(project_path, f) + File = SubElement(elem, 'File') + File.set('RelativePath', path.decode(fs_encoding)) + +def VSProject(target, script, program): project_path = os.path.dirname(os.path.abspath(target)) tree = etree.parse('template.vcproj') @@ -35,7 +48,7 @@ def VSProject(target, script): ProjectFiles = [] - # add group + # add "*.c" files group for elem in tree.iter(tag='Filter'): if elem.attrib['Name'] == 'Source Files': #print elem.tag, elem.attrib @@ -43,6 +56,12 @@ def VSProject(target, script): for group in script: group_xml = VS_AddGroup(ProjectFiles, elem, group['name'], group['src'], project_path) + + # add "*.h" files group + for elem in tree.iter(tag='Filter'): + if elem.attrib['Name'] == 'Header Files': + break + VS_AddHeadFilesGroup(program, elem, project_path) # write head include path if building.Env.has_key('CPPPATH'):