diff --git a/invoke-build.ps1 b/invoke-build.ps1 index 66a23e76..8727c9e7 100644 --- a/invoke-build.ps1 +++ b/invoke-build.ps1 @@ -12,6 +12,7 @@ param( $global:showDebug = $ShowDebug Import-Module "$PSScriptRoot/scripts/ps-modules/Build" -Force -DisableNameChecking Run-WriteParamsStep -packageAndFeatures $PackageAndFeatures -scriptArgs $PSBoundParameters +Run-CleanupStep Run-SetupVcPkgStep $VcPkgHash Run-PreBuildStep $PackageAndFeatures Run-InstallPackageStep -packageAndFeatures $PackageAndFeatures -linkType $LinkType -buildType $BuildType diff --git a/scripts/ps-modules/Build/Build.psm1 b/scripts/ps-modules/Build/Build.psm1 index 031fa235..90783e9f 100644 --- a/scripts/ps-modules/Build/Build.psm1 +++ b/scripts/ps-modules/Build/Build.psm1 @@ -160,6 +160,32 @@ function Run-WriteParamsStep { Write-Message (Get-PSObjectAsFormattedList -Object $scriptArgs) } +function Run-CleanupStep { + Write-Banner -Level 3 -Title "Cleaning files" + + Write-Message "Removing vcpkg cache..." + if ( (Get-IsOnWindowsOS) ) { + $vcpkgCacheDir = "$env:LocalAppData/vcpkg/archives" + } elseif ( (Get-IsOnMacOS) ) { + $vcpkgCacheDir = "$HOME/.cache/vcpkg/archives" + } + if (Test-Path -Path $vcpkgCacheDir -PathType Container) { + Remove-Item -Path $vcpkgCacheDir -Recurse -Force + } + + Write-Message "Removing vcpkg dir..." + $vcpkgInstallDir = "./vcpkg" + if (Test-Path -Path $vcpkgInstallDir -PathType Container) { + Remove-Item -Path $vcpkgInstallDir -Recurse -Force + } + + Write-Message "Removing StagedArtifacts..." + $stagedArtifactsDir = "./StagedArtifacts" + if (Test-Path -Path $stagedArtifactsDir -PathType Container) { + Remove-Item -Path $stagedArtifactsDir -Recurse -Force + } +} + function Run-SetupVcpkgStep { param( [string]$repoHash @@ -169,20 +195,11 @@ function Run-SetupVcpkgStep { $installDir = "./vcpkg" if ( (Get-IsOnWindowsOS) ) { $bootstrapScript = "./bootstrap-vcpkg.bat" - $cacheDir = "$env:LocalAppData/vcpkg/archives" } elseif ( (Get-IsOnMacOS) ) { $bootstrapScript = "./bootstrap-vcpkg.sh" - $cacheDir = "$HOME/.cache/vcpkg/archives" } Write-Banner -Level 3 -Title "Setting up vcpkg" - Write-Message "Removing vcpkg..." - if (Test-Path -Path $cacheDir -PathType Container) { - Remove-Item -Path $cacheDir -Recurse -Force - } - if (Test-Path -Path $installDir -PathType Container) { - Remove-Item -Path $installDir -Recurse -Force - } Write-Message "$(NL)Installing vcpkg..." if (-not (Test-Path -Path $installDir -PathType Container)) { @@ -413,7 +430,7 @@ function Resolve-Symlink { return $currentPath.FullName } -Export-ModuleMember -Function Get-PackageInfo, Run-WriteParamsStep, Run-SetupVcpkgStep, Run-PreBuildStep, Run-InstallPackageStep, Run-PrestageAndFinalizeBuildArtifactsStep, Run-PostBuildStep, Run-StageBuildArtifactsStep, Run-StageSourceArtifactsStep +Export-ModuleMember -Function Get-PackageInfo, Run-WriteParamsStep, Run-SetupVcpkgStep, Run-PreBuildStep, Run-InstallPackageStep, Run-PrestageAndFinalizeBuildArtifactsStep, Run-PostBuildStep, Run-StageBuildArtifactsStep, Run-StageSourceArtifactsStep, Run-CleanupStep Export-ModuleMember -Function NL, Write-Banner, Write-Message, Get-PSObjectAsFormattedList, Get-IsOnMacOS, Get-IsOnWindowsOS, Resolve-Symlink if ( (Get-IsOnMacOS) ) {