WinRT: added NuGet-package creation support to WinRT build script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
diff --git a/VisualC-WinRT/SDL2-WinRT.nuspec b/VisualC-WinRT/SDL2-WinRT.nuspec
new file mode 100644
index 0000000..effc07c
--- /dev/null
+++ b/VisualC-WinRT/SDL2-WinRT.nuspec
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>SDL2-WinRT</id>
+ <version>2.0.4-Unofficial</version>
+ <authors>Sam Lantinga</authors>
+ <owners>David Ludwig</owners>
+ <licenseUrl>http://libsdl.org/license.php</licenseUrl>
+ <projectUrl>http://libsdl.org</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>Unofficial pre-release of LibSDL2, built for WinRT platforms</description>
+ <copyright>Copyright 2015</copyright>
+ <tags>SDL2 SDL LibSDL OpenGL C C++ nativepackage</tags>
+ </metadata>
+ <files>
+ <file src="lib\**\*.dll" target="bin"/>
+ <file src="lib\**\*.lib" target="bin"/>
+ <file src="lib\**\*.pdb" target="bin"/>
+ <file src="..\include\**\*.*" target="include"/>
+ <file src="..\src\**\*.*" target="src"/>
+ <file src="SDL2-WinRT.targets" target="build\native"/>
+ </files>
+</package>
diff --git a/VisualC-WinRT/SDL2-WinRT.targets b/VisualC-WinRT/SDL2-WinRT.targets
new file mode 100644
index 0000000..f0b9e97
--- /dev/null
+++ b/VisualC-WinRT/SDL2-WinRT.targets
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <PropertyGroup>
+ <LibSDL2-DeviceType Condition="'$(TargetPlatformIdentifier)' == 'Windows' and '$(TargetPlatformVersion)' == '8.0'">WinRT80</LibSDL2-DeviceType>
+ <LibSDL2-DeviceType Condition="'$(TargetPlatformIdentifier)' == 'Windows' and '$(TargetPlatformVersion)' == '8.1'">WinRT81</LibSDL2-DeviceType>
+ <LibSDL2-DeviceType Condition="'$(TargetPlatformIdentifier)' == 'Windows Phone' and '$(TargetPlatformVersion)' == '8.0'">WinPhone80</LibSDL2-DeviceType>
+ <LibSDL2-DeviceType Condition="'$(TargetPlatformIdentifier)' == 'WindowsPhoneApp' and '$(TargetPlatformVersion)' == '8.1'">WinPhone81</LibSDL2-DeviceType>
+ <LibSDL2-DeviceType Condition="'$(TargetPlatformIdentifier)' == 'UAP'">UWP</LibSDL2-DeviceType>
+
+ <LibSDL2-BinPath>$(MSBuildThisFileDirectory)..\..\bin\$(LibSDL2-DeviceType)\$(Platform)</LibSDL2-BinPath>
+ </PropertyGroup>
+
+ <Target Name="LibSDL2-DeviceType-Check" BeforeTargets="ResolveAssemblyReferences">
+ <Error Condition="'$(LibSDL2-DeviceType)' == ''" Text="Unable to determine which version of Windows is being built-for" />
+ </Target>
+
+ <ItemDefinitionGroup>
+ <Link>
+ <AdditionalLibraryDirectories>$(LibSDL2-BinPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalDependencies>SDL2.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ </Link>
+ </ItemDefinitionGroup>
+
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ </ClCompile>
+ </ItemDefinitionGroup>
+
+ <ItemGroup Label="LibSDL2">
+ <PackagingOutputs Include="$(LibSDL2-BinPath)\SDL2.dll">
+ <OutputGroup>LibSDL2Binaries</OutputGroup>
+ <ProjectName>$(ProjectName)</ProjectName>
+ <TargetPath>%(Filename)%(Extension)</TargetPath>
+ </PackagingOutputs>
+ </ItemGroup>
+
+</Project>
diff --git a/VisualC-WinRT/SDL2main-WinRT-CoreWindow.nuspec b/VisualC-WinRT/SDL2main-WinRT-CoreWindow.nuspec
new file mode 100644
index 0000000..f199c21
--- /dev/null
+++ b/VisualC-WinRT/SDL2main-WinRT-CoreWindow.nuspec
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<package >
+ <metadata>
+ <id>SDL2main-WinRT-CoreWindow</id>
+ <version>2.0.4-Unofficial</version>
+ <authors>Sam Lantinga</authors>
+ <owners>David Ludwig</owners>
+ <licenseUrl>http://libsdl.org/license.php</licenseUrl>
+ <projectUrl>http://libsdl.org</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>WinMain() function for SDL2 + WinRT + CoreWindow (non-XAML) apps</description>
+ <copyright>Copyright 2015</copyright>
+ <tags>SDL2 SDL LibSDL OpenGL C C++ nativepackage</tags>
+ <dependencies>
+ <dependency id="SDL2-WinRT" version="2.0.4"/>
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="..\src\main\winrt\SDL_winrt_main_NonXAML.cpp" target="src\main\winrt"/>
+ <file src="SDL2main-WinRT-CoreWindow.targets" target="build\native"/>
+ </files>
+</package>
diff --git a/VisualC-WinRT/SDL2main-WinRT-CoreWindow.targets b/VisualC-WinRT/SDL2main-WinRT-CoreWindow.targets
new file mode 100644
index 0000000..53c5e5e
--- /dev/null
+++ b/VisualC-WinRT/SDL2main-WinRT-CoreWindow.targets
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+ <ItemGroup Label="LibSDL2">
+ <ClCompile Include="$(MSBuildThisFileDirectory)..\..\src\main\winrt\SDL_winrt_main_NonXAML.cpp">
+ <CompileAsWinRT>true</CompileAsWinRT>
+ </ClCompile>
+ </ItemGroup>
+
+</Project>
diff --git a/build-scripts/winrtbuild.ps1 b/build-scripts/winrtbuild.ps1
index d4e6052..a218b9d 100644
--- a/build-scripts/winrtbuild.ps1
+++ b/build-scripts/winrtbuild.ps1
@@ -38,6 +38,8 @@
# "ARM", or "x64" (for 64-bit x86).
#
+# Base version of SDL, used for packaging purposes
+$SDLVersion = "2.0.4"
# Gets the .bat file that sets up an MSBuild environment, given one of
# Visual Studio's, "PlatformToolset"s.
@@ -165,7 +167,7 @@ function Build-SDL-WinRT-Variant
$VSProjectName = Get-VS-ProjectName $VSProjectPath
# Where to place output binaries (.dll, .lib, and .pdb files):
- $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$PlatformToolset\$Platform"
+ $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
# Where to place intermediate build files:
$IntermediateDir = "$PSScriptRoot\..\VisualC-WinRT\obj\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
@@ -206,35 +208,87 @@ function Build-SDL-WinRT-Variant
#
# Build each variant, with corresponding .dll, .lib, and .pdb files:
#
-$DidAnyFail = $false
+$DidAnyDLLBuildFail = $false
+$DidAnyNugetBuildFail = $false
# Build for Windows Phone 8.0, via VC++ 2012:
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyDLLBuildFail = $true }
# Build for Windows Phone 8.1, via VC++ 2013:
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyDLLBuildFail = $true }
# Build for Windows 8.0 and Windows RT 8.0, via VC++ 2012:
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64")) { $DidAnyFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64")) { $DidAnyDLLBuildFail = $true }
# Build for Windows 8.1 and Windows RT 8.1, via VC++ 2013:
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64")) { $DidAnyFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64")) { $DidAnyDLLBuildFail = $true }
# Build for Windows 10, via VC++ 2015
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32")) { $DidAnyFail = $true }
-if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64")) { $DidAnyFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32")) { $DidAnyDLLBuildFail = $true }
+if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64")) { $DidAnyDLLBuildFail = $true }
+
+# Build NuGet packages, if possible
+if ($DidAnyDLLBuildFail -eq $true) {
+ Write-Warning -Message "Unable to build all variants. NuGet packages will not be built."
+ $DidAnyNugetBuildFail = $true
+} else {
+ $NugetPath = (Get-Command -CommandType Application nuget.exe | %{$_.Path}) 2> $null
+ if ("$NugetPath" -eq "") {
+ Write-Warning -Message "Unable to find nuget.exe. NuGet packages will not be built."
+ $DidAnyNugetBuildFail = $true
+ } else {
+ Write-Host -ForegroundColor Cyan "Building SDL2 NuGet packages..."
+ Write-Host -ForegroundColor Cyan "... via NuGet install: $NugetPath"
+ $NugetOutputDir = "$PSScriptRoot\..\VisualC-WinRT\lib\nuget"
+ Write-Host -ForegroundColor Cyan "... output directory: $NugetOutputDir"
+ $SDLHGRevision = $($(hg log -l 1 | select-string "changeset") -Replace "changeset:\W*(\d+).*",'$1') 2>$null
+ Write-Host -ForegroundColor Cyan "... HG Revision: $SDLHGRevision"
+
+ # Base options to nuget.exe
+ $NugetOptions = @("pack", "PACKAGE_NAME_WILL_GO_HERE", "-Output", "$NugetOutputDir")
+
+ # Try attaching hg revision to NuGet package:
+ $NugetOptions += "-Version"
+ if ("$SDLHGRevision" -eq "") {
+ Write-Warning -Message "Unable to find the Mercurial revision (maybe hg.exe can't be found?). NuGet packages will not have this attached to their name."
+ $NugetOptions += "$SDLVersion-Unofficial"
+ } else {
+ $NugetOptions += "$SDLVersion.$SDLHGRevision-Unofficial"
+ }
+
+ # Create NuGet output dir, if not yet created:
+ if ($(Test-Path "$NugetOutputDir") -eq $false) {
+ New-Item "$NugetOutputDir" -type directory
+ }
+
+ # Package SDL2:
+ $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2-WinRT.nuspec"
+ &"$NugetPath" $NugetOptions -Symbols
+ if ( ! $? ) { $DidAnyNugetBuildFail = $true }
+
+ # Package SDL2main:
+ $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2main-WinRT-CoreWindow.nuspec"
+ &"$NugetPath" $NugetOptions
+ if ( ! $? ) { $DidAnyNugetBuildFail = $true }
+ }
+}
+
# Let the script's caller know whether or not any errors occurred.
# Exit codes compatible with Buildbot are used (1 for error, 0 for success).
-if ($DidAnyFail -eq $true) {
+if ($DidAnyDLLBuildFail -eq $true) {
+ Write-Error -Message "Unable to build all known variants of SDL2 for WinRT"
exit 1
+} elseif ($DidAnyNugetBuildFail -eq $true) {
+ Write-Warning -Message "Unable to build NuGet packages"
+ exit 0 # Should NuGet package build failure lead to a non-failing result code instead?
} else {
exit 0
}