diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-02-14 07:46:11 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-02-26 19:52:45 +0000 |
commit | cb6709ce5c48a31ba1170c71494c1a3869ffa5bb (patch) | |
tree | 8fdb8721a71cba868c2fbfe7c9fbc237d1f990a8 /coin/provisioning/common/windows/03-conan.ps1 | |
parent | 08c88de5c8d531fb4fee03a0c337dd93739d365a (diff) |
Unify Windows provisioning scripts & improve error handlingv5.11.0-beta1
While Coin should also see exit codes != 0 as error, we should
stick to one way of handling script errors. As Power Shell cmdlets
signal an error by throwing an exception we should do the same
(and that approach also works in Coin).
Additionally extracting 7zip files was unified across scripts by
using the existing helper function instead of reinventing the wheel
again and again.
A similar helper function was introduced for starting an external
application (and handling its errors).
Also echo and other "cmd" commands were replaced by their PowerShell
equivalents to have a unified approach across our Windows provisioning
scripts.
Change-Id: I70129ce38692f1396c33c13b33a2918485fa5271
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'coin/provisioning/common/windows/03-conan.ps1')
-rw-r--r-- | coin/provisioning/common/windows/03-conan.ps1 | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/coin/provisioning/common/windows/03-conan.ps1 b/coin/provisioning/common/windows/03-conan.ps1 index 2c9d9f8d..d900f5a7 100644 --- a/coin/provisioning/common/windows/03-conan.ps1 +++ b/coin/provisioning/common/windows/03-conan.ps1 @@ -2,18 +2,12 @@ $scriptsPath = "C:\Python27\Scripts" -& "$scriptsPath\pip.exe" install --upgrade conan==0.24.0 +Run-Executable "$scriptsPath\pip.exe" "install --upgrade conan==0.24.0" # Use Qt Project repository by default -& "$scriptsPath\conan.exe" remote add qtproject https://api.bintray.com/conan/qtproject/conan --insert +Run-Executable "$scriptsPath\conan.exe" "remote add qtproject https://api.bintray.com/conan/qtproject/conan --insert" -[Environment]::SetEnvironmentVariable("CI_CONAN_BUILDINFO_DIR", "C:\Utils\conanbuildinfos", "Machine") - -function Start-Process-Logged -{ - Write-Host "Start-Process", $args - Start-Process @args -} +Set-EnvironmentVariable "CI_CONAN_BUILDINFO_DIR" "C:\Utils\conanbuildinfos" function Run-Conan-Install { @@ -43,18 +37,20 @@ function Run-Conan-Install $outpwd = "C:\Utils\conanbuildinfos\$($BuildinfoDir)\$($_.BaseName)" New-Item $outpwd -Type directory -Force - $process = Start-Process-Logged ` - "$scriptsPath\conan.exe" ` - -WorkingDirectory $outpwd ` - -ArgumentList "install -f $conanfile --no-imports --verify $manifestsDir", ` - '-s', ('compiler="' + $Compiler + '"'), ` - "-s os=Windows -s arch=$Arch -s compiler.version=$CompilerVersion $extraArgs" ` - -NoNewWindow -Wait -Verbose ` - -PassThru # Return process object - - if ($process.ExitCode -ne 0) { - Write-Host "conan exited with code $($process.ExitCode)" - Exit(1) + for ($i = 1; $i -le 5; $i++) { + try { + Push-Location $outpwd + Run-Executable "$scriptsPath\conan.exe" "install -f $conanfile --no-imports --verify $manifestsDir", ` + '-s', ('compiler="' + $Compiler + '"'), ` + "-s os=Windows -s arch=$Arch -s compiler.version=$CompilerVersion $extraArgs" ` + break; + } catch { + if ($i -eq 5) { + throw "Could not install conan content" + } + } finally { + Pop-Location + } } Copy-Item -Path $conanfile -Destination "$outpwd\conanfile.txt" |