Explorar el Código

[Tools] Add group libs support in vs project.

Bernard Xiong hace 8 años
padre
commit
de3cf4195a
Se han modificado 1 ficheros con 24 adiciones y 2 borrados
  1. 24 2
      tools/vs.py

+ 24 - 2
tools/vs.py

@@ -33,7 +33,7 @@ from utils import _make_path_relative
 from utils import xml_indent
 from utils import xml_indent
 fs_encoding = sys.getfilesystemencoding()
 fs_encoding = sys.getfilesystemencoding()
 
 
-def VS_AddGroup(ProjectFiles, parent, name, files, project_path):
+def VS_AddGroup(ProjectFiles, parent, name, files, libs, project_path):
     Filter = SubElement(parent, 'Filter')
     Filter = SubElement(parent, 'Filter')
     Filter.set('Name', name) #set group name to group
     Filter.set('Name', name) #set group name to group
 
 
@@ -48,6 +48,16 @@ def VS_AddGroup(ProjectFiles, parent, name, files, project_path):
         File = SubElement(Filter, 'File')
         File = SubElement(Filter, 'File')
         File.set('RelativePath', path.decode(fs_encoding))
         File.set('RelativePath', path.decode(fs_encoding))
 
 
+    for lib in libs:
+        name = os.path.basename(lib)
+        path = os.path.dirname(lib)
+
+        path = _make_path_relative(project_path, path)
+        path = os.path.join(path, name)
+
+        File = SubElement(Filter, 'File')
+        File.set('RelativePath', path.decode(fs_encoding))
+
 def VS_AddHeadFilesGroup(program, elem, project_path):
 def VS_AddHeadFilesGroup(program, elem, project_path):
     building.source_ext = []
     building.source_ext = []
     building.source_ext = ["h"]
     building.source_ext = ["h"]
@@ -79,7 +89,19 @@ def VSProject(target, script, program):
             break
             break
 
 
     for group in script:
     for group in script:
-        group_xml = VS_AddGroup(ProjectFiles, elem, group['name'], group['src'], project_path)
+        libs = []
+        if group.has_key('LIBS') and group['LIBS']:
+            for item in group['LIBS']:
+                lib_path = ''
+                for path_item in group['LIBPATH']:
+                    full_path = os.path.join(path_item, item + '.lib')
+                    if os.path.isfile(full_path): # has this library
+                        lib_path = full_path
+
+                if lib_path != '':
+                    libs.append(lib_path)
+
+        group_xml = VS_AddGroup(ProjectFiles, elem, group['name'], group['src'], libs, project_path)
 
 
     # add "*.h" files group
     # add "*.h" files group
     for elem in tree.iter(tag='Filter'):
     for elem in tree.iter(tag='Filter'):