Merge pull request #40 from nicolasnoble/vsprojects

Factoring visual studio code into a buildgen plugin.
pull/196/head
Craig Tiller 10 years ago
commit e1175473fc
  1. 28
      templates/vsprojects/vs2013/grpc.sln.template
  2. 24
      templates/vsprojects/vs2013/vcxproj_defs.include
  3. 38
      tools/buildgen/plugins/generate_vsprojects.py

@ -11,31 +11,13 @@ MinimumVisualStudioVersion = 10.0.40219.1
## Visual Studio uses GUIDs for project types
## http://msdn.microsoft.com/en-us/library/hb23x61k%28v=vs.80%29.aspx
cpp_proj_type = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"
for lib in libs:
lib.is_library = True
for target in targets:
target.is_library = False
projects = []
projects.extend(libs)
projects.extend(targets)
projects = [project for project in projects if project.get('vs_project_guid', None)]
## Exclude C++ projects for now
projects = [project for project in projects if not project.language == 'c++']
for p in projects:
p.deps = p.get('deps',[])
project_dict = dict([(p.name, p) for p in projects])
%>\
% for project in projects:
% for project in vsprojects:
Project("${cpp_proj_type}") = "${project.name}", "${project.name}.vcxproj", "${project.vs_project_guid}"
% if project.deps:
% if project.get('deps', None):
ProjectSection(ProjectDependencies) = postProject
% for dep in project.deps:
${project_dict[dep].vs_project_guid} = ${project_dict[dep].vs_project_guid}
% for dep in project.get('deps', []):
${vsproject_dict[dep].vs_project_guid} = ${vsproject_dict[dep].vs_project_guid}
% endfor
EndProjectSection
% endif
@ -51,7 +33,7 @@ Global
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
% for project in projects:
% for project in vsprojects:
${project.vs_project_guid}.Debug|Win32.ActiveCfg = Debug|Win32
${project.vs_project_guid}.Debug|Win32.Build.0 = Debug|Win32
${project.vs_project_guid}.Release|Win32.ActiveCfg = Release|Win32

@ -2,27 +2,7 @@
<%def name="get_configuration_type(is_library)">${'StaticLibrary' if is_library else 'Application'}</%def>\
<%def name="get_subsystem(is_library)">${'Windows' if is_library else 'Console'}</%def>\
<%def name="gen_project(name, libs, targets)">\
<%
## TODO(jtattermusch): this code is c&p from the solution template
for lib in libs:
lib.is_library = True
for target in targets:
target.is_library = False
projects = []
projects.extend(libs)
projects.extend(targets)
projects = [project for project in projects if project.get('vs_project_guid', None)]
## Exclude C++ projects for now
projects = [project for project in projects if not project.get('c++', False)]
for p in projects:
p.deps = p.get('deps',[])
project_dict = dict([(p.name, p) for p in projects])
%>\
% for project in projects:
% for project in vsprojects:
% if project.name == name:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
@ -124,7 +104,7 @@ project_dict = dict([(p.name, p) for p in projects])
<ItemGroup>
% for dep in project.deps:
<ProjectReference Include="${dep}.vcxproj">
<Project>${project_dict[dep].vs_project_guid}</Project>
<Project>${vsproject_dict[dep].vs_project_guid}</Project>
</ProjectReference>
% endfor
</ItemGroup>

@ -0,0 +1,38 @@
"""Buildgen vsprojects plugin.
This parses the list of libraries, and generates globals "vsprojects"
and "vsproject_dict", to be used by the visual studio generators.
"""
def mako_plugin(dictionary):
"""The exported plugin code for generate_vsprojeccts
We want to help the work of the visual studio generators.
"""
libs = dictionary.get('libs', [])
targets = dictionary.get('targets', [])
for lib in libs:
lib['is_library'] = True
for target in targets:
target['is_library'] = False
projects = []
projects.extend(libs)
projects.extend(targets)
# Exclude projects without a visual project guid, such as the tests.
projects = [project for project in projects
if project.get('vs_project_guid', None)]
# Exclude C++ projects for now
projects = [project for project in projects
if not project['language'] == 'c++']
project_dict = dict([(p['name'], p) for p in projects])
dictionary['vsprojects'] = projects
dictionary['vsproject_dict'] = project_dict
Loading…
Cancel
Save