forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_build.ps1
More file actions
162 lines (128 loc) · 5.01 KB
/
run_build.ps1
File metadata and controls
162 lines (128 loc) · 5.01 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------
# Use this script to run a build for the given BuildType (arch, flavor, subtype)
param (
[ValidateSet("x86", "x64", "arm", "arm64")]
[Parameter(Mandatory=$True)]
[string]$arch,
# We do not use ValidateSet here because this $flavor param is used to name the BuildConfiguration
# from the solution file. MsBuild will determine whether it is valid.
[Parameter(Mandatory=$True)]
[string]$flavor,
[ValidateSet("default", "codecoverage", "pogo")]
[string]$subtype = "default",
[Parameter(Mandatory=$True)]
[string]$solutionFile,
[switch]$clean,
[string]$buildRoot = "", # will be inferred if not provided
[string]$buildlogsSubdir = "buildlogs",
# assume NuGet is on the path, otherwise the caller must specify an explicit path
[string]$nugetExe = "NuGet.exe",
[string]$logFile = "",
#
# Skip flags
#
[switch]$skipPogo, # or set $Env:SKIP_POGO before invoking build
#
# POGO training parameters
#
[string[]]$scenarios = @(),
[string]$binpath, # will be inferred if not provided
[string]$binaryName = "ch.exe"
)
. $PSScriptRoot\pre_post_util.ps1
. $PSScriptRoot\locate_msbuild.ps1
# TODO (doilij) update all scripts that use pre_post_util.ps1 and rely on ComputeProjectPaths
$_, $buildRoot, $_, $binpath = `
ComputePaths `
-arch $arch -flavor $flavor -subtype $subtype -OuterScriptRoot $PSScriptRoot `
-buildRoot $buildRoot -binpath $binpath
$buildName = ConstructBuildName -arch $arch -flavor $flavor -subtype $subtype
$buildlogsPath = Join-Path $buildRoot $buildlogsSubdir
$logFile = UseValueOrDefault $logFile (Join-Path $buildRoot "logs\run_build.${buildName}.log")
# Clear the log file
if (($logFile -ne "") -and (Test-Path $logFile)) {
Remove-Item $logFile -Force
}
#
# NuGet restore
#
# To support both local builds where NuGet's location is known,
# and VSO builds where the location is not known and which use a NuGet restore task instead:
# Run `nuget restore` IFF $nugetExe exists.
if (Get-Command $nugetExe -ErrorAction SilentlyContinue) {
ExecuteCommand "& $nugetExe restore $solutionFile -NonInteractive"
}
#
# Setup
#
$msbuildExe = Locate-MSBuild
if (-not $msbuildExe) {
WriteErrorMessage "Could not find msbuild.exe -- exiting..."
exit 1
}
$skipPogo = $skipPogo -or (Test-Path Env:\SKIP_POGO)
# If $binpath is not set, then infer it. A missing path is okay because it will be created.
if (-not $binpath) {
$binpath = Join-Path $buildRoot "bin\${buildName}"
}
$defaultParams = "$solutionFile /nologo /m /nr:false /p:platform=`"${arch}`" /p:configuration=`"${flavor}`""
$loggingParams = @(
"/fl1 `"/flp1:logfile=${buildlogsPath}\build.${buildName}.log;verbosity=normal`"",
"/fl2 `"/flp2:logfile=${buildlogsPath}\build.${buildName}.err;errorsonly`"",
"/fl3 `"/flp3:logfile=${buildlogsPath}\build.${buildName}.wrn;warningsonly`"",
"/verbosity:normal"
) -join " "
$targets = ""
if ($clean) {
$targets += "`"/t:Clean,Rebuild`""
}
#
# Build
#
function Build($targets="", $extraParams) {
$buildCommand = "& `"$msbuildExe`" $targets $defaultParams $loggingParams $extraParams"
ExecuteCommand "$buildCommand"
if ($global:LastExitCode -ne 0) {
WriteErrorMessage "Failed msbuild command:`n$buildCommand`n"
WriteErrorMessage "Build failed. Exiting..."
exit 1
}
}
if ($subtype -eq "pogo") {
if ($scenarios.Length -eq 0) {
WriteMessage "No training scenarios selected for pogo build. Please specify training scenarios using the -scenarios parameter."
exit 1
}
Build -extraParams "`"/p:POGO_TYPE=PGI`"" -targets "$targets"
if (-not $skipPogo) {
$scenariosParamValue = $scenarios -join ','
$binary = Join-Path $binpath $binaryName
if (($binary -ne "") -and (Test-Path $binary)) {
$pogoTrainingCommand = "& `"${PSScriptRoot}\pgo\pogo_training.ps1`" -arch $arch -flavor $flavor -subtype $subtype -binary $binary -scenarios $scenariosParamValue"
ExecuteCommand "$pogoTrainingCommand"
} else {
WriteMessage "Binary not found at `"$binary`". Exiting..."
exit 1
}
Build -extraParams "`"/p:POGO_TYPE=PGO`""
}
} else {
$subtypeParams = ""
if ($subtype -eq "codecoverage") {
$subtypeParams = "/p:ENABLE_CODECOVERAGE=true"
}
Build -extraParams $subTypeParams -targets $targets
}
#
# Clean up
#
if (("$binpath" -ne "") -and (Test-Path $binpath)) {
# remove *.pgc, *.pgd, and pgort*
Get-ChildItem -Recurse -Path $binpath "*" `
| Where-Object { $_.Name -match "(.*\.pg[cd]|pgort.*)" } `
| ForEach-Object { Remove-Item -Force $_.FullName }
}
exit $global:lastexitcode