1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 17:52:42 +02:00

build/windows: Refactor MSIX .ps1 a bit to not impose strict SDK or .msixbundle

The original script required a specific WinSDK version. Now, it autodetects.
This is useful if we need to move to another runner and welcome locally too.

Also, downloading the arm64 artifact was mandatory to get a x64 msix, which
is silly. Now, packagers are free to package to either arm64 or x64 alone.
This is useful locally but could be useful on CI too when some arch fail(?).
This commit is contained in:
Bruno
2024-07-13 15:49:40 -03:00
parent 60897f1700
commit bd28861785
3 changed files with 198 additions and 207 deletions

View File

@@ -816,10 +816,10 @@ dist-store-weekly:
- win32-ps - win32-ps
cache: [] cache: []
script: script:
- build\windows\store\3_dist-gimp-winsdk.ps1 | Out-File -FilePath store.log - build\windows\store\3_dist-gimp-winsdk.ps1 | Out-File -FilePath winsdk.log
artifacts: artifacts:
expose_as: 'Windows msix' expose_as: 'Windows msix'
paths: paths:
- build/windows/store/_Output/ - build/windows/store/_Output/
- store.log - winsdk.log
expire_in: 8 days expire_in: 8 days

View File

@@ -1,227 +1,218 @@
#!/usr/bin/env pwsh #!/usr/bin/env pwsh
# Parameters # Parameters
param ($gimp_version, param ($build_dir = '_build',
$gimp_app_version, $a64_bundle = 'gimp-a64',
$arch_a64 = 'gimp-a64', $x64_bundle = 'gimp-x64')
$arch_x64 = 'gimp-x64')
# Autodetects latest WinSDK installed
if ($Env:PROCESSOR_ARCHITECTURE -eq 'ARM64')
{
$cpu_arch = 'arm64'
}
else
{
$cpu_arch = 'x64'
}
$win_sdk_path = Resolve-Path "C:\Program Files (x86)\Windows Kits\10\bin\*\$cpu_arch" | Select-Object -Last 1
# Needed tools from Windows SDK # Needed tools from Windows SDK
Set-Alias -Name 'makepri' -Value "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\makepri.exe" Set-Alias 'makepri' "$win_sdk_path\makepri.exe"
Set-Alias -Name 'makeappx' -Value 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\MakeAppx.exe' Set-Alias 'makeappx' 'C:\Program Files (x86)\Windows Kits\10\App Certification Kit\MakeAppx.exe'
Set-Alias -Name 'signtool' -Value 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x64\signtool.exe' Set-Alias 'signtool' "$win_sdk_path\signtool.exe"
# Global variables # Global variables
$config_path = '_build\config.h' $config_path = "$build_dir\config.h"
## Identity Name (internal) and Display Name (in the Store) ## Get Identity Name (the dir shown in Explorer)
$gimp_unstable = Get-Content -Path "$config_path" | Select-String 'GIMP_UNSTABLE' | $GIMP_UNSTABLE = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_UNSTABLE' |
Foreach-Object {$_ -replace '#define GIMP_UNSTABLE ',''} Foreach-Object {$_ -replace '#define GIMP_UNSTABLE ',''}
if ($gimp_unstable -ne '1') if ($GIMP_UNSTABLE -eq '1')
{ {
$identity_name="GIMP.GIMP" $IDENTITY_NAME="GIMP.GIMPPreview"
$display_name="GIMP"
} }
else else
{ {
$identity_name="GIMP.GIMPPreview" $IDENTITY_NAME="GIMP.GIMP"
$display_name="GIMP (Preview)"
} }
## GIMP version (major.minor.micro) ## Get GIMP version (major.minor.micro)
if (-Not $gimp_version) $GIMP_VERSION = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_VERSION' |
{
$gimp_version = Get-Content -Path "$config_path" | Select-String 'GIMP_VERSION' |
Foreach-Object {$_ -replace '#define GIMP_VERSION "',''} | Foreach-Object {$_ -replace '"',''} Foreach-Object {$_ -replace '#define GIMP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
}
## GIMP app version (major.minor)
if (-Not $gimp_app_version) # Autodetects what arch bundles will be packaged
Copy-Item .gitignore .gitignore.bak
$supported_archs = "$a64_bundle","$x64_bundle"
foreach ($bundle in $supported_archs)
{ {
$gimp_app_version = Get-Content -Path "$config_path" | Select-String 'GIMP_APP_VERSION "' | if (Test-Path "$bundle")
Foreach-Object {$_ -replace '#define GIMP_APP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
}
## GIMP API version (stable_major.0)
if (-Not $gimp_api_version)
{ {
$gimp_api_version = Get-Content -Path "$config_path" | Select-String 'GIMP_PKGCONFIG_VERSION "' | if (("$bundle" -like '*a64*') -or ("$bundle" -like '*aarch64*') -or ("$bundle" -like '*arm64*'))
Foreach-Object {$_ -replace '#define GIMP_PKGCONFIG_VERSION "',''} | Foreach-Object {$_ -replace '"',''} {
$msix_arch = 'arm64'
}
else
{
$msix_arch = 'x64'
} }
## GIMP arch folders $ig_content = "`n$bundle`n$msix_arch`n*.appxsym`n*.zip"
$vfs_a64 = "$arch_a64\VFS\ProgramFilesX64\GIMP ${gimp_app_version}" if (Test-Path .gitignore -Type Leaf)
$vfs_x64 = "$arch_x64\VFS\ProgramFilesX64\GIMP ${gimp_app_version}" {
$archsArray = "$arch_a64","$arch_x64" Add-Content .gitignore "$ig_content"
$vfsArray = "$vfs_a64","$vfs_x64" }
else
{
New-Item .gitignore
Set-Content .gitignore "$ig_content"
}
Set-Location build\windows\store\ New-Item $msix_arch -ItemType Directory
New-Item -Path "." -Name ".gitignore" -ItemType "File" -Force
Set-Content ".gitignore" "$arch_a64`n$arch_x64`n_TempOutput`n_Output"
# 1. CONFIGURE MANIFEST # 1. CONFIGURE MANIFEST
function Configure-Arch ([string]$arch, [string]$arch_msix) Copy-Item build\windows\store\AppxManifest.xml $msix_arch
{
New-Item -ItemType Directory -Path $arch
Copy-Item AppxManifest.xml $arch
## Set Identity Name ## Set Identity Name
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "@IDENTITY_NAME@","$identity_name"} | (Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "@IDENTITY_NAME@","$IDENTITY_NAME"} |
Set-Content -Path "$arch\AppxManifest.xml" Set-Content $msix_arch\AppxManifest.xml
## Set Display Name ## Set Display Name (the name shown in MS Store)
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "@DISPLAY_NAME@","$display_name"} | if ($GIMP_UNSTABLE -eq '1')
Set-Content -Path "$arch\AppxManifest.xml" {
$display_name='GIMP (Preview)'
}
else
{
$display_name='GIMP'
}
(Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "@DISPLAY_NAME@","$display_name"} |
Set-Content $msix_arch\AppxManifest.xml
## Set GIMP version ## Set GIMP version
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "@GIMP_VERSION@","$gimp_version"} | (Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "@GIMP_VERSION@","$GIMP_VERSION"} |
Set-Content -Path "$arch\AppxManifest.xml" Set-Content $msix_arch\AppxManifest.xml
## Set GIMP app version ## Set GIMP app version (major.minor)
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "@GIMP_APP_VERSION@","$gimp_app_version"} | $gimp_app_version = Get-Content "$CONFIG_PATH" | Select-String 'GIMP_APP_VERSION "' |
Set-Content -Path "$arch\AppxManifest.xml" Foreach-Object {$_ -replace '#define GIMP_APP_VERSION "',''} | Foreach-Object {$_ -replace '"',''}
(Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "@GIMP_APP_VERSION@","$gimp_app_version"} |
Set-Content $msix_arch\AppxManifest.xml
## Set arch ## Set msix_arch
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "neutral","$arch_msix"} | (Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "neutral","$msix_arch"} |
Set-Content -Path "$arch\AppxManifest.xml" Set-Content $msix_arch\AppxManifest.xml
## Match supported filetypes ## Match supported filetypes
$file_types = Get-Content -Path '..\installer\data_associations.list' | Foreach-Object {" <uap:FileType>." + $_} | $file_types = Get-Content 'build\windows\installer\data_associations.list' | Foreach-Object {" <uap:FileType>." + $_} |
Foreach-Object {$_ + "</uap:FileType>"} | Where-Object {$_ -notmatch 'xcf'} Foreach-Object {$_ + "</uap:FileType>"} | Where-Object {$_ -notmatch 'xcf'}
(Get-Content -Path "$arch\AppxManifest.xml") | Foreach-Object {$_ -replace "@FILE_TYPES@","$file_types"} | (Get-Content $msix_arch\AppxManifest.xml) | Foreach-Object {$_ -replace "@FILE_TYPES@","$file_types"} |
Set-Content -Path "$arch\AppxManifest.xml" Set-Content $msix_arch\AppxManifest.xml
}
Configure-Arch "$arch_a64" 'arm64'
Configure-Arch "$arch_x64" 'x64'
# 2. CREATE ASSETS # 2. CREATE ASSETS
## Copy pre-generated icons to each arch ## Copy pre-generated icons to each msix_arch
$icons_path = '..\..\..\_build\build\windows\store\Assets' $icons_path = "$build_dir\build\windows\store\Assets"
if (Test-Path -Path "$icons_path") if (Test-Path "$icons_path")
{ {
foreach ($arch in $archsArray) New-Item $msix_arch\Assets -ItemType Directory
{ Copy-Item "$icons_path\*.png" $msix_arch\Assets\ -Recurse
New-Item -ItemType Directory -Path "$arch\Assets\"
Copy-Item -Path "$icons_path\*.png" -Destination "$arch\Assets\" -Recurse
} }
} else
else
{ {
"MS Store icons not found. You can generate them adding '-Dms-store=true' option" "(ERROR): MS Store icons not found. You can build them with '-Dms-store=true'"
"at meson configure time."
exit 1 exit 1
} }
## Generate resources.pri ## Generate resources.pri
foreach ($arch in $archsArray) Set-Location $msix_arch
{
Set-Location $arch
makepri createconfig /cf priconfig.xml /dq lang-en-US /pv 10.0.0 makepri createconfig /cf priconfig.xml /dq lang-en-US /pv 10.0.0
Set-Location ..\ Set-Location ..\
makepri new /pr $arch /cf $arch\priconfig.xml /of $arch makepri new /pr $msix_arch /cf $msix_arch\priconfig.xml /of $msix_arch
Remove-Item "$arch\priconfig.xml" Remove-Item $msix_arch\priconfig.xml
}
# 3. COPY GIMP FILES # 3. COPY GIMP FILES
$vfs = "$msix_arch\VFS\ProgramFilesX64\GIMP"
## Copy files into VFS folder (to support external 3P plug-ins) ## Copy files into VFS folder (to support external 3P plug-ins)
Copy-Item -Path "..\..\..\$arch_a64" -Destination "$vfs_a64" -Recurse Copy-Item "$bundle" "$vfs" -Recurse -Force
Copy-Item -Path "..\..\..\$arch_x64" -Destination "$vfs_x64" -Recurse
## Remove uneeded files (to match the Inno Windows Installer artifact) ## Remove uneeded files (to match the Inno Windows Installer artifact)
Remove-Item "$vfs_a64\gimp.cmd" Remove-Item "$vfs\gimp.cmd"
Remove-Item "$vfs_x64\gimp.cmd"
## Disable Update check (since the package is auto updated) ## Disable Update check (ONLY FOR RELEASES)
foreach ($vfs in $vfsArray) if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))
{ {
Add-Content $vfs\share\gimp\$gimp_api_version\gimp-release "check-update=false" Add-Content "$vfs\share\gimp\*\gimp-release" 'check-update=false'
} }
## Remove uncompliant files (to fix 'signtool' issues) ## Remove uncompliant files (to avoid WACK/'signtool' issues)
$corrections = ("*.debug", "*.tar") Get-ChildItem "$vfs" -Recurse -Include ("*.debug", "*.tar") | Remove-Item -Recurse
foreach ($vfs in $vfsArray)
# 4. MAKE .MSIX AND CORRESPONDING .APPXSYM
$MSIX_ARTIFACT = "${IDENTITY_NAME}_${GIMP_VERSION}.0_$msix_arch.msix"
$APPXSYM = $MSIX_ARTIFACT -replace '.msix','.appxsym'
## Make .appxsym for each msix_arch (ONLY FOR RELEASES)
#if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))
# {
# Get-ChildItem $msix_arch -Filter *.pdb -Recurse |
# Compress-Archive -DestinationPath "${IDENTITY_NAME}_${GIMP_VERSION}.0_$msix_arch.zip"
# Get-ChildItem *.zip | Rename-Item -NewName $APPXSYM
# Get-ChildItem $msix_arch -Include *.pdb -Recurse -Force | Remove-Item -Recurse -Force
# }
## Make .msix from each msix_arch
makeappx pack /d $msix_arch /p $MSIX_ARTIFACT
Remove-Item $msix_arch/ -Recurse
} #END of 'if (Test-Path...'
} #END of 'foreach ($msix_arch...'
# 5. MAKE .MSIXBUNDLE AND SUBSEQUENT .MSIXUPLOAD
if ((Get-ChildItem *.msix -Recurse).Count -gt 1)
{ {
Get-ChildItem $vfs -Recurse -Include $corrections | Remove-Item -Recurse ## Make .msixbundle with all archs
} ## (This is needed not only for easier multi-arch testing but
## also to make sure against Partner Center getting confused)
$MSIX_ARTIFACT = "${IDENTITY_NAME}_${GIMP_VERSION}.0_neutral.msixbundle"
New-Item _TempOutput -ItemType Directory
Move-Item *.msix _TempOutput/
makeappx bundle /bv "${GIMP_VERSION}.0" /d _TempOutput /p $MSIX_ARTIFACT
Remove-Item _TempOutput/ -Recurse
## Make .msixupload (ONLY FOR RELEASES)
# 4. MAKE .MSIXUPLOAD (ONLY FOR RELEASES) if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))
New-Item -ItemType Directory -Path "_TempOutput"
New-Item -ItemType Directory -Path "_Output"
$archsArray_limited = $archsArray -replace "gimp-", ""
## Make .appxsym for each arch
#if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))
# {
# foreach ($arch in $archsArray_limited)
# {
# Get-ChildItem -Path "gimp-$arch" -Filter "*.pdb" -Recurse |
# Compress-Archive -DestinationPath "_Output\${identity_name}_${gimp_version}.0_$arch.zip"
# Get-ChildItem "_Output\*.zip" | Rename-Item -NewName { $_.Name -replace '.zip','.appxsym' }
# }
# }
## Make .msix for each arch (this is needed to make the .msixbundle too)
foreach ($arch in $archsArray_limited)
{ {
#Get-ChildItem "gimp-$arch" -Include "*.pdb" -Recurse -Force | Remove-Item -Recurse -Force $MSIX_ARTIFACT = "${IDENTITY_NAME}_${GIMP_VERSION}.0_x64_arm64_bundle.msixupload"
makeappx pack /d "gimp-$arch" /p "_TempOutput\${identity_name}_${gimp_version}.0_$arch.msix" Get-ChildItem *.msixbundle | ForEach-Object { Compress-Archive -Path "$($_.Basename).msixbundle" -DestinationPath "$($_.Basename).zip" }
Remove-Item "gimp-$arch" -Recurse Get-ChildItem *.zip | Rename-Item -NewName $MSIX_ARTIFACT
#Get-ChildItem *.appxsym | Remove-Item -Recurse -Force
Get-ChildItem *.msixbundle | Remove-Item -Recurse -Force
}
} }
## Make .msixbundle with all archs
## (This is needed not only for local testing but also
## to make sure against Partner Center getting confused)
makeappx bundle /bv "${gimp_version}.0" /d "_TempOutput\" /p "_Output\${identity_name}_${gimp_version}.0_neutral.msixbundle"
Remove-Item "_TempOutput\" -Recurse -Force
## Make .msixupload # 5. SIGN .MSIX OR .MSIXBUNDLE (FOR TESTING ONLY) AND DO OTHER STUFF
if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD')) if (-not $CI_COMMIT_TAG -and ($GIMP_CI_MS_STORE -ne 'MSIXUPLOAD') -and ($MSIX_ARTIFACT -notlike "*msixupload"))
{ {
Compress-Archive -Path "_Output\*" "_Output\${identity_name}_${gimp_version}.0_x64_arm64_bundle.zip" signtool sign /fd sha256 /a /f build\windows\store\pseudo-gimp.pfx /p eek $MSIX_ARTIFACT
Get-ChildItem "_Output\*.zip" | Rename-Item -NewName { $_.Name -replace '.zip','.msixupload' } Copy-Item build\windows\store\pseudo-gimp.pfx .\ -Recurse
#Get-ChildItem "_Output\*.appxsym" | Remove-Item -Recurse -Force
} }
if ($GITLAB_CI)
# 5. SIGN .MSIXBUNDLE (FOR TESTING)
Copy-Item -Path "pseudo-gimp.pfx" -Destination "_Output\" -Recurse
SignTool sign /fd sha256 /a /f _Output\pseudo-gimp.pfx /p eek "_Output\${identity_name}_${gimp_version}.0_neutral.msixbundle"
# 6. TEST .MSIXUPLOAD OR .MSIXBUNDLE
if ($CI_COMMIT_TAG -or ($GIMP_CI_MS_STORE -eq 'MSIXUPLOAD'))
{ {
$MSIX_ARTIFACT="${identity_name}_${gimp_version}.0_x64_arm64_bundle.msixupload" # GitLab doesn't support wildcards when using "expose_as" so let's move to a dir
} New-Item build\windows\store\_Output -ItemType Directory
else Move-Item $MSIX_ARTIFACT build\windows\store\_Output
{ Get-ChildItem pseudo-gimp.pfx | Move-Item -Destination build\windows\store\_Output
$MSIX_ARTIFACT="${identity_name}_${gimp_version}.0_neutral.msixbundle"
} }
if (Test-Path -Path "_Output\${MSIX_ARTIFACT}" -PathType Leaf) Remove-Item .gitignore
{ Rename-Item .gitignore.bak .gitignore
Set-Location _Output\
Get-FileHash $MSIX_ARTIFACT -Algorithm SHA256 | Out-File -FilePath "${MSIX_ARTIFACT}.SHA256SUMS"
Get-FileHash $MSIX_ARTIFACT -Algorithm SHA512 | Out-File -FilePath "${MSIX_ARTIFACT}.SHA512SUMS"
### Return to git golder
Set-Location ..\..\..\..\
exit 0
}
else
{
### Return to git golder
Set-Location ..\..\..\
exit 1
}

View File

@@ -29,7 +29,7 @@
<Resource uap:Scale="400" /> <Resource uap:Scale="400" />
</Resources> </Resources>
<Applications> <Applications>
<Application Id="GIMP" Executable="VFS\ProgramFilesX64\GIMP @GIMP_APP_VERSION@\bin\gimp-@GIMP_APP_VERSION@.exe" EntryPoint="Windows.FullTrustApplication"> <Application Id="GIMP" Executable="VFS\ProgramFilesX64\GIMP\bin\gimp-@GIMP_APP_VERSION@.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements DisplayName="GIMP @GIMP_VERSION@" Description="GNU Image Manipulation Program" BackgroundColor="transparent" Square150x150Logo="Assets\MedTile.png" Square44x44Logo="Assets\AppList.png"> <uap:VisualElements DisplayName="GIMP @GIMP_VERSION@" Description="GNU Image Manipulation Program" BackgroundColor="transparent" Square150x150Logo="Assets\MedTile.png" Square44x44Logo="Assets\AppList.png">
<uap:DefaultTile Wide310x150Logo="Assets\WideTile.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png"> <uap:DefaultTile Wide310x150Logo="Assets\WideTile.png" Square310x310Logo="Assets\LargeTile.png" Square71x71Logo="Assets\SmallTile.png">
<uap:ShowNameOnTiles> <uap:ShowNameOnTiles>
@@ -71,7 +71,7 @@
<Extensions> <Extensions>
<uap6:Extension Category="windows.loaderSearchPathOverride"> <uap6:Extension Category="windows.loaderSearchPathOverride">
<uap6:LoaderSearchPathOverride> <uap6:LoaderSearchPathOverride>
<uap6:LoaderSearchPathEntry FolderPath="VFS\ProgramFilesX64\GIMP @GIMP_APP_VERSION@\bin"/> <uap6:LoaderSearchPathEntry FolderPath="VFS\ProgramFilesX64\GIMP\bin"/>
</uap6:LoaderSearchPathOverride> </uap6:LoaderSearchPathOverride>
</uap6:Extension> </uap6:Extension>
</Extensions> </Extensions>