Skip to content

Commit

Permalink
Consolidate common post-build steps for Mac
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mike-malburg committed May 9, 2024
1 parent e709386 commit 1a210e1
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 90 deletions.
5 changes: 1 addition & 4 deletions custom-steps/expat/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

5 changes: 1 addition & 4 deletions custom-steps/ffmpeg/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

5 changes: 1 addition & 4 deletions custom-steps/hunspell/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
16 changes: 0 additions & 16 deletions custom-steps/libpng/post-build.ps1

This file was deleted.

5 changes: 1 addition & 4 deletions custom-steps/libzip/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
5 changes: 1 addition & 4 deletions custom-steps/minizip/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
16 changes: 0 additions & 16 deletions custom-steps/opencv4/post-build.ps1

This file was deleted.

5 changes: 1 addition & 4 deletions custom-steps/pango/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
16 changes: 0 additions & 16 deletions custom-steps/skia/post-build.ps1

This file was deleted.

16 changes: 1 addition & 15 deletions custom-steps/whispercpp/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
22 changes: 19 additions & 3 deletions ps-modules/MacBuild/MacBuild.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = @()
Expand Down Expand Up @@ -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

0 comments on commit 1a210e1

Please sign in to comment.