Skip to content

Commit

Permalink
scripts: Switch to manual NuGet package with both CRT linkages
Browse files Browse the repository at this point in the history
We'd like to build pugixml with both static & dynamic CRT and put it
all in one NuGet package.

CoApp sort of allows us to do this via dynamic/static pivots, but it
does not let us customize the names of the pivots and additionally has
some bugs with the project setup. Their project modifications are also
much more complicated - really, at this point we should do this
ourselves.

Create a simple native NuGet package with Linkage setting that picks the
right library, and package all libraries appropriately. Note that we use
the unified path syntax to make it simple to just get the right .lib
file from the toolset/platform/configuration/linkage combo.
  • Loading branch information
zeux committed Jun 21, 2017
1 parent 208e2cf commit a7c4070
Show file tree
Hide file tree
Showing 7 changed files with 476 additions and 49 deletions.
46 changes: 0 additions & 46 deletions scripts/nuget.autopkg

This file was deleted.

15 changes: 15 additions & 0 deletions scripts/nuget/build/native/pugixml-propertiesui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework">
<Rule Name="ReferencedPackages05032e35-86af-4ab2-a3dc-d3e348583165" PageTemplate="tool" DisplayName="Referenced Packages" SwitchPrefix="/" Order="1">
<Rule.Categories>
<Category Name="pugixml" DisplayName="pugixml" />
</Rule.Categories>
<Rule.DataSource>
<DataSource Persistence="ProjectFile" ItemType="" />
</Rule.DataSource>
<EnumProperty Name="Linkage-pugixml" DisplayName="Linkage" Description="Which version of the .lib file to link to this library" Category="pugixml">
<EnumValue Name="dynamic" DisplayName="dynamic" />
<EnumValue Name="static" DisplayName="static" />
</EnumProperty>
</Rule>
</ProjectSchemaDefinitions>
27 changes: 27 additions & 0 deletions scripts/nuget/build/native/pugixml.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Default initializers for properties">
<Linkage-pugixml Condition="'$(Linkage-pugixml)' == ''">dynamic</Linkage-pugixml>
</PropertyGroup>
<ItemGroup>
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\pugixml-propertiesui.xml" />
</ItemGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(Configuration.ToLower().IndexOf('debug')) != -1">
<Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\Debug\pugixml.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="$(Configuration.ToLower().IndexOf('debug')) == -1">
<Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)lib/$(Platform)\$(PlatformToolset.Split('_')[0])\$(Linkage-pugixml)\Release\pugixml.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>
20 changes: 20 additions & 0 deletions scripts/nuget/pugixml.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
<metadata>
<id>pugixml</id>
<version>1.8.0-appveyor</version>
<title>pugixml</title>
<authors>Arseny Kapoulkine</authors>
<owners>Arseny Kapoulkine</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl>http://pugixml.org/license.html</licenseUrl>
<projectUrl>http://pugixml.org/</projectUrl>
<iconUrl>https://github.com/zeux/pugixml/logo.svg</iconUrl>
<description>pugixml is a C++ XML processing library, which consists of a DOM-like interface with rich traversal/modification capabilities, an extremely fast XML parser which constructs the DOM tree from an XML file/buffer, and an XPath 1.0 implementation for complex data-driven tree queries. Full Unicode support is also available, with Unicode interface variants and conversions between different Unicode encodings (which happen automatically during parsing/saving).
pugixml is used by a lot of projects, both open-source and proprietary, for performance and easy-to-use interface.</description>
<summary>Light-weight, simple and fast XML parser for C++ with XPath support</summary>
<releaseNotes>http://pugixml.org/docs/manual.html#changes</releaseNotes>
<copyright>Copyright (c) 2006-2017 Arseny Kapoulkine</copyright>
<tags>native nativepackage</tags>
</metadata>
</package>
65 changes: 62 additions & 3 deletions scripts/nuget_build.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,84 @@
function Run-Command
function Run-Command([string]$cmd)
{
Invoke-Expression $args[0]
Invoke-Expression $cmd
if ($LastExitCode) { exit $LastExitCode }
}

function Force-Copy([string]$from, [string]$to)
{
Write-Host $from "=>" $to
New-Item -Force $to | Out-Null
Copy-Item -Force $from $to
if (! $?) { exit 1 }
}

Push-Location
$scriptdir = Split-Path $MyInvocation.MyCommand.Path
cd $scriptdir

Run-Command "msbuild pugixml_vs2013.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"

Run-Command "msbuild pugixml_vs2013_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2013_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"

Run-Command "msbuild pugixml_vs2015.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"

Run-Command "msbuild pugixml_vs2015_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2015_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"

Run-Command "msbuild pugixml_vs2017.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"
Write-NuGetPackage nuget.autopkg

Run-Command "msbuild pugixml_vs2017_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x86 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017_static.vcxproj /t:Rebuild /p:Configuration=Debug /p:Platform=x64 /v:minimal /nologo"
Run-Command "msbuild pugixml_vs2017_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /v:minimal /nologo"

Force-Copy "../src/pugiconfig.hpp" "nuget/build/native/include/pugiconfig.hpp"
Force-Copy "../src/pugixml.hpp" "nuget/build/native/include/pugixml.hpp"

Force-Copy "vs2013/x32/pugixml.lib" "nuget/build/native/lib/Win32/v120/dynamic/Release/pugixml.lib"
Force-Copy "vs2013/x32/pugixmld.lib" "nuget/build/native/lib/Win32/v120/dynamic/Debug/pugixml.lib"
Force-Copy "vs2013/x64/pugixml.lib" "nuget/build/native/lib/x64/v120/dynamic/Release/pugixml.lib"
Force-Copy "vs2013/x64/pugixmld.lib" "nuget/build/native/lib/x64/v120/dynamic/Debug/pugixml.lib"

Force-Copy "vs2013/x32/pugixmls.lib" "nuget/build/native/lib/Win32/v120/static/Release/pugixml.lib"
Force-Copy "vs2013/x32/pugixmlsd.lib" "nuget/build/native/lib/Win32/v120/static/Debug/pugixml.lib"
Force-Copy "vs2013/x64/pugixmls.lib" "nuget/build/native/lib/x64/v120/static/Release/pugixml.lib"
Force-Copy "vs2013/x64/pugixmlsd.lib" "nuget/build/native/lib/x64/v120/static/Debug/pugixml.lib"

Force-Copy "vs2015/Win32_Release/pugixml.lib" "nuget/build/native/lib/Win32/v140/dynamic/Release/pugixml.lib"
Force-Copy "vs2015/Win32_Debug/pugixml.lib" "nuget/build/native/lib/Win32/v140/dynamic/Debug/pugixml.lib"
Force-Copy "vs2015/x64_Release/pugixml.lib" "nuget/build/native/lib/x64/v140/dynamic/Release/pugixml.lib"
Force-Copy "vs2015/x64_Debug/pugixml.lib" "nuget/build/native/lib/x64/v140/dynamic/Debug/pugixml.lib"

Force-Copy "vs2015/Win32_ReleaseStatic/pugixml.lib" "nuget/build/native/lib/Win32/v140/static/Release/pugixml.lib"
Force-Copy "vs2015/Win32_DebugStatic/pugixml.lib" "nuget/build/native/lib/Win32/v140/static/Debug/pugixml.lib"
Force-Copy "vs2015/x64_ReleaseStatic/pugixml.lib" "nuget/build/native/lib/x64/v140/static/Release/pugixml.lib"
Force-Copy "vs2015/x64_DebugStatic/pugixml.lib" "nuget/build/native/lib/x64/v140/static/Debug/pugixml.lib"

Force-Copy "vs2017/Win32_Release/pugixml.lib" "nuget/build/native/lib/Win32/v141/dynamic/Release/pugixml.lib"
Force-Copy "vs2017/Win32_Debug/pugixml.lib" "nuget/build/native/lib/Win32/v141/dynamic/Debug/pugixml.lib"
Force-Copy "vs2017/x64_Release/pugixml.lib" "nuget/build/native/lib/x64/v141/dynamic/Release/pugixml.lib"
Force-Copy "vs2017/x64_Debug/pugixml.lib" "nuget/build/native/lib/x64/v141/dynamic/Debug/pugixml.lib"

Force-Copy "vs2017/Win32_ReleaseStatic/pugixml.lib" "nuget/build/native/lib/Win32/v141/static/Release/pugixml.lib"
Force-Copy "vs2017/Win32_DebugStatic/pugixml.lib" "nuget/build/native/lib/Win32/v141/static/Debug/pugixml.lib"
Force-Copy "vs2017/x64_ReleaseStatic/pugixml.lib" "nuget/build/native/lib/x64/v141/static/Release/pugixml.lib"
Force-Copy "vs2017/x64_DebugStatic/pugixml.lib" "nuget/build/native/lib/x64/v141/static/Debug/pugixml.lib"

Run-Command "nuget pack nuget"

Pop-Location
Loading

0 comments on commit a7c4070

Please sign in to comment.