diff --git a/ps-modules/Build/Build.psm1 b/ps-modules/Build/Build.psm1 index e132f079..e4ef0538 100644 --- a/ps-modules/Build/Build.psm1 +++ b/ps-modules/Build/Build.psm1 @@ -137,42 +137,27 @@ function Run-SetupVcpkgStep { Write-Banner -Level 3 -Title "Setting up vcpkg" Write-Message "Removing vcpkg..." - Write-Debug "> Removing vcpkg system cache..." - Write-Debug ">> Looking for user-specific vcpkg cache dir: $cacheDir" if (Test-Path -Path $cacheDir -PathType Container) { - Write-Debug ">> Deleting dir: $cacheDir" Remove-Item -Path $cacheDir -Recurse -Force - } else { - Write-Debug ">> Directory not found: $cacheDir" - } - Write-Debug "> Removing dir: vcpkg" + } if (Test-Path -Path $installDir -PathType Container) { - Write-Debug ">> Directory found. Deleting: $installDir" Remove-Item -Path $installDir -Recurse -Force - } else { - Write-Debug ">> Directory not found: $installDir, skipping step." } Write-Message "$(NL)Installing vcpkg..." - if (Test-Path -Path $installDir -PathType Container) { - Write-Debug "> Directory already exists: $installDir!!!" + if (-not (Test-Path -Path $installDir -PathType Container)) { + git clone $repo + if ($repoHash -ne "") { + Push-Location $installDir + git checkout $repoHash + Pop-Location + } } - else - { - Write-Debug "> Cloning repo: $repo" - git clone $repo - if ($repoHash -ne "") { - Write-Debug ">> Checking out hash: $repoHash" - Push-Location vcpkg - git checkout $repoHash - Pop-Location - } - Write-Debug "> Bootstrapping vcpkg..." - Push-Location $installDir - Invoke-Expression "$bootstrapScript" - Pop-Location - } + Write-Message "$(NL)Bootstrapping vcpkg..." + Push-Location $installDir + Invoke-Expression "$bootstrapScript" + Pop-Location } function Run-PreBuildStep { @@ -222,7 +207,6 @@ function Run-PostBuildStep { ) $packageNameOnly = (Get-PackageNameOnly $packageAndFeatures) $preStagePath = (Get-PreStagePath -linkType $linkType -buildType $buildType) - Write-Debug "preStagePath: $preStagePath" $scriptArgs = @{ BuildArtifactsPath = ((Resolve-Path $preStagePath).Path -replace '\\', '/') } Run-ScriptIfExists -title "Post-build step" -script "custom-steps/$packageNameOnly/post-build.ps1" -scriptArgs $scriptArgs } @@ -239,16 +223,14 @@ function Run-StageArtifactsStep { Write-Banner -Level 3 -Title "Stage build artifacts" $artifactName = (Get-ArtifactName -packageName $packageName -packageAndFeatures $packageAndFeatures -linkType $linkType -buildType $buildType) - Write-Debug "Creating dir: $artifactName" New-Item -Path $stagedArtifactsPath/$artifactName -ItemType Directory -Force -ErrorAction SilentlyContinue | Out-Null $dependenciesFilename = "dependencies.json" - Write-Debug "Generating: `"$dependenciesFilename`"..." - Write-Debug "> $stagedArtifactsPath/$artifactName/$dependenciesFilename" + Write-Message "Generating: `"$dependenciesFilename`"..." Invoke-Expression "$(Get-VcPkgExe) list --x-json > $stagedArtifactsPath/$artifactName/$dependenciesFilename" $packageInfoFilename = "package.json" - Write-Debug "Generating: `"$packageInfoFilename`"..." + Write-Message "Generating: `"$packageInfoFilename`"..." $dependenciesJson = Get-Content -Raw -Path "$stagedArtifactsPath/$artifactName/$dependenciesFilename" | ConvertFrom-Json $packageNameOnly = (Get-PackageNameOnly $packageAndFeatures) $packageVersion = ($dependenciesJson.PSObject.Properties.Value | Where-Object { $_.package_name -eq $packageNameOnly } | Select-Object -First 1).version @@ -258,15 +240,13 @@ function Run-StageArtifactsStep { # TODO: Add license file info to the staged artifacts (ex. per-library LICENSE, COPYING, or other such files that commonly have license info in them) $preStagePath = (Get-PreStagePath -linkType $linkType -buildType $buildType) - Write-Message "Copying: $preStagePath =`> $artifactName" + Write-Message "Copying files: $preStagePath =`> $artifactName" $excludedFolders = @("tools", "share", "debug") Copy-Item -Path "$preStagePath/*" -Destination $stagedArtifactsPath/$artifactName -Force -Recurse -Exclude $excludedFolders $artifactArchive = "$artifactName.tar.gz" - Write-Message "Compressing: `"$artifactName`" =`> `"$artifactArchive`"" + Write-Message "Creating final artifact: `"$artifactArchive`"" tar -czf "$stagedArtifactsPath/$artifactArchive" -C "$stagedArtifactsPath/$artifactName" . - - Write-Debug "Deleting: `"$artifactName`"" Remove-Item -Path "$stagedArtifactsPath/$artifactName" -Recurse -Force } diff --git a/ps-modules/MacBuild/MacBuild.psm1 b/ps-modules/MacBuild/MacBuild.psm1 index 85a1f1bd..875cf100 100644 --- a/ps-modules/MacBuild/MacBuild.psm1 +++ b/ps-modules/MacBuild/MacBuild.psm1 @@ -3,10 +3,8 @@ function Create-UniversalDir { $universalDir ) if (Test-Path -Path $universalDir -PathType Container) { - Write-Debug "Removing universal dir..." Remove-Item -Path "$universalDir" -Recurse -Force | Out-Null } - Write-Debug "Creating universal dir..." New-Item -Path "$universalDir" -ItemType Directory -Force | Out-Null } @@ -15,7 +13,6 @@ function Update-LibsToRelativePaths { [string]$arm64LibDir, [string]$x64LibDir ) - Write-Debug "Making install paths relative..." ConvertTo-RelativeInstallPaths -directory $arm64LibDir -extension "a" ConvertTo-RelativeInstallPaths -directory $arm64LibDir -extension "dylib" ConvertTo-RelativeInstallPaths -directory $x64LibDir -extension "a" @@ -28,11 +25,9 @@ function Create-UniversalBinaries { [string]$x64LibDir, [string]$universalLibDir ) - Write-Debug "Making binaries universal..." $universalLibDir = (Join-Path $universalDir "lib") New-Item -Path "$universalLibDir" -ItemType Directory -Force | Out-Null - Write-Debug "Looking in: $arm64LibDir" $items = Get-ChildItem -Path "$arm64LibDir/*" -Include "*.dylib","*.a" foreach($item in $items) { $fileName = $item.Name @@ -41,11 +36,9 @@ function Create-UniversalBinaries { $destPath = (Join-Path $universalLibDir $fileName) if ($item.Attributes -band [System.IO.FileAttributes]::ReparsePoint) { - Write-Debug "> Processing: $fileName - Copying symlink" Invoke-Expression -Command "cp -R `"$srcPathArm64`" `"$destPath`"" } elseif (-not $item.PSIsContainer) { - Write-Debug "> Processing: $filename - Running lipo" Invoke-Expression -Command "lipo -create -output `"$destPath`" `"$srcPathArm64`" `"$srcPathX64`"" } } @@ -60,7 +53,6 @@ function Create-FinalMacArtifacts { Write-Message "$arm64Dir, $x64Dir ==> $preStagePath" Create-UniversalDir $universalDir - Write-Debug "Creating universal dir and copying headers..." Copy-Item -Path "$x64Dir/include" -Destination "$universalDir/include" -Recurse | Out-Null # Assume arm64 and x86_64 are identical $arm64LibDir = (Join-Path $arm64Dir "lib") @@ -74,14 +66,10 @@ function Update-LibraryPath { [string]$libPath ) - Write-Debug ">> Update-LibraryPath..." - if (-not (Test-Path $libPath -PathType Leaf)) { - Write-Debug ">> File '$libPath' does not exist." return } - Write-Debug ">> Updating library path for: $libPath..." $otoolCmd = "otool -L $libPath" $otoolOutput = Invoke-Expression -Command $otoolCmd $lines = $otoolOutput.Split([Environment]::NewLine) @@ -106,14 +94,10 @@ function Update-LibraryPath { $newPath = $path.Replace($dirname, "@rpath") $dylibName = [System.IO.Path]::GetFileName($libPath) - Write-Debug ($path + "-" + $dylibName) - if ([System.IO.Path]::GetFileName($path) -eq $dylibName) { - Write-Debug ">>> Changing ID" $changeCmd = "install_name_tool -id $newPath $libPath" } else { - Write-Debug ">>> Changing path" $changeCmd = "install_name_tool -change $path $newPath $libPath" } @@ -131,7 +115,6 @@ function ConvertTo-RelativeInstallPaths { foreach ($libFile in $libFiles) { $filePath = $libFile.FullName $fileName = $libFile.Name - Write-Debug ">> Processing: $fileName" Set-ItemProperty -Path $filePath -Name IsReadOnly -Value $false Update-LibraryPath -libPath $filePath } @@ -173,13 +156,10 @@ function Remove-DylibSymlinks { } } - Write-Debug "$(NL)Dynamic library dependencies before changes..." Debug-WriteLibraryDependencies $mainFiles - Write-Debug "$(NL)Updating paths to dynamic dependencies..." foreach ($mainFile in $mainFiles) { # Main file - Write-Debug "> $mainFile" Invoke-Expression "install_name_tool -id '@rpath/$mainFile' '$mainFile'" # All other files that might point to it @@ -188,32 +168,25 @@ function Remove-DylibSymlinks { $new_dependency = "$base_filename.dylib" if ($mainFiles -contains $new_dependency) { Invoke-Expression "install_name_tool -change '@rpath/$possible_current_dependency' '@rpath/$new_dependency' '$mainFile'" - } else { - Write-Debug ">> Matching main file not found for: $possible_current_dependency!!!" } } } - Write-Debug "$(NL)Dynamic library dependenies after changes..." Debug-WriteLibraryDependencies $mainFiles - Write-Debug "$(NL)Removing unused symlinks..." $files = Get-ChildItem -File -Recurse foreach ($file in $files) { if ($file.Attributes -band [System.IO.FileAttributes]::ReparsePoint) { - Write-Debug "Removing symlink: $($file.FullName)" Remove-Item $file.FullName } } # Rename files to the "main" filename we want - Write-Debug "$(NL)Renaming files..." $files = Get-ChildItem -File -Recurse foreach ($file in $files) { $oldFilename = $file.Name $base_filename = ($oldFilename -split '[^a-zA-Z0-9]')[0] # Discard anything after the first non-alphanumeric character $newFilename = "$base_filename" + [System.IO.Path]::GetExtension($file) - Write-Debug "$oldFilename ==> $newFilename" Move-Item -Path $file.Name -Destination $newFilename } diff --git a/ps-modules/Util/Util.psm1 b/ps-modules/Util/Util.psm1 index c68d4800..fecf1537 100644 --- a/ps-modules/Util/Util.psm1 +++ b/ps-modules/Util/Util.psm1 @@ -143,7 +143,6 @@ function Run-ScriptIfExists { return } Write-Banner -Level 3 -Title $title - Write-Debug "> Executing: $script" Invoke-Powershell -FilePath $script -ArgumentList $scriptArgs }