From 1a210e134e4e0d617add1fbdd62c8cfe947491e4 Mon Sep 17 00:00:00 2001 From: Mike Malburg Date: Wed, 8 May 2024 21:39:00 -0400 Subject: [PATCH] Consolidate common post-build steps for Mac We were removing dylib symlinks in all of the post-build scripts for Mac, and we will now want to do this debug symbol stuff for all of the Mac builds, so just consolidate all of that in the Create-FinalizedMacArtifacts step, which runs before the post-build scripts. This allows us to shorten up the Post-Build scripts and also remove a few of them. --- custom-steps/expat/post-build.ps1 | 5 +---- custom-steps/ffmpeg/post-build.ps1 | 5 +---- custom-steps/hunspell/post-build.ps1 | 5 +---- custom-steps/libpng/post-build.ps1 | 16 ---------------- custom-steps/libzip/post-build.ps1 | 5 +---- custom-steps/minizip/post-build.ps1 | 5 +---- custom-steps/opencv4/post-build.ps1 | 16 ---------------- custom-steps/pango/post-build.ps1 | 5 +---- custom-steps/skia/post-build.ps1 | 16 ---------------- custom-steps/whispercpp/post-build.ps1 | 16 +--------------- ps-modules/MacBuild/MacBuild.psm1 | 22 +++++++++++++++++++--- 11 files changed, 26 insertions(+), 90 deletions(-) delete mode 100644 custom-steps/libpng/post-build.ps1 delete mode 100644 custom-steps/opencv4/post-build.ps1 delete mode 100644 custom-steps/skia/post-build.ps1 diff --git a/custom-steps/expat/post-build.ps1 b/custom-steps/expat/post-build.ps1 index abdebc5b..9c684fb9 100644 --- a/custom-steps/expat/post-build.ps1 +++ b/custom-steps/expat/post-build.ps1 @@ -11,10 +11,7 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/custom-steps/ffmpeg/post-build.ps1 b/custom-steps/ffmpeg/post-build.ps1 index abdebc5b..9c684fb9 100644 --- a/custom-steps/ffmpeg/post-build.ps1 +++ b/custom-steps/ffmpeg/post-build.ps1 @@ -11,10 +11,7 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/custom-steps/hunspell/post-build.ps1 b/custom-steps/hunspell/post-build.ps1 index 94b3785c..82fddc51 100644 --- a/custom-steps/hunspell/post-build.ps1 +++ b/custom-steps/hunspell/post-build.ps1 @@ -11,9 +11,6 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif ((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } \ No newline at end of file diff --git a/custom-steps/libpng/post-build.ps1 b/custom-steps/libpng/post-build.ps1 deleted file mode 100644 index d86bac66..00000000 --- a/custom-steps/libpng/post-build.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -param ( - [Parameter(Mandatory=$true)][string]$BuildArtifactsPath, - [Parameter(Mandatory=$false)][string]$PackageAndFeatures, - [Parameter(Mandatory=$false)][string]$LinkType, - [Parameter(Mandatory=$false)][string]$BuildType, - [Parameter(Mandatory=$false)][string]$ModulesRoot -) - -$moduleName = "Build" -if(-not (Get-Module -Name $moduleName)) { - Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking -} - -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} diff --git a/custom-steps/libzip/post-build.ps1 b/custom-steps/libzip/post-build.ps1 index 5a85fe97..619d6ada 100644 --- a/custom-steps/libzip/post-build.ps1 +++ b/custom-steps/libzip/post-build.ps1 @@ -11,10 +11,7 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { if($LinkType -eq "dynamic") { Update-VersionInfoForDlls -buildArtifactsPath $BuildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/custom-steps/minizip/post-build.ps1 b/custom-steps/minizip/post-build.ps1 index c89bd2a0..3a160dac 100644 --- a/custom-steps/minizip/post-build.ps1 +++ b/custom-steps/minizip/post-build.ps1 @@ -11,9 +11,6 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/custom-steps/opencv4/post-build.ps1 b/custom-steps/opencv4/post-build.ps1 deleted file mode 100644 index d86bac66..00000000 --- a/custom-steps/opencv4/post-build.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -param ( - [Parameter(Mandatory=$true)][string]$BuildArtifactsPath, - [Parameter(Mandatory=$false)][string]$PackageAndFeatures, - [Parameter(Mandatory=$false)][string]$LinkType, - [Parameter(Mandatory=$false)][string]$BuildType, - [Parameter(Mandatory=$false)][string]$ModulesRoot -) - -$moduleName = "Build" -if(-not (Get-Module -Name $moduleName)) { - Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking -} - -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} diff --git a/custom-steps/pango/post-build.ps1 b/custom-steps/pango/post-build.ps1 index c89bd2a0..3a160dac 100644 --- a/custom-steps/pango/post-build.ps1 +++ b/custom-steps/pango/post-build.ps1 @@ -11,9 +11,6 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/custom-steps/skia/post-build.ps1 b/custom-steps/skia/post-build.ps1 deleted file mode 100644 index d86bac66..00000000 --- a/custom-steps/skia/post-build.ps1 +++ /dev/null @@ -1,16 +0,0 @@ -param ( - [Parameter(Mandatory=$true)][string]$BuildArtifactsPath, - [Parameter(Mandatory=$false)][string]$PackageAndFeatures, - [Parameter(Mandatory=$false)][string]$LinkType, - [Parameter(Mandatory=$false)][string]$BuildType, - [Parameter(Mandatory=$false)][string]$ModulesRoot -) - -$moduleName = "Build" -if(-not (Get-Module -Name $moduleName)) { - Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking -} - -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath -} diff --git a/custom-steps/whispercpp/post-build.ps1 b/custom-steps/whispercpp/post-build.ps1 index 604a3ee2..3a160dac 100644 --- a/custom-steps/whispercpp/post-build.ps1 +++ b/custom-steps/whispercpp/post-build.ps1 @@ -11,20 +11,6 @@ if(-not (Get-Module -Name $moduleName)) { Import-Module "$ModulesRoot/$moduleName" -Force -DisableNameChecking } -if ((Get-IsOnMacOS)) { - Remove-DylibSymlinks -BuildArtifactsPath $BuildArtifactsPath - - Write-Host "Generate .dSYM files & stripping debug symbols..." - Push-Location "$BuildArtifactsPath/lib" - $libraries = (Get-ChildItem -Path . -Filter "*.dylib") - foreach($library in $libraries) { - Write-Host "Running dsymutil on: $($library.Name)..." - dsymutil $library.Name -o ($library.Name + ".dSYM") - Write-Host "Running strip on: $($library.Name)..." - strip $library.Name - } - Pop-Location -} -elseif((Get-IsOnWindowsOS)) { +if((Get-IsOnWindowsOS)) { Update-VersionInfoForDlls -buildArtifactsPath $buildArtifactsPath -versionInfoJsonPath "$PSScriptRoot/version-info.json" } diff --git a/ps-modules/MacBuild/MacBuild.psm1 b/ps-modules/MacBuild/MacBuild.psm1 index 74a73efe..6264a94d 100644 --- a/ps-modules/MacBuild/MacBuild.psm1 +++ b/ps-modules/MacBuild/MacBuild.psm1 @@ -62,6 +62,8 @@ function Create-FinalizedMacArtifacts { Copy-NonLibraryFiles -srcDir $arm64LibDir -destDir $universalLibDir Remove-Item -Force -Recurse -Path $arm64LibDir Remove-Item -Force -Recurse -Path $x64LibDir + Remove-DylibSymlinks -libDir $universalLibDir + Run-CreateDysmAndStripDebugSymbols -libDir $universalLibDir } function Update-LibraryPath { @@ -205,11 +207,11 @@ function Get-SymlinkChains { function Remove-DylibSymlinks { param ( - [Parameter(Mandatory=$true)][string]$BuildArtifactsPath + [Parameter(Mandatory=$true)][string]$libDir ) Write-Message "Consolidating libraries and symlinks..." - Push-Location "$BuildArtifactsPath/lib" + Push-Location "$libDir" # Enumerate files $physicalFiles = @() @@ -276,4 +278,18 @@ function Remove-DylibSymlinks { Pop-Location } -Export-ModuleMember -Function Create-FinalizedMacArtifacts, Remove-DylibSymlinks +function Run-CreateDysmAndStripDebugSymbols { + param ( + [Parameter(Mandatory=$true)][string]$libDir + ) + + Push-Location "$libDir" + $libraries = (Get-ChildItem -Path . -Filter "*.dylib") + foreach($library in $libraries) { + dsymutil $library.Name -o ($library.Name + ".dSYM") + strip $library.Name + } + Pop-Location +} + +Export-ModuleMember -Function Create-FinalizedMacArtifacts