forked from microsoft/CNTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_binary_drop_windows.ps1
108 lines (89 loc) · 3.26 KB
/
make_binary_drop_windows.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# WARNING. This will run in Microsoft Internal Environment ONLY
# Generating CNTK Binary drops in Jenkins environment
# Command line parameters
# Verbose command line parameter (-verbose) is automatically added
# because of CmdletBinding
[CmdletBinding()]
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
)
# Set to Stop on Error
$ErrorActionPreference = 'Stop'
# 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}
# Set Verbose mode
If ($verbose)
{
$VerbosePreference = "continue"
}
Write-Verbose "Making binary drops..."
# If not a Release build quit
If ($buildConfig -ne "Release")
{
Write-Verbose "Not a release build. No binary drops generation"
Exit
}
# Set Paths
$basePath = "BinaryDrops\ToZip"
$baseDropPath = Join-Path $basePath -ChildPath cntk
$zipFile = "BinaryDrops\BinaryDrops.zip"
$buildPath = "x64\Release"
If ($targetConfig -eq "CPU")
{
$buildPath = "x64\Release_CpuOnly"
}
$sharePath = Join-Path $sharePath -ChildPath $targetConfig
# Make binary drop folder
New-Item -Path $baseDropPath -ItemType directory
# Copy build binaries
Write-Verbose "Copying build binaries ..."
Copy-Item $buildPath -Recurse -Destination $baseDropPath\cntk
# Clean unwanted items
If (Test-Path $baseDropPath\cntk\UnitTests)
{
Remove-Item $baseDropPath\cntk\UnitTests -Recurse
}
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
Write-Verbose "Copying Examples ..."
Copy-Item Examples -Recurse -Destination $baseDropPath\Examples
# Copy all items from the share
# For whatever reason Copy-Item in the line below does not work
# Copy-Item $sharePath"\*" -Recurse -Destination $baseDropPath
# Copying with Robocopy. Maximum 2 retries, 30 sec waiting times in between
Write-Verbose "Copying dependencies and other files from Remote Share ..."
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
}
Write-Verbose "Making ZIP and cleaning up..."
# Make ZIP file
$source = Join-Path $PWD.Path -ChildPath $basePath
$destination = Join-Path $PWD.Path -ChildPath $zipFile
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination)
# Remove ZIP sources
If (Test-Path $basePath)
{
Remove-Item $basePath -Recurse
}