2016-02-24 16:20:11 +03:00
|
|
|
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
2016-02-24 20:03:39 +03:00
|
|
|
# WARNING. This will run in Microsoft Internal Environment ONLY
|
2016-02-25 13:20:25 +03:00
|
|
|
# Generating CNTK Binary drops in Jenkins environment
|
|
|
|
|
2016-03-01 20:31:54 +03:00
|
|
|
# Command line parameters
|
2016-03-03 15:46:11 +03:00
|
|
|
# Verbose command line parameter (-verbose) is automatically added
|
|
|
|
# because of CmdletBinding
|
2016-02-26 13:52:27 +03:00
|
|
|
[CmdletBinding()]
|
2016-03-01 20:31:54 +03:00
|
|
|
param
|
|
|
|
(
|
|
|
|
# Supposed to be taken from Jenkins BUILD_CONFIGURATION
|
|
|
|
[string]$buildConfig,
|
|
|
|
|
|
|
|
# Supposed to be taken from Jenkins TARGET_CONFIGURATION
|
|
|
|
[string]$targetConfig,
|
|
|
|
|
|
|
|
# File share path. Supposed to have sub-folders corresponding to $targetConfig
|
|
|
|
[string]$sharePath
|
|
|
|
)
|
2016-02-26 15:02:37 +03:00
|
|
|
|
|
|
|
# Set to Stop on Error
|
|
|
|
$ErrorActionPreference = 'Stop'
|
2016-02-26 13:52:27 +03:00
|
|
|
|
2016-03-01 20:31:54 +03:00
|
|
|
# Manual parameters check rather than using [Parameter(Mandatory=$True)]
|
|
|
|
# to avoid the risk of interactive prompts inside a Jenkins job
|
|
|
|
$usage = " parameter is missing. Usage example: make_binary_drop_windows.ps1 -buildConfig Release -targetConfig gpu -sharePath \\server\share"
|
|
|
|
If (-not $buildConfig) {Throw "buildConfig" + $usage}
|
|
|
|
If (-not $targetConfig) {Throw "targetConfig" + $usage}
|
|
|
|
If (-not $sharePath) {Throw "sharePath" + $usage}
|
|
|
|
|
2016-02-26 13:52:27 +03:00
|
|
|
# Set Verbose mode
|
2016-03-03 15:46:11 +03:00
|
|
|
If ($verbose)
|
2016-02-26 13:52:27 +03:00
|
|
|
{
|
|
|
|
$VerbosePreference = "continue"
|
|
|
|
}
|
|
|
|
|
|
|
|
Write-Verbose "Making binary drops..."
|
2016-02-24 16:20:11 +03:00
|
|
|
|
2016-02-24 20:03:39 +03:00
|
|
|
# If not a Release build quit
|
|
|
|
If ($buildConfig -ne "Release")
|
|
|
|
{
|
2016-02-26 13:52:27 +03:00
|
|
|
Write-Verbose "Not a release build. No binary drops generation"
|
2016-02-24 20:03:39 +03:00
|
|
|
Exit
|
|
|
|
}
|
2016-02-24 16:20:11 +03:00
|
|
|
|
2016-02-24 20:03:39 +03:00
|
|
|
# Set Paths
|
2016-02-24 16:20:11 +03:00
|
|
|
$basePath = "BinaryDrops\ToZip"
|
2016-02-26 13:52:27 +03:00
|
|
|
$baseDropPath = Join-Path $basePath -ChildPath cntk
|
2016-02-24 16:20:11 +03:00
|
|
|
$zipFile = "BinaryDrops\BinaryDrops.zip"
|
2016-02-26 13:52:27 +03:00
|
|
|
$buildPath = "x64\Release"
|
2016-02-24 20:03:39 +03:00
|
|
|
If ($targetConfig -eq "CPU")
|
|
|
|
{
|
|
|
|
$buildPath = "x64\Release_CpuOnly"
|
|
|
|
}
|
2016-03-01 20:31:54 +03:00
|
|
|
$sharePath = Join-Path $sharePath -ChildPath $targetConfig
|
2016-02-24 19:28:06 +03:00
|
|
|
|
2016-02-24 16:20:11 +03:00
|
|
|
|
2016-02-24 20:03:39 +03:00
|
|
|
# Make binary drop folder
|
2016-03-03 15:46:11 +03:00
|
|
|
New-Item -Path $baseDropPath -ItemType directory
|
2016-02-24 16:20:11 +03:00
|
|
|
|
|
|
|
# Copy build binaries
|
2016-02-26 13:52:27 +03:00
|
|
|
Write-Verbose "Copying build binaries ..."
|
2016-02-24 18:57:50 +03:00
|
|
|
Copy-Item $buildPath -Recurse -Destination $baseDropPath\cntk
|
2016-02-24 16:20:11 +03:00
|
|
|
|
|
|
|
# Clean unwanted items
|
2016-03-03 15:46:11 +03:00
|
|
|
If (Test-Path $baseDropPath\cntk\UnitTests)
|
|
|
|
{
|
|
|
|
Remove-Item $baseDropPath\cntk\UnitTests -Recurse
|
|
|
|
}
|
2016-02-24 16:20:11 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\*test*.exe
|
|
|
|
Remove-Item $baseDropPath\cntk\*.pdb
|
|
|
|
Remove-Item $baseDropPath\cntk\*.lib
|
|
|
|
Remove-Item $baseDropPath\cntk\*.exp
|
|
|
|
Remove-Item $baseDropPath\cntk\*.metagen
|
|
|
|
|
|
|
|
# Copy Examples
|
2016-02-26 13:52:27 +03:00
|
|
|
Write-Verbose "Copying Examples ..."
|
2016-02-24 16:20:11 +03:00
|
|
|
Copy-Item Examples -Recurse -Destination $baseDropPath\Examples
|
|
|
|
|
2016-02-24 20:03:39 +03:00
|
|
|
# Copy all items from the share
|
2016-02-25 13:20:25 +03:00
|
|
|
# For whatever reason Copy-Item in the line below does not work
|
2016-02-25 12:58:34 +03:00
|
|
|
# Copy-Item $sharePath"\*" -Recurse -Destination $baseDropPath
|
2016-03-03 15:46:11 +03:00
|
|
|
# Copying with Robocopy. Maximum 2 retries, 30 sec waiting times in between
|
2016-02-26 13:52:27 +03:00
|
|
|
Write-Verbose "Copying dependencies and other files from Remote Share ..."
|
2016-03-03 15:46:11 +03:00
|
|
|
robocopy $sharePath $baseDropPath /s /e /r:2 /w:30
|
|
|
|
# Check that Robocopy finished OK.
|
|
|
|
# Any exit code greater than 7 indicates error
|
|
|
|
# See http://ss64.com/nt/robocopy-exit.html
|
|
|
|
If ($LastExitCode -gt 7)
|
|
|
|
{
|
|
|
|
Throw "Copying from Remote Share failed. Robocopy exit code is " + $LastExitCode
|
|
|
|
}
|
2016-02-25 12:58:34 +03:00
|
|
|
|
2016-02-26 13:52:27 +03:00
|
|
|
Write-Verbose "Making ZIP and cleaning up..."
|
2016-02-24 16:20:11 +03:00
|
|
|
|
|
|
|
# Make ZIP file
|
2016-02-26 13:52:27 +03:00
|
|
|
$source = Join-Path $PWD.Path -ChildPath $basePath
|
|
|
|
$destination = Join-Path $PWD.Path -ChildPath $zipFile
|
2016-02-24 16:20:11 +03:00
|
|
|
Add-Type -assembly "system.io.compression.filesystem"
|
|
|
|
[io.compression.zipfile]::CreateFromDirectory($source, $destination)
|
|
|
|
|
|
|
|
# Remove ZIP sources
|
2016-03-03 15:46:11 +03:00
|
|
|
If (Test-Path $basePath)
|
|
|
|
{
|
|
|
|
Remove-Item $basePath -Recurse
|
|
|
|
}
|