summaryrefslogtreecommitdiff
path: root/cpp/bld-winsdk.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/bld-winsdk.ps1')
-rw-r--r--cpp/bld-winsdk.ps1229
1 files changed, 90 insertions, 139 deletions
diff --git a/cpp/bld-winsdk.ps1 b/cpp/bld-winsdk.ps1
index ae39742251..f3d126713e 100644
--- a/cpp/bld-winsdk.ps1
+++ b/cpp/bld-winsdk.ps1
@@ -18,32 +18,36 @@
#
# This script builds a WinSDK from a Qpid source checkout that
-# has been cleaned of any SVN artifacts.
+# has been cleaned of any SVN artifacts.
+# It builds a single SDK.zip file.
+# The environment for the build has been set up externally so
+# that 'devenv' runs the right version of Visual Studio (2008
+# or 2010) and the right architecture (x86 or x64), typically:
+# C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat or
+# C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvarsamd64.bat
#
# On entry:
-# 1. Args[0] holds the relative path to Qpid/trunk.
-# Directory ".\$args[0]" holds the "cpp" directory and
-# file QPID_VERSION.txt.
-# 2. Args[1] holds the x86 32-bit BOOST_ROOT. "c:\boost"
-# 3. Args[2] holds the x64 64-bit BOOST_ROOT. "c:\boost_x64"
-# 4. Args[3] holds the optional version number. "0.7.946106-99"
-# Defaults to contents of QPID_VERSION.txt
-# 5. Args[4] holds the optional Visual Studio version "VS2010"
+# 1. Args[0] holds the BOOST_ROOT directory. "c:\boost"
+# 2. Args[1] holds the version number. "2.0.0.1"
+# This arg/version number is used for output package naming purposes.
+# The version number embedded in the built executables and libraries
+# comes from qpid/cpp/src/CMakeWinVersions.cmake.
+# 3. Args[2] holds the Visual Studio version handle "VS2010"
# Defaults to VS2008.
-# 6. The current directory will receive x86 and x64 subdirs.
-# 7. The x86 an x64 dirs are where cmake will run.
-# 8. Two Boost installations, 32- and 64-bit, are available.
-# Boost was built with the same version of Visual Studio as this build.
-# 9. Boost directories must not be on the path.
-# 10. cmake, 7z, and devenv are already on the path.
-# 11. devenv is Visual Studio 2008 or 2010 as set by Args[4].
-# The PATH, INCLUDE, LIBPATH, and LIB environment vars are
-# set by calling vcvarsall.bat and then running "devenv /useenv".
+# 4. Args[3] holds the architecture handle "x86" or "x64".
+# Defaults to x86.
+# 5. This file exists in directory kitroot/qpid/cpp.
+# A new directory (kitroot/x86 or kitroot/x64) will be created.
+# 6. The x86 an x64 dirs are where cmake will run.
+# 7. Boost was built with the same version of Visual Studio
+# and the same architecture as this build.
+# 8. Boost directories must not be on the path.
+# 9. cmake, 7z, and devenv are already on the path.
#
-# This script creates separate zip kits for 32- and
+# This script creates a separate zip kit for 32-bit or
# for 64-bit variants. Example output files:
-# qpid-cpp-x86-VS2008-1.3.0.12.zip
-# qpid-cpp-x64-VS2008-1.3.0.12.zip
+# qpid-cpp-x86-VS2008-2.0.0.1.zip
+# qpid-cpp-x64-VS2008-2.0.0.1.zip
#
# Avoid "The OS handle's position is not what FileStream expected" errors
@@ -58,6 +62,7 @@ $field = $consoleHost.GetType().GetField("standardOutputWriter", $flagsF
$field.SetValue( $consoleHost, [Console]::Out)
$field2 = $consoleHost.GetType().GetField("standardErrorWriter", $flagsFld)
$field2.SetValue($consoleHost, [Console]::Out)
+
Set-PSDebug -Trace 1
Set-PSDebug -strict
@@ -71,6 +76,7 @@ $ErrorActionPreference='Stop'
[string] $global:sourceDirectory = Split-Path -parent $global:bldwinsdkDirectory
[string] $global:currentDirectory = Split-Path -parent $global:sourceDirectory
[string] $global:vsVersion = "VS2008"
+[string] $global:vsArch = "x86"
################################
@@ -92,51 +98,6 @@ function Unix2Dos
################################
#
-# SetVS2008
-# Set environment for VS2008
-#
-function SetVS2008($varsallArg)
-{
- $vs90comntools = (Get-ChildItem env:VS90COMNTOOLS).Value
- $batchFile = [System.IO.Path]::Combine($vs90comntools, "..\..\VC\vcvarsall.bat")
- $batchFile = Resolve-Path $batchFile
- GetBatchfilesEnvironment "$BatchFile" $varsallArg
-}
-
-
-################################
-#
-# SetVS2010
-# Set environment for VS2010
-#
-function SetVS2010($varsallArg)
-{
- $vs100comntools = (Get-ChildItem env:VS100COMNTOOLS).Value
- $batchFile = [System.IO.Path]::Combine($vs100comntools, "..\..\VC\vcvarsall.bat")
- $batchFile = Resolve-Path $batchFile
- GetBatchfilesEnvironment $BatchFile $varsallArg
-}
-
-################################
-#
-# GetBatchfilesEnvironment
-# Run a batch file specifically to change environment variables.
-# Then propagate those variables to this process.
-#
-function GetBatchfilesEnvironment($file, $varsallArg)
-{
- $exe = "cmd"
- [Array]$params = "/c", """$file""", $varsallArg, "&", "set";
- Write-Host "Select Visual Studio command line environment: $exe $params"
- & $exe $params | Foreach-Object {
- $p, $v = $_.split('=')
- Set-Item -path env:$p -value $v
- }
-}
-
-
-################################
-#
# BuildAPlatform
# Build a platform, x86 or x64.
# Compiles and packages Debug and RelWithDebInfo configurations.
@@ -185,7 +146,7 @@ function BuildAPlatform
if ($vsName -eq "VS2010") {
$msvcVer = "msvc10"
} else {
- Write-Host "illegal vsName parameter: $vsName"
+ Write-Host "illegal vsName parameter: $vsName Choose VS2008 or VS2010"
exit
}
}
@@ -203,26 +164,6 @@ function BuildAPlatform
#
Set-Location $platform_dir
- #
- # Set environment for this build
- #
- # set up the vcvarsall arg for a native/cross compiler command line
- if ($platform -eq "x86") {
- $varsallArg = "x86"
- } else {
- $os=Get-WMIObject win32_operatingsystem
- if ($os.OSArchitecture -eq "64-bit") {
- $varsallArg = "amd64"
- } else {
- $varsallArg = "x86_amd64"
- }
- }
- if ($vsName -eq "VS2008") {
- SetVS2008 $varsallArg
- } else {
- SetVS2010 $varsallArg
- }
-
$env:BOOST_ROOT = "$boostRoot"
$env:QPID_BUILD_ROOT = Get-Location
@@ -235,31 +176,31 @@ function BuildAPlatform
# Need to build doxygen api docs separately as nothing depends on them.
# Build for both x86 and x64 or cmake_install fails.
if ("x86" -eq $platform) {
- devenv /useenv qpid-cpp.sln /build "Release|Win32" /project docs-user-api
+ devenv qpid-cpp.sln /build "Release|Win32" /project docs-user-api
} else {
- devenv /useenv qpid-cpp.sln /build "Release|$platform" /project docs-user-api
+ devenv qpid-cpp.sln /build "Release|$platform" /project docs-user-api
}
# Build both Debug and Release builds so we can ship both sets of libs:
# Make RelWithDebInfo for debuggable release code.
# (Do Release after Debug so that the release executables overwrite the
# debug executables. Don't skip Debug as it creates some needed content.)
- devenv /useenv qpid-cpp.sln /build "$vsTargetDebug" /project INSTALL
- devenv /useenv qpid-cpp.sln /build "$vsTargetRelease" /project INSTALL
+ devenv qpid-cpp.sln /build "$vsTargetDebug" /project INSTALL
+ devenv qpid-cpp.sln /build "$vsTargetRelease" /project INSTALL
$bindingSln = Resolve-Path $qpid_cpp_src\bindings\qpid\dotnet\$msvcVer\org.apache.qpid.messaging.sln
# Build the .NET binding
if ("x86" -eq $platform) {
- devenv /useenv $bindingSln /build "Debug|Win32" /project org.apache.qpid.messaging
- devenv /useenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging.sessionreceiver
- devenv /useenv $bindingSln /build "RelWithDebInfo|Win32" /project org.apache.qpid.messaging
- devenv /useenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging.sessionreceiver
+ devenv $bindingSln /build "Debug|Win32" /project org.apache.qpid.messaging
+ devenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging.sessionreceiver
+ devenv $bindingSln /build "RelWithDebInfo|Win32" /project org.apache.qpid.messaging
+ devenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging.sessionreceiver
} else {
- devenv /useenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging
- devenv /useenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging.sessionreceiver
- devenv /useenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging
- devenv /useenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging.sessionreceiver
+ devenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging
+ devenv $bindingSln /build "Debug|$platform" /project org.apache.qpid.messaging.sessionreceiver
+ devenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging
+ devenv $bindingSln /build "RelWithDebInfo|$platform" /project org.apache.qpid.messaging.sessionreceiver
}
# Create install Debug and Release directories
@@ -310,6 +251,8 @@ function BuildAPlatform
'examples/qmf-console',
'examples/request-response',
'examples/tradedemo',
+ 'examples/*.sln',
+ 'examples/*.vcproj',
'include',
'plugins')
@@ -365,9 +308,9 @@ function BuildAPlatform
# Construct the examples' msvc-versioned solution/projects
New-Item $(Join-Path $install_dir "examples\msvc") -type Directory | Out-Null
- Push-Location $(Join-Path $install_dir "examples\msvc")
- cmake -G $cmakeGenerator $(Resolve-Path "$qpid_cpp_src/examples/winsdk-cmake")
- Pop-Location
+ $src = Resolve-Path "$global:sourceDirectory/cpp/examples/winsdk-cmake"
+ $dst = Join-Path $install_dir "examples\msvc"
+ Copy-Item "$src\*" -destination "$dst\"
# Zip the /bin PDB files
&'7z' a -mx9 ".\$install_dir\bin\Debug\symbols-debug.zip" ".\$install_dir\bin\DebugPDB\*.pdb"
@@ -393,29 +336,19 @@ function BuildAPlatform
# Main()
#
# Process the args
-#
-if ($args.length -lt 3) {
- Write-Host 'Usage: bld-winsdk.ps1 qpid_src_dir boost32_dir boost64_dir [buildVersion [Visual Studio Version]]'
- Write-Host ' bld-winsdk.ps1 qpid d:\boost-32 d:\boost-64 1.2.3.4 VS2008'
- exit
-}
-
-$qpid_src = $args[0]
-$boostRoot32 = $args[1]
-$boostRoot64 = $args[2]
-$ver = $args[3]
-if ($ver -eq $null) {
- $qpid_version_file="$qpid_src\QPID_VERSION.txt"
+#
- if ( !(Test-Path $qpid_version_file)) {
- Write-Host "Path doesn't seem to be a qpid src tree (no QPID_VERSION.txt)"
+if ($args.length -lt 3) {
+ Write-Host 'Usage: bld-winsdk.ps1 boost_root buildVersion [VisualStudioVersion [architecture]]'
+ Write-Host ' bld-winsdk.ps1 d:\boost-32 1.2.3.4 VS2008 x86'
exit
- }
- $ver=Get-Content $qpid_version_file
}
+$qpid_src = "qpid"
+$boostRoot = $args[0]
+$ver = $args[1]
$generator = ""
-$global:vsVersion = $args[4]
+$global:vsVersion = $args[2]
if ( !($global:vsVersion -eq $null) ) {
if ($global:vsVersion -eq "VS2008") {
$generator = "Visual Studio 9 2008"
@@ -432,13 +365,29 @@ if ( !($global:vsVersion -eq $null) ) {
$global:vsVersion = "VS2008"
$generator = "Visual Studio 9 2008"
}
+
+$global:vsArch = $args[3]
+if ( !($global:vsArch -eq $null) ) {
+ if ($global:vsArch -eq "x86") {
+ } else {
+ if ($global:vsArch -eq "x64") {
+ } else {
+ Write-Host "Architecture must be x86 or x64"
+ exit
+ }
+ }
+} else {
+ # default architecture
+ $global:vsArch = "x86"
+}
+
Write-Host "bld-winsdk.ps1"
Write-Host " qpid_src : $qpid_src"
-Write-Host " boostRoot32 : $boostRoot32"
-Write-Host " boostRoot64 : $boostRoot64"
+Write-Host " boostRoot : $boostRoot"
Write-Host " ver : $ver"
Write-Host " cmake gene : $generator"
Write-Host " vsVersion : $global:vsVersion"
+Write-Host " vsArch : $global:vsArch"
#
# Verify that Boost is not in PATH
@@ -458,20 +407,22 @@ $qpid_cpp_src="$qpid_src\cpp"
#
# buid
#
-BuildAPlatform $qpid_cpp_src `
- "x64" `
- "$generator Win64" `
- "Debug|x64" `
- "RelWithDebInfo|x64" `
- $boostRoot64 `
- $randomness `
- $global:vsVersion
-
-BuildAPlatform $qpid_cpp_src `
- "x86" `
- "$generator" `
- "Debug|Win32" `
- "RelWithDebInfo|Win32" `
- $boostRoot32 `
- $randomness `
- $global:vsVersion
+if ($global:vsArch -eq "x86") {
+ BuildAPlatform $qpid_cpp_src `
+ "x86" `
+ "$generator" `
+ "Debug|Win32" `
+ "RelWithDebInfo|Win32" `
+ $boostRoot `
+ $randomness `
+ $global:vsVersion
+} else {
+ BuildAPlatform $qpid_cpp_src `
+ "x64" `
+ "$generator Win64" `
+ "Debug|x64" `
+ "RelWithDebInfo|x64" `
+ $boostRoot `
+ $randomness `
+ $global:vsVersion
+} \ No newline at end of file