|
|
@@ -3,10 +3,11 @@
|
|
|
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
|
|
|
#-------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
-. "$PSScriptRoot\util.ps1"
|
|
|
+. $PSScriptRoot\util.ps1
|
|
|
|
|
|
function WriteCommonArguments() {
|
|
|
WriteMessage " Source Path: $srcpath"
|
|
|
+ WriteMessage " Build Root: $buildRoot"
|
|
|
WriteMessage " Object Path: $objpath"
|
|
|
WriteMessage "Binaries Path: $binpath"
|
|
|
}
|
|
|
@@ -14,7 +15,7 @@ function WriteCommonArguments() {
|
|
|
function GetVersionField($fieldname) {
|
|
|
$gitExe = GetGitPath
|
|
|
$query = "#define ${fieldname} (\d+)"
|
|
|
- $line = (iex "${gitExe} grep -P ""${query}"" :/")
|
|
|
+ $line = (Invoke-Expression "${gitExe} grep -P ""${query}"" :/")
|
|
|
$matches = $line | Select-String $query
|
|
|
if ($matches) {
|
|
|
return $matches[0].Matches.Groups[1].Value
|
|
|
@@ -25,7 +26,8 @@ function GetVersionField($fieldname) {
|
|
|
function GetBuildInfo($oauth, $commitHash) {
|
|
|
# Get the git remote path and construct the REST API URI
|
|
|
$gitExe = GetGitPath
|
|
|
- $remote = (iex "$gitExe remote -v" | ? { $_.contains("_git") })[0].split()[1].replace("_git", "_apis/git/repositories")
|
|
|
+ $remote = (Invoke-Expression "$gitExe remote -v" `
|
|
|
+ | Where-Object { $_.contains("_git") })[0].split()[1].replace("_git", "_apis/git/repositories")
|
|
|
$remote = $remote.replace("mshttps", "https")
|
|
|
|
|
|
# Get the pushId and push date time to use that for build number and build date time
|
|
|
@@ -46,7 +48,25 @@ function GetBuildPushId($info) {
|
|
|
return @($buildPushId, $buildPushIdPart1, $buildPushIdPart2, $buildPushIdString)
|
|
|
}
|
|
|
|
|
|
+function EnsureVariables($functionName, $arch, $flavor, $OuterScriptRoot) {
|
|
|
+ if (("$arch" -eq "") -or ("$flavor" -eq "") -or ("$OuterScriptRoot" -eq ""))
|
|
|
+ {
|
|
|
+ WriteErrorMessage @"
|
|
|
+
|
|
|
+ ${functionName}: Required variables not set:
|
|
|
+ `$arch = $arch
|
|
|
+ `$flavor = $flavor
|
|
|
+ `$OuterScriptRoot = $OuterScriptRoot
|
|
|
+
|
|
|
+"@
|
|
|
+
|
|
|
+ throw "Cannot continue: ${functionName}: required variables not set."
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function ConstructBuildName($arch, $flavor, $subtype) {
|
|
|
+ EnsureVariables "ConstructBuildName" $arch $flavor "(OuterScriptRoot not needed)"
|
|
|
+
|
|
|
if ($subtype -eq "codecoverage") {
|
|
|
# TODO eliminate tools' dependency on this particular formatting exception
|
|
|
# Normalize the $BuildName of even if the $BuildType is e.g. x64_test_codecoverage
|
|
|
@@ -58,22 +78,12 @@ function ConstructBuildName($arch, $flavor, $subtype) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-# Compute paths
|
|
|
-
|
|
|
-if (("$arch" -eq "") -or ("$flavor" -eq "") -or ("$OuterScriptRoot" -eq ""))
|
|
|
-{
|
|
|
- WriteErrorMessage @"
|
|
|
-
|
|
|
- Required variables not set before script was included:
|
|
|
- `$arch = $arch
|
|
|
- `$flavor = $flavor
|
|
|
- `$OuterScriptRoot = $OuterScriptRoot
|
|
|
-
|
|
|
-"@
|
|
|
-
|
|
|
- throw "Cannot continue - required variables not set."
|
|
|
+function ComputePaths($arch, $flavor, $subtype, $OuterScriptRoot, $srcpath = "", $buildRoot = "", $objpath = "", $binpath = "") {
|
|
|
+ EnsureVariables "ComputePaths" $arch $flavor $OuterScriptRoot
|
|
|
+ $buildName = ConstructBuildName $arch $flavor $subtype
|
|
|
+ $srcpath = UseValueOrDefault $srcpath "$Env:TF_BUILD_SOURCESDIRECTORY" (Resolve-Path "${OuterScriptRoot}\..\..")
|
|
|
+ $buildRoot = UseValueOrDefault $buildRoot "$Env:BinariesDirectory" "$Env:TF_BUILD_BINARIESDIRECTORY" (Join-Path $srcpath "Build\VcBuild")
|
|
|
+ $objpath = UseValueOrDefault $objpath "$Env:TF_BUILD_BUILDDIRECTORY" (Join-Path $buildRoot "obj\${buildName}")
|
|
|
+ $binpath = Join-Path $buildRoot "bin\${buildName}"
|
|
|
+ return @($srcpath, $buildRoot, $objpath, $binpath)
|
|
|
}
|
|
|
-
|
|
|
-$srcpath = UseValueOrDefault $srcpath "$env:TF_BUILD_SOURCESDIRECTORY" (Resolve-Path "$OuterScriptRoot\..\..")
|
|
|
-$objpath = UseValueOrDefault $objpath "$env:TF_BUILD_BUILDDIRECTORY" "${srcpath}\Build\VcBuild\obj\${arch}_${flavor}"
|
|
|
-$binpath = UseValueOrDefault $binpath "$env:TF_BUILD_BINARIESDIRECTORY" "${srcpath}\Build\VcBuild"
|