@@ -44,39 +44,51 @@ function Invoke-PhpBuild {
4444
4545 New-Item " $buildDirectory " - ItemType " directory" - Force > $null 2>&1
4646
47- Set-Location " $buildDirectory "
47+ try {
48+ Set-Location " $buildDirectory "
4849
49- Add-BuildRequirements - PhpVersion $PhpVersion - Arch $Arch - FetchSrc:$fetchSrc
50+ Add-BuildRequirements - PhpVersion $PhpVersion - Arch $Arch - FetchSrc:$fetchSrc
5051
51- Copy-Item - Path $PSScriptRoot \..\config - Destination . - Recurse
52- $buildPath = " $buildDirectory \config\$ ( $VsConfig.vs ) \$Arch \php-$PhpVersion "
53- $sourcePath = " $buildDirectory \php-$PhpVersion -src"
54- if (-not ($fetchSrc )) {
55- $sourcePath = $currentDirectory
56- }
57- Move-Item $sourcePath $buildPath
58- Set-Location " $buildPath "
59- New-Item " ..\obj" - ItemType " directory" > $null 2>&1
60- Copy-Item " ..\config.$Ts .bat"
52+ $configDirectory = Join-Path $PSScriptRoot " ..\config\$ ( $VsConfig.vs ) \$Arch "
53+ $configBatch = Join-Path $configDirectory " config.$Ts .bat"
6154
62- if (-not [string ]::IsNullOrWhiteSpace($env: LIBS_BUILD_RUNS )) {
63- Add-PhpDeps - PhpVersion $PhpVersion - VsVersion $VsConfig.vs - Arch $Arch - Destination " $buildPath \..\deps"
64- $taskTemplate = Join-Path $PSScriptRoot " ..\runner\task-$Ts .bat"
65- } else {
66- $taskTemplate = Join-Path $PSScriptRoot " ..\runner\task-$Ts -with-deps.bat"
67- }
55+ if ($fetchSrc ) {
56+ Copy-Item - Path $PSScriptRoot \..\config - Destination . - Recurse
57+ $buildPath = " $buildDirectory \config\$ ( $VsConfig.vs ) \$Arch \php-$PhpVersion "
58+ $sourcePath = " $buildDirectory \php-$PhpVersion -src"
59+ Move-Item $sourcePath $buildPath
60+ } else {
61+ $buildPath = $currentDirectory
62+ }
63+
64+ $buildParent = Split-Path - Path $buildPath - Parent
65+ $artifactsDirectory = Join-Path $currentDirectory ' artifacts'
6866
69- $task = [System.IO.Path ]::GetFileName($taskTemplate )
70- Copy-Item - Path $taskTemplate - Destination $task - Force
67+ Set-Location " $buildPath "
68+ New-Item (Join-Path $buildParent ' obj' ) - ItemType " directory" - Force > $null 2>&1
69+ Copy-Item - Path $configBatch - Destination (Join-Path $buildPath " config.$Ts .bat" ) - Force
7170
72- Invoke-PhpSdkStarter - BuildDirectory $buildDirectory - VsConfig $VsConfig - Arch $Arch - Task $task
71+ if (-not [string ]::IsNullOrWhiteSpace($env: LIBS_BUILD_RUNS )) {
72+ Add-PhpDeps - PhpVersion $PhpVersion - VsVersion $VsConfig.vs - Arch $Arch - Destination (Join-Path $buildParent ' deps' )
73+ $taskTemplate = Join-Path $PSScriptRoot " ..\runner\task-$Ts .bat"
74+ } else {
75+ $taskTemplate = Join-Path $PSScriptRoot " ..\runner\task-$Ts -with-deps.bat"
76+ }
7377
74- $artifacts = if ($Ts -eq " ts" ) {" ..\obj\Release_TS\php-*.zip" } else {" ..\obj\Release\php-*.zip" }
75- New-Item " $currentDirectory \artifacts" - ItemType " directory" - Force > $null 2>&1
76- xcopy $artifacts " $currentDirectory \artifacts\*"
77- Move-Item " $buildDirectory \php-$PhpVersion -src.zip" " $currentDirectory \artifacts\"
78+ $task = [System.IO.Path ]::GetFileName($taskTemplate )
79+ Copy-Item - Path $taskTemplate - Destination $task - Force
7880
79- Set-Location " $currentDirectory "
81+ Invoke-PhpSdkStarter - BuildDirectory $buildDirectory - VsConfig $VsConfig - Arch $Arch - Task $task
82+
83+ $artifacts = if ($Ts -eq " ts" ) {" ..\obj\Release_TS\php-*.zip" } else {" ..\obj\Release\php-*.zip" }
84+ New-Item " $artifactsDirectory " - ItemType " directory" - Force > $null 2>&1
85+ xcopy $artifacts " $artifactsDirectory \*"
86+ if ($fetchSrc ) {
87+ Move-Item " $buildDirectory \php-$PhpVersion -src.zip" " $artifactsDirectory \"
88+ }
89+ } finally {
90+ Set-Location " $currentDirectory "
91+ }
8092 }
8193 end {
8294 }
0 commit comments