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-07-12 15:49:17 +03:00
|
|
|
$baseIncludePath = Join-Path $baseDropPath -ChildPath Include
|
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-10-20 17:15:14 +03:00
|
|
|
# Include Files
|
2016-07-12 15:25:56 +03:00
|
|
|
$includePath = "Source\Common\Include"
|
2016-10-20 17:15:14 +03:00
|
|
|
$includePath20 = "Source\CNTKv2LibraryDll\API"
|
|
|
|
$includeFiles = New-Object string[] 3
|
|
|
|
$includeFiles[0] = Join-Path $includePath -ChildPath Eval.h
|
|
|
|
$includeFiles[1] = Join-Path $includePath20 -ChildPath CNTKLibrary.h
|
|
|
|
$includeFiles[2] = Join-Path $includePath20 -ChildPath CNTKLibraryInternals.h
|
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
|
|
|
|
Remove-Item $baseDropPath\cntk\*test*.exe
|
|
|
|
Remove-Item $baseDropPath\cntk\*.pdb
|
2016-07-12 15:25:56 +03:00
|
|
|
# Keep EvalDll.lib
|
2016-10-21 22:37:51 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\*.lib -Exclude EvalDll.lib, CNTKLibrary-2.0.lib
|
2016-02-24 16:20:11 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\*.exp
|
|
|
|
Remove-Item $baseDropPath\cntk\*.metagen
|
2016-07-07 15:15:03 +03:00
|
|
|
# Remove specific items
|
2016-10-22 15:51:13 +03:00
|
|
|
# Add Python artefacts to 2.0 Beta Drop
|
|
|
|
# If (Test-Path $baseDropPath\cntk\Python)
|
|
|
|
# {
|
|
|
|
# Remove-Item $baseDropPath\cntk\Python -Recurse
|
|
|
|
# }
|
2016-10-20 17:15:14 +03:00
|
|
|
# Add CNTKLibrary-2.0.dll to 2.0 Beta Drop
|
2016-10-20 16:04:17 +03:00
|
|
|
# If (Test-Path $baseDropPath\cntk\CNTKLibrary-2.0.dll)
|
|
|
|
# {
|
|
|
|
# Remove-Item $baseDropPath\cntk\CNTKLibrary-2.0.dll
|
|
|
|
# }
|
2016-09-05 18:04:12 +03:00
|
|
|
If (Test-Path $baseDropPath\cntk\CPPEvalClientTest.exe)
|
2016-07-07 15:15:03 +03:00
|
|
|
{
|
2016-09-05 18:04:12 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\CPPEvalClientTest.exe
|
2016-07-07 15:15:03 +03:00
|
|
|
}
|
2016-09-05 18:04:12 +03:00
|
|
|
If (Test-Path $baseDropPath\cntk\CSEvalClientTest.exe)
|
2016-07-07 15:15:03 +03:00
|
|
|
{
|
2016-09-05 18:04:12 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\CSEvalClientTest.exe
|
2016-07-07 15:15:03 +03:00
|
|
|
}
|
2016-09-05 18:04:12 +03:00
|
|
|
If (Test-Path $baseDropPath\cntk\CSEvalClientTest.exe.config)
|
2016-07-07 15:15:03 +03:00
|
|
|
{
|
2016-09-05 18:04:12 +03:00
|
|
|
Remove-Item $baseDropPath\cntk\CSEvalClientTest.exe.config
|
2016-07-07 15:15:03 +03:00
|
|
|
}
|
|
|
|
If (Test-Path $baseDropPath\cntk\CommandEval.exe)
|
|
|
|
{
|
|
|
|
Remove-Item $baseDropPath\cntk\CommandEval.exe
|
|
|
|
}
|
2016-02-24 16:20:11 +03:00
|
|
|
|
2016-07-12 15:42:55 +03:00
|
|
|
# Make Include folder
|
|
|
|
New-Item -Path $baseIncludePath -ItemType directory
|
|
|
|
|
2016-07-12 15:25:56 +03:00
|
|
|
# Copy Include
|
|
|
|
Write-Verbose "Copying Include files ..."
|
2016-10-20 17:15:14 +03:00
|
|
|
Foreach ($includeFile in $includeFiles)
|
|
|
|
{
|
|
|
|
Copy-Item $includeFile -Destination $baseIncludePath
|
|
|
|
}
|
2016-07-12 15:25:56 +03:00
|
|
|
|
2016-02-24 16:20:11 +03:00
|
|
|
# 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-10-20 18:01:04 +03:00
|
|
|
# Include CPPEvalV2Client examples in 2.0 Beta drop
|
|
|
|
# If (Test-Path $baseDropPath\Examples\Evaluation\CPPEvalV2Client)
|
|
|
|
# {
|
|
|
|
# Remove-Item $baseDropPath\Examples\Evaluation\CPPEvalV2Client -Recurse
|
|
|
|
# }
|
2016-02-24 16:20:11 +03:00
|
|
|
|
2016-07-07 15:15:03 +03:00
|
|
|
# Copy Scripts
|
|
|
|
Write-Verbose "Copying Scripts ..."
|
2016-07-07 15:45:28 +03:00
|
|
|
Copy-Item Scripts -Recurse -Destination $baseDropPath\Scripts
|
2016-07-07 15:15:03 +03:00
|
|
|
# Remove test related file(s) if exist(s)
|
|
|
|
If (Test-Path $baseDropPath\Scripts\pytest.ini)
|
|
|
|
{
|
|
|
|
Remove-Item $baseDropPath\Scripts\pytest.ini
|
|
|
|
}
|
|
|
|
|
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-07-07 15:15:03 +03:00
|
|
|
# Copying with Robocopy. Maximum 2 retries, 30 sec waiting time 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
|
|
|
|
}
|