build-scripts/winrtbuild.ps1
changeset 9940 f2d5ed0d9686
parent 9935 93fd2ca0ed98
child 9941 d0c6d95483d9
equal deleted inserted replaced
9939:6ccf11a01cb5 9940:f2d5ed0d9686
    36 #   * Platform: a Visual Studio platform name, which often maps to a CPU
    36 #   * Platform: a Visual Studio platform name, which often maps to a CPU
    37 #     CPU architecture.  Possible values may include: "Win32" (for 32-bit x86),
    37 #     CPU architecture.  Possible values may include: "Win32" (for 32-bit x86),
    38 #     "ARM", or "x64" (for 64-bit x86).
    38 #     "ARM", or "x64" (for 64-bit x86).
    39 #
    39 #
    40 
    40 
       
    41 # Base version of SDL, used for packaging purposes
       
    42 $SDLVersion = "2.0.4"
    41 
    43 
    42 # Gets the .bat file that sets up an MSBuild environment, given one of
    44 # Gets the .bat file that sets up an MSBuild environment, given one of
    43 # Visual Studio's, "PlatformToolset"s.
    45 # Visual Studio's, "PlatformToolset"s.
    44 function Get-MSBuild-Env-Launcher
    46 function Get-MSBuild-Env-Launcher
    45 {
    47 {
   163 
   165 
   164     # The internal name of the VS Project, used in some post-build steps:
   166     # The internal name of the VS Project, used in some post-build steps:
   165     $VSProjectName = Get-VS-ProjectName $VSProjectPath
   167     $VSProjectName = Get-VS-ProjectName $VSProjectPath
   166 
   168 
   167     # Where to place output binaries (.dll, .lib, and .pdb files):
   169     # Where to place output binaries (.dll, .lib, and .pdb files):
   168     $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$PlatformToolset\$Platform"
   170     $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
   169 
   171 
   170     # Where to place intermediate build files:
   172     # Where to place intermediate build files:
   171     $IntermediateDir = "$PSScriptRoot\..\VisualC-WinRT\obj\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
   173     $IntermediateDir = "$PSScriptRoot\..\VisualC-WinRT\obj\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
   172 
   174 
   173     #
   175     #
   204 
   206 
   205 
   207 
   206 #
   208 #
   207 # Build each variant, with corresponding .dll, .lib, and .pdb files:
   209 # Build each variant, with corresponding .dll, .lib, and .pdb files:
   208 #
   210 #
   209 $DidAnyFail = $false
   211 $DidAnyDLLBuildFail = $false
       
   212 $DidAnyNugetBuildFail = $false
   210 
   213 
   211 # Build for Windows Phone 8.0, via VC++ 2012:
   214 # Build for Windows Phone 8.0, via VC++ 2012:
   212 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM"))   { $DidAnyFail = $true }
   215 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM"))   { $DidAnyDLLBuildFail = $true }
   213 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyFail = $true }
   216 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyDLLBuildFail = $true }
   214 
   217 
   215 # Build for Windows Phone 8.1, via VC++ 2013:
   218 # Build for Windows Phone 8.1, via VC++ 2013:
   216 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM"))   { $DidAnyFail = $true }
   219 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM"))   { $DidAnyDLLBuildFail = $true }
   217 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyFail = $true }
   220 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyDLLBuildFail = $true }
   218 
   221 
   219 # Build for Windows 8.0 and Windows RT 8.0, via VC++ 2012:
   222 # Build for Windows 8.0 and Windows RT 8.0, via VC++ 2012:
   220 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM"))        { $DidAnyFail = $true }
   223 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM"))        { $DidAnyDLLBuildFail = $true }
   221 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32"))      { $DidAnyFail = $true }
   224 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32"))      { $DidAnyDLLBuildFail = $true }
   222 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64"))        { $DidAnyFail = $true }
   225 if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64"))        { $DidAnyDLLBuildFail = $true }
   223 
   226 
   224 # Build for Windows 8.1 and Windows RT 8.1, via VC++ 2013:
   227 # Build for Windows 8.1 and Windows RT 8.1, via VC++ 2013:
   225 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM"))        { $DidAnyFail = $true }
   228 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM"))        { $DidAnyDLLBuildFail = $true }
   226 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32"))      { $DidAnyFail = $true }
   229 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32"))      { $DidAnyDLLBuildFail = $true }
   227 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64"))        { $DidAnyFail = $true }
   230 if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64"))        { $DidAnyDLLBuildFail = $true }
   228 
   231 
   229 # Build for Windows 10, via VC++ 2015
   232 # Build for Windows 10, via VC++ 2015
   230 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM"))        { $DidAnyFail = $true }
   233 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM"))        { $DidAnyDLLBuildFail = $true }
   231 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32"))      { $DidAnyFail = $true }
   234 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32"))      { $DidAnyDLLBuildFail = $true }
   232 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64"))        { $DidAnyFail = $true }
   235 if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64"))        { $DidAnyDLLBuildFail = $true }
       
   236 
       
   237 # Build NuGet packages, if possible
       
   238 if ($DidAnyDLLBuildFail -eq $true) {
       
   239     Write-Warning -Message "Unable to build all variants.  NuGet packages will not be built."
       
   240     $DidAnyNugetBuildFail = $true
       
   241 } else {
       
   242     $NugetPath = (Get-Command -CommandType Application nuget.exe | %{$_.Path}) 2> $null
       
   243     if ("$NugetPath" -eq "") {
       
   244         Write-Warning -Message "Unable to find nuget.exe.  NuGet packages will not be built."
       
   245         $DidAnyNugetBuildFail = $true
       
   246     } else {
       
   247         Write-Host -ForegroundColor Cyan "Building SDL2 NuGet packages..."
       
   248         Write-Host -ForegroundColor Cyan "... via NuGet install: $NugetPath"
       
   249         $NugetOutputDir = "$PSScriptRoot\..\VisualC-WinRT\lib\nuget"
       
   250         Write-Host -ForegroundColor Cyan "...  output directory: $NugetOutputDir"
       
   251         $SDLHGRevision = $($(hg log -l 1 | select-string "changeset") -Replace "changeset:\W*(\d+).*",'$1') 2>$null
       
   252         Write-Host -ForegroundColor Cyan "...       HG Revision: $SDLHGRevision"
       
   253 
       
   254         # Base options to nuget.exe
       
   255         $NugetOptions = @("pack", "PACKAGE_NAME_WILL_GO_HERE", "-Output", "$NugetOutputDir")
       
   256 
       
   257         # Try attaching hg revision to NuGet package:
       
   258         $NugetOptions += "-Version"
       
   259         if ("$SDLHGRevision" -eq "") {
       
   260             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."
       
   261             $NugetOptions += "$SDLVersion-Unofficial"
       
   262         } else {
       
   263             $NugetOptions += "$SDLVersion.$SDLHGRevision-Unofficial"
       
   264         }
       
   265 
       
   266         # Create NuGet output dir, if not yet created:
       
   267         if ($(Test-Path "$NugetOutputDir") -eq $false) {
       
   268             New-Item "$NugetOutputDir" -type directory
       
   269         }
       
   270 
       
   271         # Package SDL2:
       
   272         $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2-WinRT.nuspec"
       
   273         &"$NugetPath" $NugetOptions -Symbols
       
   274         if ( ! $? ) { $DidAnyNugetBuildFail = $true }
       
   275 
       
   276         # Package SDL2main:
       
   277         $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2main-WinRT-CoreWindow.nuspec"
       
   278         &"$NugetPath" $NugetOptions
       
   279         if ( ! $? ) { $DidAnyNugetBuildFail = $true }
       
   280     }
       
   281 }
       
   282 
   233 
   283 
   234 # Let the script's caller know whether or not any errors occurred.
   284 # Let the script's caller know whether or not any errors occurred.
   235 # Exit codes compatible with Buildbot are used (1 for error, 0 for success).
   285 # Exit codes compatible with Buildbot are used (1 for error, 0 for success).
   236 if ($DidAnyFail -eq $true) {
   286 if ($DidAnyDLLBuildFail -eq $true) {
       
   287     Write-Error -Message "Unable to build all known variants of SDL2 for WinRT"
   237     exit 1
   288     exit 1
       
   289 } elseif ($DidAnyNugetBuildFail -eq $true) {
       
   290     Write-Warning -Message "Unable to build NuGet packages"
       
   291     exit 0  # Should NuGet package build failure lead to a non-failing result code instead?
   238 } else {
   292 } else {
   239     exit 0
   293     exit 0
   240 }
   294 }