diff --git a/.github/workflows/QtApng.yml b/.github/workflows/QtApng.yml index 0dd3c17..a07c279 100644 --- a/.github/workflows/QtApng.yml +++ b/.github/workflows/QtApng.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, macos-latest] + os: [ubuntu-20.04, macos-12] vers: ['5.15.2'] include: - os: windows-2019 @@ -22,23 +22,24 @@ jobs: vers: '6.2.2' forceWin32: 'false' arch: 'win64_msvc2019_64' - - os: macos-latest + - os: macos-12 vers: '6.2.2' - forceWin32: 'false' + universalBinary: 'true' - os: windows-2019 - vers: '6.4.3' + vers: '6.5.3' forceWin32: 'false' arch: 'win64_msvc2019_64' - - os: macos-latest - vers: '6.4.3' - forceWin32: 'false' + - os: macos-12 + vers: '6.5.3' + universalBinary: 'true' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: + cache: true version: ${{ matrix.vers }} arch: ${{ matrix.arch }} @@ -46,17 +47,26 @@ jobs: run: pwsh pwsh/buildapng.ps1 env: forceWin32: ${{ matrix.forceWin32 }} + universalBinary: ${{ matrix.universalBinary }} + + - name: 'Upload Artifact' + if: github.ref != 'refs/heads/master' + uses: actions/upload-artifact@v4 + with: + name: qtapng-${{ matrix.os }}-${{ matrix.vers }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} + path: QtApng/output - name: 'Zip Artifact' + if: github.ref == 'refs/heads/master' uses: thedoctor0/zip-release@0.7.1 with: type: 'zip' - path: QtApng/plugins/ + path: QtApng/output/ filename: "qtapng-${{ matrix.os }}-${{ matrix.vers }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}.zip" - name: 'Upload to continous release' - if: github.event_name != 'pull_request' - uses: softprops/action-gh-release@v1 + if: github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v2 with: tag_name: 'cont' files: qtapng-*.zip diff --git a/.github/workflows/kimageformats.yml b/.github/workflows/kimageformats.yml index 50ba58f..2c1e6f5 100644 --- a/.github/workflows/kimageformats.yml +++ b/.github/workflows/kimageformats.yml @@ -14,7 +14,7 @@ jobs: include: - os: ubuntu-20.04 vers: '5.15.2' - - os: macos-latest + - os: macos-12 vers: '5.15.2' - os: windows-2019 vers: '5.15.2' @@ -24,22 +24,22 @@ jobs: vers: '6.2.2' forceWin32: 'false' arch: 'win64_msvc2019_64' - - os: macos-latest + - os: macos-12 vers: '6.2.2' universalBinary: 'true' - os: windows-2019 - vers: '6.4.3' + vers: '6.5.3' forceWin32: 'false' arch: 'win64_msvc2019_64' - - os: macos-latest - vers: '6.4.3' + - os: macos-12 + vers: '6.5.3' universalBinary: 'true' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install Qt - uses: jurplel/install-qt-action@v3 + uses: jurplel/install-qt-action@v4 with: cache: true version: ${{ matrix.vers }} @@ -49,7 +49,7 @@ jobs: - name: Setup vcpkg uses: lukka/run-vcpkg@v11 with: - vcpkgGitCommitId: '64d69a75df89c6b28a5d4d30fd7eaee138d35a4a' + vcpkgGitCommitId: '7eb700c9688daed6d8bdcdc571ebe3eedea6a774' - name: Build KImageFormats (just one big step for now) run: pwsh pwsh/buildkimageformats.ps1 @@ -57,7 +57,15 @@ jobs: forceWin32: ${{ matrix.forceWin32 }} universalBinary: ${{ matrix.universalBinary }} + - name: 'Upload Artifact' + if: github.ref != 'refs/heads/master' + uses: actions/upload-artifact@v4 + with: + name: kimageformats-${{ matrix.os }}-${{ matrix.vers }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }} + path: kimageformats/output + - name: 'Zip Artifact' + if: github.ref == 'refs/heads/master' uses: thedoctor0/zip-release@0.7.1 with: type: 'zip' @@ -65,8 +73,8 @@ jobs: filename: "kimageformats-${{ matrix.os }}-${{ matrix.vers }}${{ matrix.arch && format('-{0}', matrix.arch) || '' }}.zip" - name: 'Upload to continous release' - if: github.event_name != 'pull_request' - uses: softprops/action-gh-release@v1 + if: github.ref == 'refs/heads/master' + uses: softprops/action-gh-release@v2 with: tag_name: 'cont' files: kimageformats-*.zip diff --git a/pwsh/buildapng.ps1 b/pwsh/buildapng.ps1 index 52f7753..51088cf 100755 --- a/pwsh/buildapng.ps1 +++ b/pwsh/buildapng.ps1 @@ -1,22 +1,43 @@ #!/usr/bin/env pwsh +$qtVersion = ((qmake --version -split '\n')[1] -split ' ')[3] + # Clone git clone https://github.com/jurplel/QtApng.git cd QtApng -git checkout 250f218ceeefdf2a6e66b596799abd279adea033 +git checkout 6a83caf22111cb8054753b925c2dfbcd9b92e038 +# Dependencies +if ($IsWindows) { + & "$env:GITHUB_WORKSPACE/pwsh/vcvars.ps1" + choco install ninja pkgconfiglite +} elseif ($IsMacOS) { + brew update + brew install ninja +} else { + sudo apt-get install ninja-build +} # Build +$argApngQt6 = $qtVersion -like '5.*' ? "-DAPNG_QT6=OFF" : $null +cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release $argApngQt6 +ninja -C build -# vcvars on windows -if ($IsWindows) { - & "$env:GITHUB_WORKSPACE/pwsh/vcvars.ps1" +if ($env:universalBinary -eq 'true') { + cmake -B build_arm64 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 + ninja -C build_arm64 } -qmake "CONFIG += libpng_static" QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" -if ($IsWindows) { - nmake -} else { - make +# Copy output +$outputDir = "output" +mkdir $outputDir +$files = Get-ChildItem -Path "build/plugins/imageformats" | Where-Object { $_.Extension -in ".dylib", ".dll", ".so" } +foreach ($file in $files) { + if ($env:universalBinary -eq 'true') { + $name = $file.Name + lipo -create "$file" "build_arm64/plugins/imageformats/$name" -output "$outputDir/$name" + lipo -info "$outputDir/$name" + } else { + Copy-Item -Path $file -Destination $outputDir + } } -cd .. diff --git a/pwsh/buildkarchive.ps1 b/pwsh/buildkarchive.ps1 index e5e62b4..465b9a0 100755 --- a/pwsh/buildkarchive.ps1 +++ b/pwsh/buildkarchive.ps1 @@ -8,6 +8,8 @@ git checkout $args[0] if ($IsWindows) { if ([Environment]::Is64BitOperatingSystem -and ($env:forceWin32 -ne 'true')) { $env:VCPKG_DEFAULT_TRIPLET = "x64-windows" + } else { + $env:VCPKG_DEFAULT_TRIPLET = "x86-windows" } # vcvars on windows & "$env:GITHUB_WORKSPACE\pwsh\vcvars.ps1" diff --git a/pwsh/buildkimageformats.ps1 b/pwsh/buildkimageformats.ps1 index 479789a..85132e3 100755 --- a/pwsh/buildkimageformats.ps1 +++ b/pwsh/buildkimageformats.ps1 @@ -1,6 +1,6 @@ -/usr/bin/env pwsh +#!/usr/bin/env pwsh -$kde_vers = 'v5.108.0' +$kde_vers = 'v5.116.0' # Clone git clone https://invent.kde.org/frameworks/kimageformats.git @@ -27,17 +27,7 @@ if ($IsWindows) { & "$env:GITHUB_WORKSPACE/pwsh/buildecm.ps1" $kde_vers & "$env:GITHUB_WORKSPACE/pwsh/get-vcpkg-deps.ps1" - -if ($env:forceWin32 -ne 'true') { - & "$env:GITHUB_WORKSPACE/pwsh/buildkarchive.ps1" $kde_vers -} - -# HEIF not necessary on macOS since it ships with HEIF support -if ($IsMacOS) { - $heifOn = "OFF" -} else { - $heifOn = "ON" -} +& "$env:GITHUB_WORKSPACE/pwsh/buildkarchive.ps1" $kde_vers if ((qmake --version -split '\n')[1][17] -eq '6') { $qt6flag = "-DBUILD_WITH_QT6=ON" @@ -49,7 +39,7 @@ if (-Not $IsWindows) { } # Build kimageformats -cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/installed" -DKIMAGEFORMATS_JXL=ON -DKIMAGEFORMATS_HEIF=$heifOn $qt6flag -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" . +cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/installed" -DKIMAGEFORMATS_JXL=ON -DKIMAGEFORMATS_HEIF=ON $qt6flag -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" . ninja ninja install @@ -69,7 +59,7 @@ if ($env:universalBinary) { $env:KF5Archive_DIR = $env:KF5Archive_DIR_ARM - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/installed_arm64" -DKIMAGEFORMATS_JXL=ON -DKIMAGEFORMATS_HEIF=$heifOn $qt6flag -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="arm64-osx" -DCMAKE_OSX_ARCHITECTURES="arm64" . + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$PWD/installed_arm64" -DKIMAGEFORMATS_JXL=ON -DKIMAGEFORMATS_HEIF=ON $qt6flag -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="arm64-osx" -DCMAKE_OSX_ARCHITECTURES="arm64" . ninja ninja install @@ -125,3 +115,7 @@ if ($IsMacOS) { } } +if ($IsWindows) { + Write-Host "`nDetecting plugin dependencies..." + & "$env:GITHUB_WORKSPACE/pwsh/scankimgdeps.ps1" $prefix_out +} diff --git a/pwsh/get-vcpkg-deps.ps1 b/pwsh/get-vcpkg-deps.ps1 index 25e3a3f..226ca53 100755 --- a/pwsh/get-vcpkg-deps.ps1 +++ b/pwsh/get-vcpkg-deps.ps1 @@ -47,16 +47,10 @@ if ($IsWindows) { } else { $vcpkgexec = "vcpkg" } -& "$env:VCPKG_ROOT/$vcpkgexec" install --keep-going libjxl libavif openexr zlib libraw - - -# No point to building libheif on mac since Qt has built-in support for HEIF on macOS. Also, this avoids CI problems. -if (-Not $IsMacOS) { - & "$env:VCPKG_ROOT/$vcpkgexec" install libheif -} +& "$env:VCPKG_ROOT/$vcpkgexec" install --keep-going libjxl libavif[aom] libheif openexr zlib libraw # Build arm64-osx dependencies separately--we'll have to combine stuff later. if ($env:universalBinary) { - & "$env:VCPKG_ROOT/$vcpkgexec" install --keep-going libjxl:arm64-osx libavif:arm64-osx openexr:arm64-osx zlib:arm64-osx libraw:arm64-osx + & "$env:VCPKG_ROOT/$vcpkgexec" install --keep-going libjxl:arm64-osx libavif[aom]:arm64-osx libheif:arm64-osx openexr:arm64-osx zlib:arm64-osx libraw:arm64-osx } diff --git a/pwsh/scankimgdeps.ps1 b/pwsh/scankimgdeps.ps1 new file mode 100644 index 0000000..00946dc --- /dev/null +++ b/pwsh/scankimgdeps.ps1 @@ -0,0 +1,63 @@ +param( + $dir +) + +function GetDeps($dllPath) { + # Run dumpbin with /DEPENDENTS option + $output = & dumpbin.exe /NOLOGO /DEPENDENTS $dllPath + + # Directory of the input DLL + $inputDir = Split-Path -Path $dllPath + + # Parse the output and filter existing DLLs in the same directory as the input DLL + $dependencies = $output | + Where-Object { $_ -match '^\s+.+\.dll$' } | + ForEach-Object { + $dllName = $_.Trim() + $fullDllPath = Join-Path -Path $inputDir -ChildPath $dllName + if (Test-Path $fullDllPath) { + $dllName + } + } + + return $dependencies +} + +function GetNestedDeps($dllPath) { + $visited = [System.Collections.Generic.HashSet[string]]::new() + $queue = [System.Collections.Generic.Queue[string]]::new() + + [void]$visited.Add($dllPath) + $queue.Enqueue($dllPath) + + while ($queue.Count -gt 0) { + $currentDll = $queue.Dequeue() + $deps = GetDeps $currentDll + + foreach ($dep in $deps) { + $fullDepPath = Join-Path (Split-Path $currentDll) $dep + if (-not $visited.Contains($fullDepPath)) { + [void]$visited.Add($fullDepPath) + $queue.Enqueue($fullDepPath) + } + } + } + + # Return all collected dependencies, excluding the initial input + return $visited | Where-Object { $_ -ne $dllPath } | ForEach-Object { Split-Path $_ -Leaf } | Sort-Object +} + +# Loop through DLL files starting with "kimg_" in the specified directory in alphabetical order +Get-ChildItem -Path $dir -Filter "kimg_*.dll" | + Sort-Object Name | + ForEach-Object { + $dllName = $_.Name + $deps = GetNestedDeps $_.FullName + + # Check if any dependencies were found and output appropriately + if ($deps.Count -gt 0) { + # Joining dependency names to pass as an array + $depList = $deps -join '", "' + Write-Output "$dllName`: `"$depList`"" + } + } diff --git a/util/kimageformats-find-libraw-vcpkg.patch b/util/kimageformats-find-libraw-vcpkg.patch index 0040313..2f6a004 100644 --- a/util/kimageformats-find-libraw-vcpkg.patch +++ b/util/kimageformats-find-libraw-vcpkg.patch @@ -1,6 +1,6 @@ --- kimageformats/CMakeLists.txt 2023-08-05 16:14:58 +++ CMakeLists.txt 2023-08-05 16:14:49 -@@ -71,11 +71,20 @@ +@@ -74,11 +74,15 @@ add_feature_info(LibJXL LibJXL_FOUND "required for the QImage plugin for JPEG XL images") # note: module FindLibRaw missing from https://invent.kde.org/frameworks/extra-cmake-modules @@ -12,11 +12,6 @@ TYPE OPTIONAL PURPOSE "Required for the QImage plugin for RAW images" ) -+# Horrific hack to fix the include path... -+get_property(include TARGET libraw::raw PROPERTY INTERFACE_INCLUDE_DIRECTORIES) -+cmake_path(REPLACE_FILENAME include "include/libraw") -+set_property(TARGET libraw::raw PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${include}) -+ +# Adapt naming so the rest of the cmake infra finds this new target +add_library(LibRaw::LibRaw ALIAS libraw::raw) +set(LibRaw_FOUND ${libraw_FOUND})