build-scripts/winrtbuild.ps1
changeset 9940 f2d5ed0d9686
parent 9935 93fd2ca0ed98
child 9941 d0c6d95483d9
     1.1 --- a/build-scripts/winrtbuild.ps1	Tue Dec 01 22:24:04 2015 +0100
     1.2 +++ b/build-scripts/winrtbuild.ps1	Tue Dec 01 22:07:24 2015 -0500
     1.3 @@ -38,6 +38,8 @@
     1.4  #     "ARM", or "x64" (for 64-bit x86).
     1.5  #
     1.6  
     1.7 +# Base version of SDL, used for packaging purposes
     1.8 +$SDLVersion = "2.0.4"
     1.9  
    1.10  # Gets the .bat file that sets up an MSBuild environment, given one of
    1.11  # Visual Studio's, "PlatformToolset"s.
    1.12 @@ -165,7 +167,7 @@
    1.13      $VSProjectName = Get-VS-ProjectName $VSProjectPath
    1.14  
    1.15      # Where to place output binaries (.dll, .lib, and .pdb files):
    1.16 -    $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$PlatformToolset\$Platform"
    1.17 +    $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
    1.18  
    1.19      # Where to place intermediate build files:
    1.20      $IntermediateDir = "$PSScriptRoot\..\VisualC-WinRT\obj\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
    1.21 @@ -206,35 +208,87 @@
    1.22  #
    1.23  # Build each variant, with corresponding .dll, .lib, and .pdb files:
    1.24  #
    1.25 -$DidAnyFail = $false
    1.26 +$DidAnyDLLBuildFail = $false
    1.27 +$DidAnyNugetBuildFail = $false
    1.28  
    1.29  # Build for Windows Phone 8.0, via VC++ 2012:
    1.30 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM"))   { $DidAnyFail = $true }
    1.31 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyFail = $true }
    1.32 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM"))   { $DidAnyDLLBuildFail = $true }
    1.33 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyDLLBuildFail = $true }
    1.34  
    1.35  # Build for Windows Phone 8.1, via VC++ 2013:
    1.36 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM"))   { $DidAnyFail = $true }
    1.37 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyFail = $true }
    1.38 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM"))   { $DidAnyDLLBuildFail = $true }
    1.39 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyDLLBuildFail = $true }
    1.40  
    1.41  # Build for Windows 8.0 and Windows RT 8.0, via VC++ 2012:
    1.42 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM"))        { $DidAnyFail = $true }
    1.43 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32"))      { $DidAnyFail = $true }
    1.44 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64"))        { $DidAnyFail = $true }
    1.45 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM"))        { $DidAnyDLLBuildFail = $true }
    1.46 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32"))      { $DidAnyDLLBuildFail = $true }
    1.47 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64"))        { $DidAnyDLLBuildFail = $true }
    1.48  
    1.49  # Build for Windows 8.1 and Windows RT 8.1, via VC++ 2013:
    1.50 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM"))        { $DidAnyFail = $true }
    1.51 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32"))      { $DidAnyFail = $true }
    1.52 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64"))        { $DidAnyFail = $true }
    1.53 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM"))        { $DidAnyDLLBuildFail = $true }
    1.54 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32"))      { $DidAnyDLLBuildFail = $true }
    1.55 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64"))        { $DidAnyDLLBuildFail = $true }
    1.56  
    1.57  # Build for Windows 10, via VC++ 2015
    1.58 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM"))        { $DidAnyFail = $true }
    1.59 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32"))      { $DidAnyFail = $true }
    1.60 -if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64"))        { $DidAnyFail = $true }
    1.61 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM"))        { $DidAnyDLLBuildFail = $true }
    1.62 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32"))      { $DidAnyDLLBuildFail = $true }
    1.63 +if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64"))        { $DidAnyDLLBuildFail = $true }
    1.64 +
    1.65 +# Build NuGet packages, if possible
    1.66 +if ($DidAnyDLLBuildFail -eq $true) {
    1.67 +    Write-Warning -Message "Unable to build all variants.  NuGet packages will not be built."
    1.68 +    $DidAnyNugetBuildFail = $true
    1.69 +} else {
    1.70 +    $NugetPath = (Get-Command -CommandType Application nuget.exe | %{$_.Path}) 2> $null
    1.71 +    if ("$NugetPath" -eq "") {
    1.72 +        Write-Warning -Message "Unable to find nuget.exe.  NuGet packages will not be built."
    1.73 +        $DidAnyNugetBuildFail = $true
    1.74 +    } else {
    1.75 +        Write-Host -ForegroundColor Cyan "Building SDL2 NuGet packages..."
    1.76 +        Write-Host -ForegroundColor Cyan "... via NuGet install: $NugetPath"
    1.77 +        $NugetOutputDir = "$PSScriptRoot\..\VisualC-WinRT\lib\nuget"
    1.78 +        Write-Host -ForegroundColor Cyan "...  output directory: $NugetOutputDir"
    1.79 +        $SDLHGRevision = $($(hg log -l 1 | select-string "changeset") -Replace "changeset:\W*(\d+).*",'$1') 2>$null
    1.80 +        Write-Host -ForegroundColor Cyan "...       HG Revision: $SDLHGRevision"
    1.81 +
    1.82 +        # Base options to nuget.exe
    1.83 +        $NugetOptions = @("pack", "PACKAGE_NAME_WILL_GO_HERE", "-Output", "$NugetOutputDir")
    1.84 +
    1.85 +        # Try attaching hg revision to NuGet package:
    1.86 +        $NugetOptions += "-Version"
    1.87 +        if ("$SDLHGRevision" -eq "") {
    1.88 +            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."
    1.89 +            $NugetOptions += "$SDLVersion-Unofficial"
    1.90 +        } else {
    1.91 +            $NugetOptions += "$SDLVersion.$SDLHGRevision-Unofficial"
    1.92 +        }
    1.93 +
    1.94 +        # Create NuGet output dir, if not yet created:
    1.95 +        if ($(Test-Path "$NugetOutputDir") -eq $false) {
    1.96 +            New-Item "$NugetOutputDir" -type directory
    1.97 +        }
    1.98 +
    1.99 +        # Package SDL2:
   1.100 +        $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2-WinRT.nuspec"
   1.101 +        &"$NugetPath" $NugetOptions -Symbols
   1.102 +        if ( ! $? ) { $DidAnyNugetBuildFail = $true }
   1.103 +
   1.104 +        # Package SDL2main:
   1.105 +        $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2main-WinRT-CoreWindow.nuspec"
   1.106 +        &"$NugetPath" $NugetOptions
   1.107 +        if ( ! $? ) { $DidAnyNugetBuildFail = $true }
   1.108 +    }
   1.109 +}
   1.110 +
   1.111  
   1.112  # Let the script's caller know whether or not any errors occurred.
   1.113  # Exit codes compatible with Buildbot are used (1 for error, 0 for success).
   1.114 -if ($DidAnyFail -eq $true) {
   1.115 +if ($DidAnyDLLBuildFail -eq $true) {
   1.116 +    Write-Error -Message "Unable to build all known variants of SDL2 for WinRT"
   1.117      exit 1
   1.118 +} elseif ($DidAnyNugetBuildFail -eq $true) {
   1.119 +    Write-Warning -Message "Unable to build NuGet packages"
   1.120 +    exit 0  # Should NuGet package build failure lead to a non-failing result code instead?
   1.121  } else {
   1.122      exit 0
   1.123  }