build-scripts/winrtbuild.ps1
author Ryan C. Gordon <icculus@icculus.org>
Sun, 28 Aug 2016 13:36:13 -0400
changeset 10286 3b884985835c
parent 9942 e82bfd942409
permissions -rw-r--r--
Merge audio capture work back into the mainline.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     1
#
9217
e15f7d963d98 WinRT: removed '-' from build script file names
David Ludwig <dludwig@pobox.com>
parents: 9216
diff changeset
     2
# winrtbuild.ps1 -- A Powershell script to build all SDL/WinRT variants,
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     3
#    across all WinRT platforms, in all of their supported, CPU architectures.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     4
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     5
# Initial version written by David Ludwig <dludwig@pobox.com>
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     6
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     7
# This script can be launched from Windows Explorer by double-clicking
9217
e15f7d963d98 WinRT: removed '-' from build script file names
David Ludwig <dludwig@pobox.com>
parents: 9216
diff changeset
     8
# on winrtbuild.bat
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
     9
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    10
# Output will be placed in the following subdirectories of the SDL source
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    11
# tree:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    12
#   * VisualC-WinRT\lib\  -- final .dll, .lib, and .pdb files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    13
#   * VisualC-WinRT\obj\  -- intermediate build files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    14
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    15
# Recommended Dependencies:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    16
#   * Windows 8.1 or higher
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    17
#   * Powershell 4.0 or higher (included as part of Windows 8.1)
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    18
#   * Visual C++ 2012, for building Windows 8.0 and Windows Phone 8.0 binaries.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    19
#   * Visual C++ 2013, for building Windows 8.1 and Windows Phone 8.1 binaries
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    20
#   * SDKs for Windows 8.0, Windows 8.1, Windows Phone 8.0, and
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    21
#     Windows Phone 8.1, as needed
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    22
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    23
# Commom parameters/variables may include, but aren't strictly limited to:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    24
#   * PlatformToolset: the name of one of Visual Studio's build platforms.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    25
#     Different PlatformToolsets output different binaries.  One
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    26
#     PlatformToolset exists for each WinRT platform.  Possible values
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    27
#     may include:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    28
#       - "v110": Visual Studio 2012 build tools, plus the Windows 8.0 SDK
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    29
#       - "v110_wp80": Visual Studio 2012 build tools, plus the Windows Phone 8.0 SDK
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    30
#       - "v120": Visual Studio 2013 build tools, plus the Windows 8.1 SDK
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    31
#       - "v120_wp81": Visual Studio 2013 build tools, plus the Windows Phone 8.1 SDK
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    32
#   * VSProjectPath: the full path to a Visual Studio or Visual C++ project file
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    33
#   * VSProjectName: the internal name of a Visual Studio or Visual C++ project
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    34
#     file.  Some of Visual Studio's own build tools use this name when
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    35
#     calculating paths for build-output.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    36
#   * Platform: a Visual Studio platform name, which often maps to a CPU
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    37
#     CPU architecture.  Possible values may include: "Win32" (for 32-bit x86),
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    38
#     "ARM", or "x64" (for 64-bit x86).
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    39
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    40
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
    41
# Base version of SDL, used for packaging purposes
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
    42
$SDLVersion = "2.0.4"
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    43
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    44
# Gets the .bat file that sets up an MSBuild environment, given one of
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    45
# Visual Studio's, "PlatformToolset"s.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    46
function Get-MSBuild-Env-Launcher
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    47
{
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    48
    param(
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    49
        [Parameter(Mandatory=$true,Position=1)][string]$PlatformToolset
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    50
    )
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    51
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    52
    if ($PlatformToolset -eq "v110") {      # Windows 8.0 (not Windows Phone), via VS 2012
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    53
        return "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    54
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    55
    if ($PlatformToolset -eq "v110_wp80") { # Windows Phone 8.0, via VS 2012
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    56
        return "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\WPSDK\WP80\vcvarsphoneall.bat"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    57
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    58
    if ($PlatformToolset -eq "v120") {      # Windows 8.1 (not Windows Phone), via VS 2013
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    59
        return "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    60
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    61
    if ($PlatformToolset -eq "v120_wp81") { # Windows Phone 8.1, via VS 2013
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    62
        return "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    63
    }
9935
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
    64
    if ($PlatformToolset -eq "v140") {      # Windows 10, via VS 2015
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
    65
        return "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
    66
    }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    67
    return ""
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    68
}
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    69
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    70
# Gets a string that identifies the build-variant of SDL/WinRT that is specific
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    71
# to a particular Visual Studio PlatformToolset.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    72
function Get-SDL-WinRT-Variant-Name
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    73
{
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    74
    param(
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    75
        [Parameter(Mandatory=$true,Position=1)][string]$PlatformToolset,
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    76
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    77
        # If true, append a string to this function's output, identifying the
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    78
        # build-variant's minimum-supported version of Visual Studio.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    79
        [switch]$IncludeVSSuffix = $false
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    80
    )
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    81
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    82
    if ($PlatformToolset -eq "v110") {      # Windows 8.0 (not Windows Phone), via VS 2012 project files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    83
        if ($IncludeVSSuffix) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    84
            return "WinRT80_VS2012"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    85
        } else {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    86
            return "WinRT80"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    87
        }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    88
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    89
    if ($PlatformToolset -eq "v110_wp80") { # Windows Phone 8.0, via VS 2012 project files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    90
        if ($IncludeVSSuffix) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    91
            return "WinPhone80_VS2012"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    92
        } else {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    93
            return "WinPhone80"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    94
        }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    95
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    96
    if ($PlatformToolset -eq "v120") {      # Windows 8.1 (not Windows Phone), via VS 2013 project files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    97
        if ($IncludeVSSuffix) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    98
            return "WinRT81_VS2013"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
    99
        } else {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   100
            return "WinRT81"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   101
        }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   102
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   103
    if ($PlatformToolset -eq "v120_wp81") { # Windows Phone 8.1, via VS 2013 project files
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   104
        if ($IncludeVSSuffix) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   105
            return "WinPhone81_VS2013"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   106
        } else {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   107
            return "WinPhone81"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   108
        }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   109
    }
9935
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   110
    if ($PlatformToolset -eq "v140") {      # Windows 10, via VS 2015 project files
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   111
        if ($IncludeVSSuffix) {
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   112
            return "UWP_VS2015"
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   113
        } else {
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   114
            return "UWP"
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   115
        }
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   116
    }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   117
    return ""
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   118
}
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   119
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   120
# Returns the internal name of a Visual Studio Project.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   121
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   122
# The internal name of a VS Project is encoded inside the project file
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   123
# itself, inside a set of <ProjectName></ProjectName> XML tags.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   124
function Get-VS-ProjectName
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   125
{
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   126
    param(
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   127
        [Parameter(Mandatory=$true,Position=1)]$VSProjectPath
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   128
    )
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   129
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   130
    # For now, just do a regex for the project name:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   131
    $matches = (Get-Content $VSProjectPath | Select-String -Pattern ".*<ProjectName>([^<]+)<.*").Matches
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   132
    foreach ($match in $matches) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   133
        if ($match.Groups.Count -ge 1) {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   134
            return $match.Groups[1].Value
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   135
        }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   136
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   137
    return $null
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   138
}
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   139
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   140
# Build a specific variant of SDL/WinRT
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   141
function Build-SDL-WinRT-Variant
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   142
{
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   143
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   144
    # Read in arguments:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   145
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   146
    param (
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   147
        # name of an SDL project file, minus extensions and
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   148
        # platform-identifying suffixes
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   149
        [Parameter(Mandatory=$true,Position=1)][string]$SDLProjectName,
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   150
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   151
        [Parameter(Mandatory=$true,Position=2)][string]$PlatformToolset,
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   152
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   153
        [Parameter(Mandatory=$true,Position=3)][string]$Platform
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   154
    )
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   155
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   156
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   157
    # Derive other properties from read-in arguments:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   158
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   159
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   160
    # The .bat file to setup a platform-appropriate MSBuild environment:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   161
    $BatchFileForMSBuildEnv = Get-MSBuild-Env-Launcher $PlatformToolset
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   162
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   163
    # The full path to the VS Project that'll be built:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   164
    $VSProjectPath = "$PSScriptRoot\..\VisualC-WinRT\$(Get-SDL-WinRT-Variant-Name $PlatformToolset -IncludeVSSuffix)\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset).vcxproj"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   165
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   166
    # The internal name of the VS Project, used in some post-build steps:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   167
    $VSProjectName = Get-VS-ProjectName $VSProjectPath
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   168
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   169
    # Where to place output binaries (.dll, .lib, and .pdb files):
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   170
    $OutDir = "$PSScriptRoot\..\VisualC-WinRT\lib\$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   171
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   172
    # Where to place intermediate build files:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   173
    $IntermediateDir = "$PSScriptRoot\..\VisualC-WinRT\obj\$SDLProjectName-$(Get-SDL-WinRT-Variant-Name $PlatformToolset)\$Platform"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   174
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   175
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   176
    # Build the VS Project:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   177
    #
9735
35d8f8976d32 WinRT: made sure build script generates Release-built binaries, by default
David Ludwig <dludwig@pobox.com>
parents: 9217
diff changeset
   178
    cmd.exe /c " ""$BatchFileForMSBuildEnv"" x86 & msbuild ""$VSProjectPath"" /p:Configuration=Release /p:Platform=$Platform /p:OutDir=""$OutDir\\"" /p:IntDir=""$IntermediateDir\\""" | Out-Host
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   179
    $BuildResult = $?
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   180
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   181
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   182
    # Move .dll files into place.  This fixes a problem whereby MSBuild may
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   183
    # put output files into a sub-directory of $OutDir, rather than $OutDir
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   184
    # itself.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   185
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   186
    if (Test-Path "$OutDir\$VSProjectName\") {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   187
        Move-Item -Force "$OutDir\$VSProjectName\*" "$OutDir"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   188
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   189
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   190
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   191
    # Clean up unneeded files in $OutDir:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   192
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   193
    if (Test-Path "$OutDir\$VSProjectName\") {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   194
        Remove-Item -Recurse "$OutDir\$VSProjectName"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   195
    }
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   196
    Remove-Item "$OutDir\*.exp"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   197
    Remove-Item "$OutDir\*.ilk"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   198
    Remove-Item "$OutDir\*.pri"
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   199
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   200
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   201
    # All done.  Indicate success, or failure, to the caller:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   202
    #
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   203
    #echo "RESULT: $BuildResult" | Out-Host
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   204
    return $BuildResult
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   205
}
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   206
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   207
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   208
#
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   209
# Build each variant, with corresponding .dll, .lib, and .pdb files:
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   210
#
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   211
$DidAnyDLLBuildFail = $false
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   212
$DidAnyNugetBuildFail = $false
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   213
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   214
# Build for Windows Phone 8.0, via VC++ 2012:
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   215
if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "ARM"))   { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   216
if ( ! (Build-SDL-WinRT-Variant "SDL" "v110_wp80" "Win32")) { $DidAnyDLLBuildFail = $true }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   217
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   218
# Build for Windows Phone 8.1, via VC++ 2013:
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   219
if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "ARM"))   { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   220
if ( ! (Build-SDL-WinRT-Variant "SDL" "v120_wp81" "Win32")) { $DidAnyDLLBuildFail = $true }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   221
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   222
# Build for Windows 8.0 and Windows RT 8.0, via VC++ 2012:
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   223
if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "ARM"))        { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   224
if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "Win32"))      { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   225
if ( ! (Build-SDL-WinRT-Variant "SDL" "v110" "x64"))        { $DidAnyDLLBuildFail = $true }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   226
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   227
# Build for Windows 8.1 and Windows RT 8.1, via VC++ 2013:
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   228
if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "ARM"))        { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   229
if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "Win32"))      { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   230
if ( ! (Build-SDL-WinRT-Variant "SDL" "v120" "x64"))        { $DidAnyDLLBuildFail = $true }
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   231
9935
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   232
# Build for Windows 10, via VC++ 2015
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   233
if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "ARM"))        { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   234
if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "Win32"))      { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   235
if ( ! (Build-SDL-WinRT-Variant "SDL" "v140" "x64"))        { $DidAnyDLLBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   236
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   237
# Build NuGet packages, if possible
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   238
if ($DidAnyDLLBuildFail -eq $true) {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   239
    Write-Warning -Message "Unable to build all variants.  NuGet packages will not be built."
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   240
    $DidAnyNugetBuildFail = $true
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   241
} else {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   242
    $NugetPath = (Get-Command -CommandType Application nuget.exe | %{$_.Path}) 2> $null
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   243
    if ("$NugetPath" -eq "") {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   244
        Write-Warning -Message "Unable to find nuget.exe.  NuGet packages will not be built."
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   245
        $DidAnyNugetBuildFail = $true
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   246
    } else {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   247
        Write-Host -ForegroundColor Cyan "Building SDL2 NuGet packages..."
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   248
        Write-Host -ForegroundColor Cyan "... via NuGet install: $NugetPath"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   249
        $NugetOutputDir = "$PSScriptRoot\..\VisualC-WinRT\lib\nuget"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   250
        Write-Host -ForegroundColor Cyan "...  output directory: $NugetOutputDir"
9941
d0c6d95483d9 WinRT: allowed NuGet packaging code to get hg revision regardless of cwd
David Ludwig <dludwig@pobox.com>
parents: 9940
diff changeset
   251
        $SDLHGRevision = $($(hg log -l 1 --repository "$PSScriptRoot\.." | select-string "changeset") -Replace "changeset:\W*(\d+).*",'$1') 2>$null
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   252
        Write-Host -ForegroundColor Cyan "...       HG Revision: $SDLHGRevision"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   253
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   254
        # Base options to nuget.exe
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   255
        $NugetOptions = @("pack", "PACKAGE_NAME_WILL_GO_HERE", "-Output", "$NugetOutputDir")
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   256
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   257
        # Try attaching hg revision to NuGet package:
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   258
        $NugetOptions += "-Version"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   259
        if ("$SDLHGRevision" -eq "") {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   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."
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   261
            $NugetOptions += "$SDLVersion-Unofficial"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   262
        } else {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   263
            $NugetOptions += "$SDLVersion.$SDLHGRevision-Unofficial"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   264
        }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   265
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   266
        # Create NuGet output dir, if not yet created:
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   267
        if ($(Test-Path "$NugetOutputDir") -eq $false) {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   268
            New-Item "$NugetOutputDir" -type directory
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   269
        }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   270
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   271
        # Package SDL2:
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   272
        $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2-WinRT.nuspec"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   273
        &"$NugetPath" $NugetOptions -Symbols
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   274
        if ( ! $? ) { $DidAnyNugetBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   275
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   276
        # Package SDL2main:
9942
e82bfd942409 WinRT: minor tweak to NuGet package naming
David Ludwig <dludwig@pobox.com>
parents: 9941
diff changeset
   277
        $NugetOptions[1] = "$PSScriptRoot\..\VisualC-WinRT\SDL2main-WinRT-NonXAML.nuspec"
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   278
        &"$NugetPath" $NugetOptions
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   279
        if ( ! $? ) { $DidAnyNugetBuildFail = $true }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   280
    }
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   281
}
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   282
9935
93fd2ca0ed98 WinRT: made WinRT build script create Win10/UWP .dll files
David Ludwig <dludwig@pobox.com>
parents: 9735
diff changeset
   283
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   284
# Let the script's caller know whether or not any errors occurred.
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   285
# Exit codes compatible with Buildbot are used (1 for error, 0 for success).
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   286
if ($DidAnyDLLBuildFail -eq $true) {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   287
    Write-Error -Message "Unable to build all known variants of SDL2 for WinRT"
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   288
    exit 1
9940
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   289
} elseif ($DidAnyNugetBuildFail -eq $true) {
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   290
    Write-Warning -Message "Unable to build NuGet packages"
f2d5ed0d9686 WinRT: added NuGet-package creation support to WinRT build script
David Ludwig <dludwig@pobox.com>
parents: 9935
diff changeset
   291
    exit 0  # Should NuGet package build failure lead to a non-failing result code instead?
9216
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   292
} else {
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   293
    exit 0
61cf772a4ed3 WinRT: added scripts to build Release copies of SDL for all WinRT variants
David Ludwig <dludwig@pobox.com>
parents:
diff changeset
   294
}