Skip to content

Commit

Permalink
big refactoring of visual studio projects, started using nuget
Browse files Browse the repository at this point in the history
dependencies.
  • Loading branch information
jtattermusch committed Apr 21, 2015
1 parent 2a191e3 commit 8ff00a3
Show file tree
Hide file tree
Showing 90 changed files with 556 additions and 6,354 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,24 @@ OUT_DIR=test_bin
CC=cl.exe
LINK=link.exe

INCLUDES=/I..\.. /I..\..\include /I..\..\third_party\zlib /I..\third_party /I..\..\third_party\openssl\inc32
REPO_ROOT=..
OPENSSL_INCLUDES = .\packages\openssl.1.0.2.1\build\native\include\v120\Win32\Debug\static
ZLIB_INCLUDES = .\packages\zlib.1.2.8.7\build\native\include
INCLUDES=/I$(REPO_ROOT) /I$(REPO_ROOT)\include /I$(OPENSSL_INCLUDES) /I$(ZLIB_INCLUDES)
DEFINES=/D WIN32 /D _LIB /D _USE_32BIT_TIME_T /D _UNICODE /D UNICODE /D _CRT_SECURE_NO_WARNINGS
CFLAGS=/c $(INCLUDES) /nologo /Z7 /W3 /WX- /sdl $(DEFINES) /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TC /analyze-
LFLAGS=/DEBUG /INCREMENTAL /NOLOGO /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /MACHINE:X86

OPENSSL_LIBS=..\..\third_party\openssl\out32\ssleay32.lib ..\..\third_party\openssl\out32\libeay32.lib
OPENSSL_LIBS=.\packages\openssl.1.0.2.1\build\native\lib\v120\Win32\Debug\static\ssleay32.lib .\packages\openssl.1.0.2.1\build\native\lib\v120\Win32\Debug\static\libeay32.lib
WINSOCK_LIBS=ws2_32.lib
ZLIB_LIBS=Debug\zlibwapi.lib
ZLIB_LIBS=.\packages\zlib.1.2.8.7\build\native\lib\v120\Win32\Debug\static\cdecl\zlib.lib
LIBS=$(OPENSSL_LIBS) $(WINSOCK_LIBS) $(ZLIB_LIBS)

gpr_test_util:
MSBuild.exe gpr_test_util.vcxproj /p:Configuration=Debug
MSBuild.exe gpr_test_util\gpr_test_util.vcxproj /p:Configuration=Debug

grpc_test_util:
MSBuild.exe grpc_test_util.vcxproj /p:Configuration=Debug
MSBuild.exe grpc_test_util\grpc_test_util.vcxproj /p:Configuration=Debug

$(OUT_DIR):
mkdir $(OUT_DIR)
Expand All @@ -87,7 +90,7 @@ ${target.name}.exe: grpc_test_util $(OUT_DIR)
echo Building ${target.name}
$(CC) $(CFLAGS) /Fo:$(OUT_DIR)\ \
%for source in target.src:
..\..\${to_windows_path(source)} \
$(REPO_ROOT)\${to_windows_path(source)} \
%endfor

$(LINK) $(LFLAGS) /OUT:"$(OUT_DIR)\${target.name}.exe" \
Expand Down
2 changes: 2 additions & 0 deletions templates/vsprojects/gpr/gpr.vcxproj.filters.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj.filters_defs.include" import="gen_filters"/>\
${gen_filters('gpr', libs, targets)}
2 changes: 2 additions & 0 deletions templates/vsprojects/gpr/gpr.vcxproj.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('gpr', libs, targets)}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('gpr_test_util', libs, targets)}
2 changes: 2 additions & 0 deletions templates/vsprojects/grpc++/grpc++.vcxproj.filters.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj.filters_defs.include" import="gen_filters"/>\
${gen_filters('grpc++', libs, targets)}
2 changes: 2 additions & 0 deletions templates/vsprojects/grpc++/grpc++.vcxproj.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('grpc++', libs, targets)}
42 changes: 42 additions & 0 deletions templates/vsprojects/grpc.sln.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Template for Visual Studio solution
## based on http://msdn.microsoft.com/en-us/library/bb165951(v=vs.90).aspx
## NOTE: tabs in this file are needed by Visual Studio to correctly interpret
## the file.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
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 project in vsprojects:
Project("${cpp_proj_type}") = "${project.name}", "${project.name}\${project.name}.vcxproj", "${project.vs_project_guid}"
% if project.get('deps', None):
ProjectSection(ProjectDependencies) = postProject
% for dep in project.get('deps', []):
${vsproject_dict[dep].vs_project_guid} = ${vsproject_dict[dep].vs_project_guid}
% endfor
EndProjectSection
% endif
EndProject
% endfor
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
% 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
${project.vs_project_guid}.Release|Win32.Build.0 = Release|Win32
% endfor
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions templates/vsprojects/grpc/grpc.vcxproj.filters.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj.filters_defs.include" import="gen_filters"/>\
${gen_filters('grpc', libs, targets)}
2 changes: 2 additions & 0 deletions templates/vsprojects/grpc/grpc.vcxproj.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('grpc', libs, targets, openssl_pkg_version='1.0.2.1', zlib_pkg_version='1.2.8.7')}
7 changes: 7 additions & 0 deletions templates/vsprojects/grpc/packages.config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="openssl" version="1.0.2.1" targetFramework="Native" />
<package id="openssl.redist" version="1.0.2.1" targetFramework="Native" />
<package id="zlib" version="1.2.8.7" targetFramework="Native" />
<package id="zlib.redist" version="1.2.8.7" targetFramework="Native" />
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('grpc_csharp_ext', libs, targets, configuration_type = 'DynamicLibrary', additional_props = ['winsock'], openssl_pkg_version='1.0.2.1', zlib_pkg_version='1.2.8.7')}
7 changes: 7 additions & 0 deletions templates/vsprojects/grpc_csharp_ext/packages.config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="openssl" version="1.0.2.1" targetFramework="Native" />
<package id="openssl.redist" version="1.0.2.1" targetFramework="Native" />
<package id="zlib" version="1.2.8.7" targetFramework="Native" />
<package id="zlib.redist" version="1.2.8.7" targetFramework="Native" />
</packages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('grpc_test_util', libs, targets)}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj.filters_defs.include" import="gen_filters"/>\
${gen_filters('grpc_unsecure', libs, targets)}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%namespace file="../vcxproj_defs.include" import="gen_project"/>\
${gen_project('grpc_unsecure', libs, targets, zlib_pkg_version='1.2.8.7')}
5 changes: 5 additions & 0 deletions templates/vsprojects/grpc_unsecure/packages.config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="zlib" version="1.2.8.7" targetFramework="Native" />
<package id="zlib.redist" version="1.2.8.7" targetFramework="Native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
def calc_to_filter(path):
return '\\'.join(path.split('/')[:-1])
%>\
<%def name="get_repo_root()">..\..</%def>\
<%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\
<%def name="to_filter(path)">${calc_to_filter(path)}</%def>\
<%def name="filter_to_guid(proj, filter)">${re.sub('(........)(....)(....)(....)', r'\1-\2-\3-\4-', hashlib.md5(''.join([filter, proj])).hexdigest())}</%def>\
Expand All @@ -16,7 +17,7 @@
% if project.get('src',[]):
<ItemGroup>
% for src_name in project.src:
<ClCompile Include="..\..\${to_windows_path(src_name)}">
<ClCompile Include="${get_repo_root()}\${to_windows_path(src_name)}">
<Filter>${to_filter(src_name)}</Filter>
</ClCompile>
% endfor
Expand All @@ -25,7 +26,7 @@
% if project.get('public_headers',[]):
<ItemGroup>
% for public_header in project.public_headers:
<ClInclude Include="..\..\${to_windows_path(public_header)}">
<ClInclude Include="${get_repo_root()}\${to_windows_path(public_header)}">
<Filter>${to_filter(public_header)}</Filter>
</ClInclude>
% endfor
Expand All @@ -34,7 +35,7 @@
% if project.get('headers',[]):
<ItemGroup>
% for header in project.headers:
<ClInclude Include="..\..\${to_windows_path(header)}">
<ClInclude Include="${get_repo_root()}\${to_windows_path(header)}">
<Filter>${to_filter(header)}</Filter>
</ClInclude>
% endfor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<%def name="get_repo_root()">..\..</%def>\
<%def name="to_windows_path(path)">${path.replace('/','\\')}</%def>\
<%def name="get_subsystem(is_library)">${'Windows' if is_library else 'Console'}</%def>\
<%def name="gen_project(name, libs, targets, configuration_type = 'StaticLibrary', project_guid = None, additional_props = [], depends_on_zlib = False)">\
<%def name="gen_project(name, libs, targets, configuration_type = 'StaticLibrary', project_guid = None, additional_props = [], openssl_pkg_version = None, zlib_pkg_version = None)">\
% 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">
% if openssl_pkg_version:
<Import Project="..\packages\openssl.${openssl_pkg_version}\build\native\openssl.props" Condition="Exists('..\packages\openssl.${openssl_pkg_version}\build\native\openssl.props')" />
% endif
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -19,36 +23,41 @@
<ProjectGuid>${project_guid if project_guid else project.vs_project_guid}</ProjectGuid>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration">
<PlatformToolset>v100</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration">
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration">
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>${configuration_type}</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>${configuration_type}</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<IntDir>$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="global.props" />
<Import Project="..\global.props" />
% for prop in additional_props:
<Import Project="${prop}.props" />
<Import Project="..\${prop}.props" />
% endfor
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="global.props" />
<Import Project="..\global.props" />
% for prop in additional_props:
<Import Project="${prop}.props" />
<Import Project="..\${prop}." />
% endfor
</ImportGroup>
<PropertyGroup Label="UserMacros" />
Expand Down Expand Up @@ -91,42 +100,66 @@
% if project.get('public_headers',[]):
<ItemGroup>
% for public_header in project.public_headers:
<ClInclude Include="..\..\${to_windows_path(public_header)}" />
<ClInclude Include="${get_repo_root()}\${to_windows_path(public_header)}" />
% endfor
</ItemGroup>
% endif
% if project.get('headers',[]):
<ItemGroup>
% for header in project.headers:
<ClInclude Include="..\..\${to_windows_path(header)}" />
<ClInclude Include="${get_repo_root()}\${to_windows_path(header)}" />
% endfor
</ItemGroup>
% endif
% if project.get('src',[]):
<ItemGroup>
% for src_name in project.src:
<ClCompile Include="..\..\${to_windows_path(src_name)}">
<ClCompile Include="${get_repo_root()}\${to_windows_path(src_name)}">
</ClCompile>
% endfor
</ItemGroup>
% endif
% if project.get('deps',[]):
<ItemGroup>
% for dep in project.deps:
<ProjectReference Include="${dep}.vcxproj">
<ProjectReference Include="..\${dep}\${dep}.vcxproj">
<Project>${vsproject_dict[dep].vs_project_guid}</Project>
</ProjectReference>
% endfor
% if depends_on_zlib:
<ProjectReference Include="third_party\zlibvc.vcxproj">
<Project>{8fd826f8-3739-44e6-8cc8-997122e53b8d}</Project>
</ProjectReference>
% endif
</ItemGroup>
% endif
%if zlib_pkg_version or openssl_pkg_version:
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
%endif
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
%if zlib_pkg_version:
<Import Project="..\packages\zlib.redist.${zlib_pkg_version}\build\native\zlib.redist.targets" Condition="Exists('..\packages\zlib.redist.${zlib_pkg_version}\build\native\zlib.redist.targets')" />
<Import Project="..\packages\zlib.${zlib_pkg_version}\build\native\zlib.targets" Condition="Exists('..\packages\zlib.${zlib_pkg_version}\build\native\zlib.targets')" />
%endif
% if openssl_pkg_version:
<Import Project="..\packages\openssl.redist.${openssl_pkg_version}\build\native\openssl.redist.targets" Condition="Exists('..\packages\openssl.redist.${openssl_pkg_version}\build\native\openssl.redist.targets')" />
<Import Project="..\packages\openssl.${openssl_pkg_version}\build\native\openssl.targets" Condition="Exists('..\packages\openssl.${openssl_pkg_version}\build\native\openssl.targets')" />
% endif
</ImportGroup>
%if zlib_pkg_version or openssl_pkg_version:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
%if zlib_pkg_version:
<Error Condition="!Exists('..\packages\zlib.redist.${zlib_pkg_version}\build\native\zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.redist.${zlib_pkg_version}\build\native\zlib.redist.targets'))" />
<Error Condition="!Exists('..\packages\zlib.${zlib_pkg_version}\build\native\zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\zlib.${zlib_pkg_version}\build\native\zlib.targets'))" />
%endif
% if openssl_pkg_version:
<Error Condition="!Exists('..\packages\openssl.redist.${openssl_pkg_version}\build\native\openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\openssl.redist.${openssl_pkg_version}\build\native\openssl.redist.targets'))" />
<Error Condition="!Exists('..\packages\openssl.${openssl_pkg_version}\build\native\openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\openssl.${openssl_pkg_version}\build\native\openssl.props'))" />
<Error Condition="!Exists('..\packages\openssl.${openssl_pkg_version}\build\native\openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\openssl.${openssl_pkg_version}\build\native\openssl.targets'))" />
%endif
</Target>
%endif
</Project>
% endif
% endfor
Expand Down
Loading

0 comments on commit 8ff00a3

Please sign in to comment.