Skip to content

Commit

Permalink
Merge pull request #3 from jdpurcell/update1
Browse files Browse the repository at this point in the history
Various updates / fixes
  • Loading branch information
jurplel authored Jun 4, 2024
2 parents 956fe76 + 358ac85 commit 10d9220
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 61 deletions.
34 changes: 22 additions & 12 deletions .github/workflows/QtApng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,41 +22,51 @@ 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 }}

- name: Build QtApng
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/[email protected]
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
28 changes: 18 additions & 10 deletions .github/workflows/kimageformats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 }}
Expand All @@ -49,24 +49,32 @@ 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
env:
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/[email protected]
with:
type: 'zip'
path: kimageformats/output/
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
41 changes: 31 additions & 10 deletions pwsh/buildapng.ps1
Original file line number Diff line number Diff line change
@@ -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 ..
2 changes: 2 additions & 0 deletions pwsh/buildkarchive.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 9 additions & 15 deletions pwsh/buildkimageformats.ps1
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -125,3 +115,7 @@ if ($IsMacOS) {
}
}

if ($IsWindows) {
Write-Host "`nDetecting plugin dependencies..."
& "$env:GITHUB_WORKSPACE/pwsh/scankimgdeps.ps1" $prefix_out
}
10 changes: 2 additions & 8 deletions pwsh/get-vcpkg-deps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

63 changes: 63 additions & 0 deletions pwsh/scankimgdeps.ps1
Original file line number Diff line number Diff line change
@@ -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`""
}
}
7 changes: 1 addition & 6 deletions util/kimageformats-find-libraw-vcpkg.patch
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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})
Expand Down

0 comments on commit 10d9220

Please sign in to comment.