From 544af892dd3093f351c27e02bb0bbe67291027ba Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 14:19:01 +0200 Subject: [PATCH 01/18] build: update actions --- .github/workflows/publish.yml | 22 +++++++++++----------- .github/workflows/~dotnet.yml | 14 +++++++------- .github/workflows/~java.yml | 20 ++++++++++---------- .github/workflows/~native.yml | 20 ++++++++++---------- .github/workflows/~node.yml | 16 ++++++++-------- .github/workflows/~reusable-full-build.yml | 4 ++-- 6 files changed, 48 insertions(+), 48 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c061de4..5162f7c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,12 +28,12 @@ jobs: env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: nupkgs path: dist/.organize/nupkgs @@ -50,16 +50,16 @@ jobs: SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} steps: - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: # workaround until we know how to upload existing maven packages # https://discuss.gradle.org/t/how-to-push-maven-to-ossrh-from-previous-local-publish/46875 @@ -74,16 +74,16 @@ jobs: env: NPMJS_AUTH_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }} steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: nodetars path: dist/.organize/node - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: "lts/*" registry-url: https://registry.npmjs.org/ diff --git a/.github/workflows/~dotnet.yml b/.github/workflows/~dotnet.yml index cbf150b..698a4d4 100644 --- a/.github/workflows/~dotnet.yml +++ b/.github/workflows/~dotnet.yml @@ -22,16 +22,16 @@ jobs: - uses: actions/setup-dotnet@v4 with: dotnet-version: '8' - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: dist/.organize - run: ./build.cmd DotNet - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nupkgs path: | @@ -59,13 +59,13 @@ jobs: - uses: actions/setup-dotnet@v4 with: dotnet-version: '8' - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nupkgs path: dist/.organize/nupkgs - run: ./build.cmd DotNetTest --architecture ${{ matrix.architecture }} --framework ${{ matrix.framework }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: dotnettest-${{ matrix.runs-on }}-${{ matrix.architecture }}--${{ matrix.framework }} diff --git a/.github/workflows/~java.yml b/.github/workflows/~java.yml index 94fb880..9381ab3 100644 --- a/.github/workflows/~java.yml +++ b/.github/workflows/~java.yml @@ -24,20 +24,20 @@ jobs: SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} steps: - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: dist/.organize - run: ./build.cmd Java - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: maven path: | @@ -53,21 +53,21 @@ jobs: runs-on: ${{ matrix.runs-on }} needs: [java] steps: - - uses: actions/setup-java@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: maven path: dist/.organize/maven - run: ./build.cmd JavaTest - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: javatest-${{ matrix.runs-on }} diff --git a/.github/workflows/~native.yml b/.github/workflows/~native.yml index d3c6282..dd6c65a 100644 --- a/.github/workflows/~native.yml +++ b/.github/workflows/~native.yml @@ -49,16 +49,16 @@ jobs: architecture: ${{ fromJson( inputs.architectures ) }} steps: - name: Cloning Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Fetching Pre-Built Nuke - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - name: Fetch Cached LibSkia - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 if: ${{ inputs.use-skia-cache }} with: path: dist @@ -70,13 +70,13 @@ jobs: id: build - name: Uploading LibSkia to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: libskia-${{ inputs.target-os }}-${{ matrix.architecture }}-static path: artifacts - name: Uploading LibSkia to Build Cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: ${{ steps.build.outputs.build-skipped != 'true' }} with: path: dist @@ -93,18 +93,18 @@ jobs: variant: ${{ fromJson( inputs.variants ) }} steps: - name: Cloning Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - name: Fetching Pre-Built Nuke - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - name: Downloading LibSkia - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: dist/.organize/libskia-${{ inputs.target-os }}-${{ matrix.architecture }}-static name: libskia-${{ inputs.target-os }}-${{ matrix.architecture }}-static @@ -113,14 +113,14 @@ jobs: run: dotnet build/bin/Debug/publish/_build.dll LibAlphaSkia LibAlphaSkiaTest --target-os ${{ inputs.target-os }} --architecture ${{ matrix.architecture }} --variant ${{ matrix.variant }} - name: Uploading LibAlphaSkia to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: libalphaskia-${{ inputs.target-os }}-${{ matrix.architecture }}-${{ matrix.variant }} path: artifacts - name: Uploading LibAlphaSkiaTest to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: libalphaskiatest-${{ inputs.target-os }}-${{ matrix.architecture }}-${{ matrix.variant }} diff --git a/.github/workflows/~node.yml b/.github/workflows/~node.yml index 34c8cbc..d95da92 100644 --- a/.github/workflows/~node.yml +++ b/.github/workflows/~node.yml @@ -19,16 +19,16 @@ jobs: node: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: path: dist/.organize - run: ./build.cmd Node - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nodetars path: | @@ -42,12 +42,12 @@ jobs: runs-on: ${{ matrix.runs-on }} needs: [node] steps: - - uses: actions/checkout@v3 - - uses: actions/download-artifact@v3 + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 with: name: nodetars path: dist/.organize/node - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node }} - run: ./build.cmd NodeTest @@ -55,7 +55,7 @@ jobs: if: always() run: echo "NODE_VERSION=${{ matrix.node }}" | sed 's/[*\/]//g' >> "$GITHUB_OUTPUT" shell: bash - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: always() with: name: nodetest-${{ matrix.runs-on }}-${{ steps.sanitize-node-version.outputs.NODE_VERSION }} diff --git a/.github/workflows/~reusable-full-build.yml b/.github/workflows/~reusable-full-build.yml index 17ab81a..1ba1cd5 100644 --- a/.github/workflows/~reusable-full-build.yml +++ b/.github/workflows/~reusable-full-build.yml @@ -25,9 +25,9 @@ jobs: nuke: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - run: dotnet publish ./build/_build.csproj - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: nuke path: build/bin/Debug/publish/ From 74b158ed9c9f915cc5e60878a1d1ea50aa8bf788 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 14:22:40 +0200 Subject: [PATCH 02/18] build: bump .net --- .github/workflows/build.yml | 5 +++++ .github/workflows/publish.yml | 9 +++++++++ .github/workflows/~dotnet.yml | 10 +++++----- .github/workflows/~java.yml | 8 +++++++- .github/workflows/~native.yml | 6 ++++++ .github/workflows/~node.yml | 6 ++++++ .github/workflows/~reusable-full-build.yml | 5 ++++- build/_build.csproj | 2 +- test/dotnet/AlphaSkia.Test/AlphaSkia.Test.csproj | 2 +- test/test-generator/TestGenerator.csproj | 2 +- 10 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6051571..a4212c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,9 @@ on: + push: + branches: + - develop + - main + pull_request: workflow_dispatch: inputs: use-skia-cache: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5162f7c..9553411 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,6 +28,9 @@ jobs: env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: @@ -50,6 +53,9 @@ jobs: SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/setup-java@v4 with: distribution: 'temurin' @@ -74,6 +80,9 @@ jobs: env: NPMJS_AUTH_TOKEN: ${{ secrets.NPMJS_AUTH_TOKEN }} steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/~dotnet.yml b/.github/workflows/~dotnet.yml index 698a4d4..720d9c8 100644 --- a/.github/workflows/~dotnet.yml +++ b/.github/workflows/~dotnet.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8' + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: @@ -43,13 +43,13 @@ jobs: include: - runs-on: ubuntu-latest architecture: x64 - framework: net8.0 + framework: net9.0 - runs-on: macos-latest architecture: arm64 - framework: net8.0 + framework: net9.0 - runs-on: windows-latest architecture: x64 - framework: net8.0 + framework: net9.0 - runs-on: windows-latest architecture: x64 framework: net48 @@ -58,7 +58,7 @@ jobs: steps: - uses: actions/setup-dotnet@v4 with: - dotnet-version: '8' + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/~java.yml b/.github/workflows/~java.yml index 9381ab3..e141491 100644 --- a/.github/workflows/~java.yml +++ b/.github/workflows/~java.yml @@ -27,7 +27,10 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: '17' + java-version: '17' + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: @@ -57,6 +60,9 @@ jobs: with: distribution: 'temurin' java-version: '17' + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/~native.yml b/.github/workflows/~native.yml index dd6c65a..db85439 100644 --- a/.github/workflows/~native.yml +++ b/.github/workflows/~native.yml @@ -48,6 +48,9 @@ jobs: matrix: architecture: ${{ fromJson( inputs.architectures ) }} steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - name: Cloning Repository uses: actions/checkout@v4 @@ -92,6 +95,9 @@ jobs: architecture: ${{ fromJson( inputs.architectures ) }} variant: ${{ fromJson( inputs.variants ) }} steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - name: Cloning Repository uses: actions/checkout@v4 with: diff --git a/.github/workflows/~node.yml b/.github/workflows/~node.yml index d95da92..e8337e3 100644 --- a/.github/workflows/~node.yml +++ b/.github/workflows/~node.yml @@ -19,6 +19,9 @@ jobs: node: runs-on: ubuntu-latest steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: @@ -42,6 +45,9 @@ jobs: runs-on: ${{ matrix.runs-on }} needs: [node] steps: + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: diff --git a/.github/workflows/~reusable-full-build.yml b/.github/workflows/~reusable-full-build.yml index 1ba1cd5..dff923f 100644 --- a/.github/workflows/~reusable-full-build.yml +++ b/.github/workflows/~reusable-full-build.yml @@ -26,7 +26,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: dotnet publish ./build/_build.csproj + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: '9' + - run: dotnet publish --configuration Debug ./build/_build.csproj - uses: actions/upload-artifact@v4 with: name: nuke diff --git a/build/_build.csproj b/build/_build.csproj index 3dba0c1..2a3f2c8 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net9.0 CS0649;CS0169;CA1050;CA1822;CA2211;IDE1006 .. diff --git a/test/dotnet/AlphaSkia.Test/AlphaSkia.Test.csproj b/test/dotnet/AlphaSkia.Test/AlphaSkia.Test.csproj index 0763b58..bb68c1c 100644 --- a/test/dotnet/AlphaSkia.Test/AlphaSkia.Test.csproj +++ b/test/dotnet/AlphaSkia.Test/AlphaSkia.Test.csproj @@ -2,7 +2,7 @@ Exe - net8.0;net48 + net9.0;net48 enable enable 10 diff --git a/test/test-generator/TestGenerator.csproj b/test/test-generator/TestGenerator.csproj index a332342..b31e373 100644 --- a/test/test-generator/TestGenerator.csproj +++ b/test/test-generator/TestGenerator.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net9.0 enable enable From 7313e98bc1e9a4955ba0e70f55de3cd1599a7727 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 15:07:30 +0200 Subject: [PATCH 03/18] chore: Update skia to latest --- .gitmodules | 2 +- externals/depot_tools | 2 +- externals/skia | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index faf3653..412c801 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,7 @@ [submodule "externals/skia"] path = externals/skia url = https://skia.googlesource.com/skia.git - branch = chrome/m120 + branch = chrome/m135 [submodule "externals/node-api-headers"] path = externals/node-api-headers url = https://github.com/nodejs/node-api-headers.git diff --git a/externals/depot_tools b/externals/depot_tools index d7ba85d..f6cb81e 160000 --- a/externals/depot_tools +++ b/externals/depot_tools @@ -1 +1 @@ -Subproject commit d7ba85d1eb584a97e905aab180fe290f29c5a29a +Subproject commit f6cb81eb4fff49ff5a4f32b31b87caf44b24b4ce diff --git a/externals/skia b/externals/skia index 349c117..5a44cdd 160000 --- a/externals/skia +++ b/externals/skia @@ -1 +1 @@ -Subproject commit 349c1179c43ef46f2804404952b9460dc007d76a +Subproject commit 5a44cdd70f04aa65fa063caa1a7e3028d75236f8 From 10f37e657944704c0e4f1d06e5181551269b618d Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 15:07:55 +0200 Subject: [PATCH 04/18] build: disable autobuild not sure whats going on with GHA, builds gets stuck --- .github/workflows/build.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a4212c7..6051571 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,4 @@ on: - push: - branches: - - develop - - main - pull_request: workflow_dispatch: inputs: use-skia-cache: From 2a6a064362550f73a393e40df7fc87e88bc76bcc Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 15:09:15 +0200 Subject: [PATCH 05/18] build: use matching ubuntu ports for ubuntu-latest --- build/Build.Linux.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 6b3dd4f..391b325 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -49,13 +49,13 @@ partial class Build installDependencies.AppendLine($"echo Adding new {linuxArch} sources"); installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ jammy main multiverse universe' >> /etc/apt/sources.list"); + $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble main multiverse universe' >> /etc/apt/sources.list"); installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ jammy-security main multiverse universe' >> /etc/apt/sources.list"); + $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-security main multiverse universe' >> /etc/apt/sources.list"); installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main multiverse universe' >> /etc/apt/sources.list"); + $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main multiverse universe' >> /etc/apt/sources.list"); installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main multiverse universe' >> /etc/apt/sources.list"); + $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main multiverse universe' >> /etc/apt/sources.list"); } else { From 76959193c1594b7f8c060b29e7de377fe86a975f Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sat, 19 Apr 2025 15:36:10 +0200 Subject: [PATCH 06/18] build: Update Skia patching and Linux APT --- build/Build.LibAlphaSkia.cs | 3 +- build/Build.LibSkia.cs | 59 +++------------- build/Build.Linux.cs | 76 +++++++++++++++------ wrapper/include/SkFontMgr_alphaskia.h | 3 + wrapper/src/SkFontMgr_alphaskia.cpp | 16 ++++- wrapper/src/SkFontMgr_alphaskia_factory.cpp | 6 -- wrapper/src/alphaskia_canvas.cpp | 8 +-- wrapper/src/alphaskia_typeface.cpp | 10 ++- 8 files changed, 94 insertions(+), 87 deletions(-) delete mode 100644 wrapper/src/SkFontMgr_alphaskia_factory.cpp diff --git a/build/Build.LibAlphaSkia.cs b/build/Build.LibAlphaSkia.cs index ecd1a76..438aec8 100644 --- a/build/Build.LibAlphaSkia.cs +++ b/build/Build.LibAlphaSkia.cs @@ -530,7 +530,8 @@ AbsolutePath DownloadNodeLib() // https://nodejs.org/dist/latest/win-x64/node.lib // https://nodejs.org/dist/latest/win-x86/node.lib // https://nodejs.org/dist/latest/win-arm64/node.lib - var url = $"https://nodejs.org/dist/latest/{TargetOs.RuntimeIdentifier}-{Architecture}/node.lib"; + // NOTE: Node v23 has no win-x86 either, remove in future: https://github.com/nodejs/node/issues/42543 + var url = $"https://nodejs.org/dist/v22.9.0/{TargetOs.RuntimeIdentifier}-{Architecture}/node.lib"; var libDir = TemporaryDirectory / $"libnode-{TargetOs.RuntimeIdentifier}-{Architecture}"; HttpTasks.HttpDownloadFile(url, libDir / "node.lib"); diff --git a/build/Build.LibSkia.cs b/build/Build.LibSkia.cs index d03f00d..84f984e 100644 --- a/build/Build.LibSkia.cs +++ b/build/Build.LibSkia.cs @@ -150,30 +150,15 @@ partial class Build newSources += " ]\n"; // ensure we have the OS specific font managers available newSources += " if (is_win) {\n"; - newSources += " sources += [\n"; - newSources += " \"include/ports/SkFontMgr_indirect.h\",\n"; - newSources += " \"include/ports/SkRemotableFontMgr.h\",\n"; - newSources += " \"src/fonts/SkFontMgr_indirect.cpp\",\n"; - newSources += " \"src/ports/SkFontMgr_win_dw.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_win_dw.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_win_dw.h\",\n"; - newSources += " \"src/ports/SkTypeface_win_dw.cpp\",\n"; - newSources += " \"src/ports/SkTypeface_win_dw.h\",\n"; - newSources += " ]\n"; + newSources += " sources += skia_ports_windows_fonts_sources\n"; newSources += " }\n"; newSources += " if (is_linux) {\n"; newSources += " public_deps += [ \"//third_party:fontconfig\" ]\n"; - newSources += " sources += [\n"; - newSources += " \"src/ports/SkFontMgr_fontconfig.cpp\",\n"; - newSources += " ]\n"; + newSources += " sources += skia_ports_fontmgr_fontconfig_sources\n"; newSources += " }\n"; newSources += " if (is_android) {\n"; newSources += " deps += [ \"//third_party/expat\" ]\n"; - newSources += " sources += [\n"; - newSources += " \"src/ports/SkFontMgr_android.cpp\",\n"; - newSources += " \"src/ports/SkFontMgr_android_parser.cpp\",\n"; - newSources += " \"src/ports/SkFontMgr_android_parser.h\",\n"; - newSources += " ]\n"; + newSources += " sources += skia_ports_fontmgr_android_sources\n"; newSources += " }\n"; newSources += " frameworks = []\n"; newSources += " if (is_mac) {\n"; @@ -181,13 +166,7 @@ partial class Build newSources += " \"AppKit.framework\",\n"; newSources += " \"ApplicationServices.framework\",\n"; newSources += " ]\n"; - newSources += " sources += [\n"; - newSources += " \"src/ports/SkFontMgr_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_mac_ct.h\",\n"; - newSources += " \"src/ports/SkTypeface_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkTypeface_mac_ct.h\",\n"; - newSources += " ]\n"; + newSources += " sources += skia_ports_fontmgr_coretext_sources\n"; newSources += " }\n"; newSources += " if (is_ios) {\n"; newSources += " frameworks += [\n"; @@ -196,32 +175,14 @@ partial class Build newSources += " \"CoreText.framework\",\n"; newSources += " \"UIKit.framework\",\n"; newSources += " ]\n"; - newSources += " sources += [\n"; - newSources += " \"src/ports/SkFontMgr_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkScalerContext_mac_ct.h\",\n"; - newSources += " \"src/ports/SkTypeface_mac_ct.cpp\",\n"; - newSources += " \"src/ports/SkTypeface_mac_ct.h\",\n"; - newSources += " ]\n"; + newSources += " sources += skia_ports_fontmgr_coretext_sources\n"; newSources += " }\n"; newSources += " "; - - buildFileSource = buildFileSource[..sourcesEnd] - + newSources - + buildFileSource[sourcesEnd..]; - } - - const string emptyFactoryFile = " sources = [ \"src/ports/SkFontMgr_empty_factory.cpp\" ]"; - var emptyFactoryIndex = buildFileSource.IndexOf(emptyFactoryFile); - if(emptyFactoryIndex >= 0) - { - var newSources = " sources = [\n"; - newSources += " \"../../wrapper/src/SkFontMgr_alphaskia_factory.cpp\",\n"; + newSources += " sources += [\n"; newSources += " \"../../wrapper/src/SkFontMgr_alphaskia.cpp\",\n"; newSources += " \"../../wrapper/include/SkFontMgr_alphaskia.h\",\n"; newSources += " ]\n"; - newSources += " public = [ \"../../wrapper/include/SkFontMgr_alphaskia.h\" ]"; - newSources += " defines = []\n"; + newSources += " public += [ \"../../wrapper/include/SkFontMgr_alphaskia.h\" ]"; newSources += " if (is_win) {\n"; newSources += " defines += [ \"ALPHASKIA_FONTMGR_WINDOWS\" ]\n"; newSources += " }\n"; @@ -238,9 +199,9 @@ partial class Build newSources += " defines += [ \"ALPHASKIA_FONTMGR_IOS\" ]\n"; newSources += " }\n"; - buildFileSource = buildFileSource[..emptyFactoryIndex] - + newSources - + buildFileSource[(emptyFactoryIndex + emptyFactoryFile.Length)..]; + buildFileSource = buildFileSource[..sourcesEnd] + + newSources + + buildFileSource[sourcesEnd..]; } buildFile.WriteAllText(buildFileSource); diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 391b325..074ee93 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -6,12 +6,13 @@ using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; +using Serilog; partial class Build { Target InstallDependenciesLinux => _ => _ .Unlisted() - .OnlyWhenStatic(()=> OperatingSystem.IsLinux() && IsGitHubActions) + .OnlyWhenStatic(() => OperatingSystem.IsLinux() && IsGitHubActions) .After(PrepareGitHubArtifacts, LibAlphaSkiaGitSyncDeps, LibAlphaSkiaPatchSkiaBuildFiles, LibSkiaGitSyncDeps, LibSkiaPatchSkiaBuildFiles) @@ -39,29 +40,64 @@ partial class Build installDependencies.AppendLine($"echo Adding Arch {linuxArch}"); installDependencies.AppendLine($"dpkg --add-architecture {linuxArch}"); - installDependencies.AppendLine("echo Modifying sources.list"); - installDependencies.AppendLine("sed -i \"s/deb /deb [arch=amd64,i386] /\" /etc/apt/sources.list"); - installDependencies.AppendLine( - "sed -i \"s/deb-src /deb-src [arch=amd64,i386] /\" /etc/apt/sources.list"); + // NOTE: This happens within Nuke, not in the shell script + // https://github.com/actions/runner-images/issues/10901 + var ubuntu24Sources = TemporaryDirectory / "ubuntu.sources"; + ubuntu24Sources.WriteAllText( + """ + Types: deb + URIs: http://archive.ubuntu.com/ubuntu/ + Suites: noble + Components: main restricted universe + Architectures: amd64,i386 + + Types: deb + URIs: http://security.ubuntu.com/ubuntu/ + Suites: noble-security + Components: main restricted universe + Architectures: amd64,i386 + + Types: deb + URIs: http://archive.ubuntu.com/ubuntu/ + Suites: noble-updates + Components: main restricted universe + Architectures: amd64,i386 + """ + ); if (Architecture == Architecture.Arm || Architecture == Architecture.Arm64) { - installDependencies.AppendLine($"echo Adding new {linuxArch} sources"); - - installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble main multiverse universe' >> /etc/apt/sources.list"); - installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-security main multiverse universe' >> /etc/apt/sources.list"); - installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-backports main multiverse universe' >> /etc/apt/sources.list"); - installDependencies.AppendLine( - $"echo 'deb [arch={linuxArch}] http://ports.ubuntu.com/ubuntu-ports/ noble-updates main multiverse universe' >> /etc/apt/sources.list"); - } - else - { - installDependencies.AppendLine($"echo No additional package sources for {linuxArch}"); + ubuntu24Sources.AppendAllText(content: + $""" + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble + Components: main restricted multiverse universe + Architectures: {linuxArch} + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-security + Components: main restricted multiverse universe + Architectures: {linuxArch} + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-backports + Components: main restricted multiverse universe + Architectures: {linuxArch} + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-updates + Components: main restricted multiverse universe + Architectures: {linuxArch} + """ + ); } + installDependencies.AppendLine("echo Updating APT sources"); + installDependencies.AppendLine($"mv {ubuntu24Sources} /etc/apt/sources.list.d/ubuntu.sources"); installDependencies.AppendLine("echo Updating Packages"); installDependencies.AppendLine("apt-get update"); installDependencies.AppendLine("echo Installing main build tools"); @@ -79,6 +115,8 @@ partial class Build installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); + installDependencies.AppendLine( + $"aptitude install -y libfontconfig-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); diff --git a/wrapper/include/SkFontMgr_alphaskia.h b/wrapper/include/SkFontMgr_alphaskia.h index 87784e4..b1eeccf 100644 --- a/wrapper/include/SkFontMgr_alphaskia.h +++ b/wrapper/include/SkFontMgr_alphaskia.h @@ -10,6 +10,8 @@ class SK_API SkFontMgr_AlphaSkia : public SkFontMgr void switch_to_operating_system_fonts(); void switch_to_freetype_fonts(); + static sk_sp instance(); + protected: int onCountFamilies() const override; void onGetFamilyName(int index, SkString *familyName) const override; @@ -26,6 +28,7 @@ class SK_API SkFontMgr_AlphaSkia : public SkFontMgr sk_sp onMakeFromFile(const char path[], int ttcIndex) const override; sk_sp onLegacyMakeTypeface(const char familyName[], SkFontStyle style) const override; + private: sk_sp currentFontMgr_; sk_sp freeTypeFontMgr_; diff --git a/wrapper/src/SkFontMgr_alphaskia.cpp b/wrapper/src/SkFontMgr_alphaskia.cpp index 8dc723a..adb989a 100644 --- a/wrapper/src/SkFontMgr_alphaskia.cpp +++ b/wrapper/src/SkFontMgr_alphaskia.cpp @@ -25,6 +25,16 @@ #error "Unsupported operating system - extend font mgr" #endif +sk_sp SkFontMgr_AlphaSkia::instance() +{ + static SkOnce once; + static sk_sp singleton; + + once([] + { singleton = std::move(sk_make_sp()); }); + return singleton; +} + SkFontMgr_AlphaSkia::SkFontMgr_AlphaSkia() { operatingSystemTypeFontMgr_ = CREATE_OPERATING_SYSTEM_FONTMGR; @@ -65,14 +75,14 @@ sk_sp SkFontMgr_AlphaSkia::onMatchFamily(const char familyName[] } sk_sp SkFontMgr_AlphaSkia::onMatchFamilyStyle(const char familyName[], - const SkFontStyle &fontStyle) const + const SkFontStyle &fontStyle) const { return currentFontMgr_->matchFamilyStyle(familyName, fontStyle); } sk_sp SkFontMgr_AlphaSkia::onMatchFamilyStyleCharacter(const char familyName[], const SkFontStyle &style, - const char *bcp47[], int bcp47Count, - SkUnichar character) const + const char *bcp47[], int bcp47Count, + SkUnichar character) const { return currentFontMgr_->matchFamilyStyleCharacter(familyName, style, bcp47, bcp47Count, character); } diff --git a/wrapper/src/SkFontMgr_alphaskia_factory.cpp b/wrapper/src/SkFontMgr_alphaskia_factory.cpp deleted file mode 100644 index dc02a1f..0000000 --- a/wrapper/src/SkFontMgr_alphaskia_factory.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "../include/SkFontMgr_alphaskia.h" - -sk_sp SkFontMgr::Factory() -{ - return sk_make_sp(); -} diff --git a/wrapper/src/alphaskia_canvas.cpp b/wrapper/src/alphaskia_canvas.cpp index d120635..85d90b6 100644 --- a/wrapper/src/alphaskia_canvas.cpp +++ b/wrapper/src/alphaskia_canvas.cpp @@ -20,16 +20,12 @@ extern "C" AS_API void alphaskia_switch_to_freetype_fonts() { - sk_sp fm = SkFontMgr::RefDefault(); - SkFontMgr_AlphaSkia *afm = reinterpret_cast(fm.get()); - afm->switch_to_freetype_fonts(); + SkFontMgr_AlphaSkia::instance()->switch_to_freetype_fonts(); } AS_API void alphaskia_switch_to_operating_system_fonts() { - sk_sp fm = SkFontMgr::RefDefault(); - SkFontMgr_AlphaSkia *afm = reinterpret_cast(fm.get()); - afm->switch_to_operating_system_fonts(); + SkFontMgr_AlphaSkia::instance()->switch_to_operating_system_fonts(); } AS_API int32_t alphaskia_get_color_type() diff --git a/wrapper/src/alphaskia_typeface.cpp b/wrapper/src/alphaskia_typeface.cpp index 7e0d914..d40c7a5 100644 --- a/wrapper/src/alphaskia_typeface.cpp +++ b/wrapper/src/alphaskia_typeface.cpp @@ -1,4 +1,5 @@ #include "../include/alphaskia.h" +#include "../include/SkFontMgr_alphaskia.h" #include "../../externals/skia/include/core/SkTypeface.h" #include "../../externals/skia/include/core/SkData.h" @@ -7,7 +8,8 @@ extern "C" AS_API alphaskia_typeface_t alphaskia_typeface_register(alphaskia_data_t data) { sk_sp *skData = reinterpret_cast *>(data); - sk_sp skTypeface = SkTypeface::MakeFromData(*skData, 0); + auto fontMgr = SkFontMgr_AlphaSkia::instance(); + sk_sp skTypeface = fontMgr->makeFromData(*skData, 0); if (!skTypeface) { return nullptr; @@ -29,10 +31,12 @@ extern "C" AS_API alphaskia_typeface_t alphaskia_typeface_make_from_name(const char *family_name, uint8_t bold, uint8_t italic) { + auto fontMgr = SkFontMgr_AlphaSkia::instance(); + SkFontStyle style(bold ? SkFontStyle::kBold_Weight : SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, italic ? SkFontStyle::kItalic_Slant : SkFontStyle::kUpright_Slant); - sk_sp skTypeface = SkTypeface::MakeFromName(family_name, style); + sk_sp skTypeface = fontMgr->legacyMakeTypeface(family_name, style); if (!skTypeface) { @@ -46,7 +50,7 @@ extern "C" { sk_sp *skTypeface = reinterpret_cast *>(typeface); - SkString* skFamilyName = new SkString(); + SkString *skFamilyName = new SkString(); (*skTypeface)->getFamilyName(skFamilyName); return reinterpret_cast(skFamilyName); From 6b1b226e991ae9f7af04bbf199d7f3c379014127 Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 22:21:24 +0200 Subject: [PATCH 07/18] Update Build.Linux.cs --- build/Build.Linux.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 074ee93..03ac828 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -116,7 +116,9 @@ partial class Build installDependencies.AppendLine( $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev"); + $"aptitude install -y libfontconfig-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev tree"); + installDependencies.AppendLine("tree /usr/aarch64-linux-gnu/include"); + installDependencies.AppendLine("tree /usr/include/"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); @@ -157,4 +159,4 @@ void SetClangLinux(Dictionary gnArgs) AppendToFlagList(gnArgs, "extra_cflags", $"{init}, {bin}, {includes}"); } } -} \ No newline at end of file +} From 19e0700142b8f21dbada4755e434b68f48581911 Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:00:17 +0200 Subject: [PATCH 08/18] Update Build.Linux.cs --- build/Build.Linux.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 03ac828..6c15832 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -114,11 +114,7 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); - installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev tree"); - installDependencies.AppendLine("tree /usr/aarch64-linux-gnu/include"); - installDependencies.AppendLine("tree /usr/include/"); + $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libexpat1-dev{linuxArchSuffix} libfreetype-dev{linuxArchSuffix} uuid-dev{linuxArchSuffix}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From da6237c483c35308fe6e2dc9dfa4fb6054d2087c Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:14:10 +0200 Subject: [PATCH 09/18] Update Build.Linux.cs --- build/Build.Linux.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 6c15832..35eb1a2 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -100,6 +100,7 @@ partial class Build installDependencies.AppendLine($"mv {ubuntu24Sources} /etc/apt/sources.list.d/ubuntu.sources"); installDependencies.AppendLine("echo Updating Packages"); installDependencies.AppendLine("apt-get update"); + installDependencies.AppendLine("apt --fix-broken install"); installDependencies.AppendLine("echo Installing main build tools"); installDependencies.AppendLine( $"aptitude install -y crossbuild-essential-{linuxArch} libstdc++-11-dev-{linuxArch}-cross"); @@ -114,8 +115,10 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libexpat1-dev{linuxArchSuffix} libfreetype-dev{linuxArchSuffix} uuid-dev{linuxArchSuffix}"); - + $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); + installDependencies.AppendLine( + $"apt --fix-broken install libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); + var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); ToolResolver.GetPathTool("sudo")($"bash {scriptFile}"); From 854cc963064f01731f60ef4abc0df39f38179804 Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:19:32 +0200 Subject: [PATCH 10/18] Update Build.Linux.cs --- build/Build.Linux.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 35eb1a2..cd195db 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -115,9 +115,9 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); + $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); installDependencies.AppendLine( - $"apt --fix-broken install libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix}"); + $"apt --fix-broken install libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From 63bdc2af89cf6b8200d9bc0f1433f9a3651b29db Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:26:16 +0200 Subject: [PATCH 11/18] Update Build.Linux.cs --- build/Build.Linux.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index cd195db..663be29 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -115,9 +115,7 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"aptitude install -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); - installDependencies.AppendLine( - $"apt --fix-broken install libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); + $"aptitude install -y build-essential{linuxArchSuffix} libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From a44b4534ba968940bda094e61518925e2c92217f Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:32:23 +0200 Subject: [PATCH 12/18] Update Build.Linux.cs --- build/Build.Linux.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 663be29..f992588 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -28,8 +28,6 @@ partial class Build // conflicts easier installDependencies.AppendLine("echo Install Aptitude"); installDependencies.AppendLine("apt-get update"); - installDependencies.AppendLine("apt-get install -y aptitude"); - // Main system build tools installDependencies.AppendLine("apt-get install -y build-essential"); @@ -100,10 +98,9 @@ partial class Build installDependencies.AppendLine($"mv {ubuntu24Sources} /etc/apt/sources.list.d/ubuntu.sources"); installDependencies.AppendLine("echo Updating Packages"); installDependencies.AppendLine("apt-get update"); - installDependencies.AppendLine("apt --fix-broken install"); installDependencies.AppendLine("echo Installing main build tools"); installDependencies.AppendLine( - $"aptitude install -y crossbuild-essential-{linuxArch} libstdc++-11-dev-{linuxArch}-cross"); + $"apt-get install -f -y crossbuild-essential-{linuxArch} libstdc++-11-dev-{linuxArch}-cross"); } else { @@ -115,7 +112,7 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"aptitude install -y build-essential{linuxArchSuffix} libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); + $"apt-get install -f -y build-essential{linuxArchSuffix} libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From 6496c6dde3d45227cf1b8b135623cc3f58d549c3 Mon Sep 17 00:00:00 2001 From: Daniel Kuschny Date: Sun, 20 Apr 2025 23:39:42 +0200 Subject: [PATCH 13/18] Update Build.Linux.cs --- build/Build.Linux.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index f992588..8ad48c0 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -112,7 +112,7 @@ partial class Build var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); installDependencies.AppendLine( - $"apt-get install -f -y build-essential{linuxArchSuffix} libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); + $"apt-get install -f -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From a218f35ef793b692b6b426ce45a24746adca1e48 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Mon, 21 Apr 2025 14:57:12 +0200 Subject: [PATCH 14/18] build: Simplify package installation --- build/Build.Linux.cs | 55 +++++++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 14 deletions(-) diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 8ad48c0..88b245b 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -23,13 +23,10 @@ partial class Build installDependencies.AppendLine("#!/bin/bash"); installDependencies.AppendLine("set -e"); - // Using aptitude here because github actions runners have quite some packages preinstalled - // which leads to many version conflicts after adding more sources. aptitude can resolve those - // conflicts easier - installDependencies.AppendLine("echo Install Aptitude"); - installDependencies.AppendLine("apt-get update"); - // Main system build tools - installDependencies.AppendLine("apt-get install -y build-essential"); + var packages = new List + { + "build-essential" + }; // Cross compilation build tools if needed var linuxArch = Architecture.LinuxArch; @@ -60,6 +57,30 @@ partial class Build Suites: noble-updates Components: main restricted universe Architectures: amd64,i386 + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble + Components: main restricted multiverse universe + Architectures: arm64,armhf + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-security + Components: main restricted multiverse universe + Architectures: arm64,armhf + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-backports + Components: main restricted multiverse universe + Architectures: arm64,armhf + + Types: deb + URIs: http://ports.ubuntu.com/ubuntu-ports/ + Suites: noble-updates + Components: main restricted multiverse universe + Architectures: arm64,armhf """ ); @@ -96,11 +117,9 @@ partial class Build installDependencies.AppendLine("echo Updating APT sources"); installDependencies.AppendLine($"mv {ubuntu24Sources} /etc/apt/sources.list.d/ubuntu.sources"); - installDependencies.AppendLine("echo Updating Packages"); - installDependencies.AppendLine("apt-get update"); - installDependencies.AppendLine("echo Installing main build tools"); - installDependencies.AppendLine( - $"apt-get install -f -y crossbuild-essential-{linuxArch} libstdc++-11-dev-{linuxArch}-cross"); + + packages.Add($"crossbuild-essential-{linuxArch}"); + packages.Add($"libstdc++-11-dev-{linuxArch}-cross"); } else { @@ -108,11 +127,19 @@ partial class Build linuxArch = ""; } + + // dependent libraries var linuxArchSuffix = string.IsNullOrEmpty(linuxArch) ? "" : $":{linuxArch}"; installDependencies.AppendLine("echo Installing libs"); - installDependencies.AppendLine( - $"apt-get install -f -y libfontconfig-dev{linuxArchSuffix} libgl1-mesa-dev{linuxArchSuffix} libglu1-mesa-dev{linuxArchSuffix} freeglut3-dev{linuxArchSuffix} libc6-dev{linuxArchSuffix} linux-libc-dev{linuxArchSuffix}"); + + packages.Add($"libfontconfig-dev{linuxArchSuffix}"); + packages.Add($"libgl1-mesa-dev{linuxArchSuffix}"); + packages.Add($"libglu1-mesa-dev{linuxArchSuffix}"); + packages.Add($"freeglut3-dev{linuxArchSuffix}"); + + installDependencies.AppendLine("apt-get update"); + installDependencies.AppendLine($"apt-get install -y {string.Join(" ", packages)}"); var scriptFile = TemporaryDirectory / "install_dependencies.sh"; File.WriteAllText(scriptFile, installDependencies.ToString()); From b0f8cb45d67edb7ef4d45243cdc495576bd49497 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Mon, 21 Apr 2025 15:37:35 +0200 Subject: [PATCH 15/18] build: update nuke --- build/Architecture.cs | 2 +- build/Build.DotNet.cs | 32 +-- build/Build.Java.cs | 74 ++++--- build/Build.LibAlphaSkia.cs | 363 ++++++++++++++++---------------- build/Build.LibSkia.cs | 43 ++-- build/Build.Linux.cs | 3 +- build/Build.MacOs.cs | 9 +- build/Build.Native.cs | 12 +- build/Build.Node.cs | 60 +++--- build/Build.cs | 45 ++-- build/Configuration.cs | 14 -- build/TargetOperatingSystem.cs | 1 - build/_build.csproj | 2 +- build/_build.csproj.DotSettings | 5 +- 14 files changed, 340 insertions(+), 325 deletions(-) delete mode 100644 build/Configuration.cs diff --git a/build/Architecture.cs b/build/Architecture.cs index b186e94..cf133d0 100644 --- a/build/Architecture.cs +++ b/build/Architecture.cs @@ -9,7 +9,7 @@ public class Architecture : Enumeration public static readonly Architecture X64 = new() { Value = "x64", LinuxArch = "amd64", LinuxCrossToolchain = "", LinuxCrossTargetArch = "" }; - public static Architecture X86 = new() + public static readonly Architecture X86 = new() { Value = "x86", LinuxArch = "i386", LinuxCrossToolchain = "i686-linux-gnu", LinuxCrossTargetArch = "i686-linux-gnu" diff --git a/build/Build.DotNet.cs b/build/Build.DotNet.cs index ab40606..c5af7fc 100644 --- a/build/Build.DotNet.cs +++ b/build/Build.DotNet.cs @@ -1,5 +1,5 @@ +using JetBrains.Annotations; using Nuke.Common; -using Nuke.Common.CI.GitHubActions; using Nuke.Common.IO; using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; @@ -8,10 +8,12 @@ partial class Build { - public Target DotNet => _ => _ + [PublicAPI] + public Target DotNet => t => t .DependsOn(DotNetPack); - public Target DotNetPack => _ => _ + [PublicAPI] + public Target DotNetPack => t => t .Unlisted() .DependsOn(DotNetBuild) .Executes(() => @@ -24,7 +26,7 @@ partial class Build .DeleteFiles(); } - DotNetTasks.DotNetPack(_ => _ + DotNetTasks.DotNetPack(t => t .SetProcessWorkingDirectory(RootDirectory / "lib" / "dotnet") .SetConfiguration("Release") ); @@ -38,21 +40,23 @@ partial class Build foreach (var nupkg in (RootDirectory / "lib" / "dotnet").GetFiles("*.nupkg", int.MaxValue)) { - FileSystemTasks.CopyFile(nupkg, + nupkg.Copy( RootDirectory / "dist" / "nupkgs" / nupkg.Name, - FileExistsPolicy.OverwriteIfNewer); + ExistsPolicy.MergeAndOverwriteIfNewer + ); } } }); - public Target DotNetBuild => _ => _ + [PublicAPI] + public Target DotNetBuild => t => t .Unlisted() .DependsOn(PrepareGitHubArtifacts) .Executes(() => { DotNetWriteVersionInfoProps(); - DotNetTasks.DotNetBuild(_ => _ + DotNetTasks.DotNetBuild(t => t .SetProcessWorkingDirectory(RootDirectory / "lib" / "dotnet") .SetConfiguration("Release") .SetForce(Rebuild) @@ -98,13 +102,13 @@ void DotNetWriteVersionInfoProps() [Parameter] string Framework; - public Target DotNetTest => _ => _ + public Target DotNetTest => t => t .DependsOn(PrepareGitHubArtifacts) .Requires(() => Framework) .Executes(() => { Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (OS fonts)"); - DotNetTasks.DotNetRun(_ => _ + DotNetTasks.DotNetRun(t => t .SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test") .SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" + (Architecture ?? Architecture.Current)) @@ -113,7 +117,7 @@ void DotNetWriteVersionInfoProps() ); Log.Information($"Running DotNet tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (FreeType fonts)"); - DotNetTasks.DotNetRun(_ => _ + DotNetTasks.DotNetRun(t => t .SetProcessWorkingDirectory(RootDirectory / "test" / "dotnet" / "AlphaSkia.Test") .SetRuntime(TargetOperatingSystem.Current.DotNetRid + "-" + (Architecture ?? Architecture.Current)) @@ -125,17 +129,17 @@ void DotNetWriteVersionInfoProps() [Parameter] [Secret] readonly string NugetApiKey = GetVariable("NUGET_API_KEY"); - public Target DotNetPublish => _ => _ + public Target DotNetPublish => t => t .DependsOn(PrepareGitHubArtifacts) .Requires(() => IsGitHubActions) .Executes(() => { - DotNetTasks.DotNetNuGetPush(_ => _ + DotNetTasks.DotNetNuGetPush(t => t .SetSource("https://api.nuget.org/v3/index.json") .SetApiKey(NugetApiKey) .CombineWith( (DistBasePath / "nupkgs").GlobFiles("*.nupkg") - , (_, v) => _ + , (s, v) => s .SetTargetPath(v))); }); } \ No newline at end of file diff --git a/build/Build.Java.cs b/build/Build.Java.cs index 1edc07b..2723722 100644 --- a/build/Build.Java.cs +++ b/build/Build.Java.cs @@ -1,3 +1,5 @@ +using System.Collections.Generic; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; @@ -11,14 +13,17 @@ partial class Build readonly AbsolutePath GradlewExe = GetVariable("GRADLEW_EXE") ?? RootDirectory / "lib" / "java" / $"gradlew{ScriptExtension}"; - [Parameter] readonly AbsolutePath JavaHome = GetVariable("JAVA_HOME") ?? GetVariable("JAVA_HOME_17_X64"); + [Parameter] + readonly AbsolutePath JavaHome = GetVariable("JAVA_HOME") ?? GetVariable("JAVA_HOME_17_X64"); Tool GradlewTool => ToolResolver.GetTool(GradlewExe); - public Target Java => _ => _ + [PublicAPI] + public Target Java => t => t .DependsOn(JavaPack); - public Target JavaPack => _ => _ + [PublicAPI] + public Target JavaPack => t => t .DependsOn(JavaBuild) .Executes(() => { @@ -36,14 +41,17 @@ partial class Build (RootDirectory / "dist" / "maven").DeleteDirectory(); } - FileSystemTasks.CopyDirectoryRecursively(RootDirectory / "lib" / "java" / "dist", - RootDirectory / "dist" / "maven", - DirectoryExistsPolicy.Merge, FileExistsPolicy.OverwriteIfNewer); + (RootDirectory / "lib" / "java" / "dist") + .Copy( + RootDirectory / "dist" / "maven", + ExistsPolicy.MergeAndOverwriteIfNewer + ); } }); - public Target JavaBuild => _ => _ + [PublicAPI] + public Target JavaBuild => t => t .DependsOn(PrepareGitHubArtifacts) .Executes(JavaBuildInternal); @@ -63,35 +71,36 @@ void JavaBuildInternal() } GradlewTool("build", - environmentVariables: Variables + environmentVariables: Variables .ToDictionary(x => x.Key, x => x.Value) .SetKeyValue("JAVA_HOME", JavaHome) .AsReadOnly(), workingDirectory: RootDirectory / "lib" / "java"); } - public Target JavaTest => _ => _ + public Target JavaTest => t => t .DependsOn(PrepareGitHubArtifacts) .Executes(() => { - Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (OS fonts)", JavaHome, JavaVersion); + Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (OS fonts)", JavaHome, + JavaVersion); GradlewTool("run", - environmentVariables: Variables + environmentVariables: Variables .ToDictionary(x => x.Key, x => x.Value) .SetKeyValue("JAVA_HOME", JavaHome) .SetKeyValue("ALPHASKIA_TEST_VERSION", JavaVersion) .AsReadOnly(), workingDirectory: RootDirectory / "test" / "java"); - - Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (FreeType fonts)", JavaHome, JavaVersion); + + Log.Information("Testing with Java at {JavaHome} and version {AlphaSkiaTestVersion} (FreeType fonts)", + JavaHome, JavaVersion); GradlewTool("run --args=--freetype", - environmentVariables: Variables + environmentVariables: Variables .ToDictionary(x => x.Key, x => x.Value) .SetKeyValue("JAVA_HOME", JavaHome) .SetKeyValue("ALPHASKIA_TEST_VERSION", JavaVersion) .AsReadOnly(), workingDirectory: RootDirectory / "test" / "java"); - }); void JavaWriteVersionInfoProperties() @@ -99,19 +108,19 @@ void JavaWriteVersionInfoProperties() var semVer = JavaVersion; var props = $""" - alphaskiaDescription={VersionInfo.Description} - alphaskiaAuthorId={VersionInfo.AuthorId} - alphaskiaAuthorName={VersionInfo.AuthorName} - alphaskiaOrgUrl={VersionInfo.OrgUrl} - alphaskiaCompany={VersionInfo.Company} - alphaskiaVersion={semVer} - alphaskiaProjectUrl={VersionInfo.ProjectUrl} - alphaskiaGitUrlHttp={VersionInfo.GitUrlHttp} - alphaskiaGitUrlGit"={VersionInfo.GitUrlGit} - alphaskiaLicenseSpdx={VersionInfo.LicenseSpdx} - alphaskiaLicenseUrl={VersionInfo.LicenseUrl} - alphaskiaIssuesUrl={VersionInfo.IssuesUrl} - """; + alphaskiaDescription={VersionInfo.Description} + alphaskiaAuthorId={VersionInfo.AuthorId} + alphaskiaAuthorName={VersionInfo.AuthorName} + alphaskiaOrgUrl={VersionInfo.OrgUrl} + alphaskiaCompany={VersionInfo.Company} + alphaskiaVersion={semVer} + alphaskiaProjectUrl={VersionInfo.ProjectUrl} + alphaskiaGitUrlHttp={VersionInfo.GitUrlHttp} + alphaskiaGitUrlGit"={VersionInfo.GitUrlGit} + alphaskiaLicenseSpdx={VersionInfo.LicenseSpdx} + alphaskiaLicenseUrl={VersionInfo.LicenseUrl} + alphaskiaIssuesUrl={VersionInfo.IssuesUrl} + """; (RootDirectory / "lib" / "java" / "local.properties").WriteAllText(props); } @@ -132,18 +141,19 @@ string JavaVersion { semVer = $"{VersionInfo.FileVersion.ToString(3)}-SNAPSHOT"; } + return semVer; } } - - public Target JavaPublish => _ => _ + + public Target JavaPublish => t => t .DependsOn(PrepareGitHubArtifacts) .Executes(() => { // workaround until we know how to upload existing maven packages // https://discuss.gradle.org/t/how-to-push-maven-to-ossrh-from-previous-local-publish/46875 JavaBuildInternal(); - + GradlewTool("publishMavenJavaPublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository", environmentVariables: Variables .ToDictionary(x => x.Key, x => x.Value) @@ -151,4 +161,4 @@ string JavaVersion .AsReadOnly(), workingDirectory: RootDirectory / "lib" / "java"); }); -} +} \ No newline at end of file diff --git a/build/Build.LibAlphaSkia.cs b/build/Build.LibAlphaSkia.cs index 438aec8..591f43c 100644 --- a/build/Build.LibAlphaSkia.cs +++ b/build/Build.LibAlphaSkia.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Text; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; @@ -10,36 +11,39 @@ partial class Build { - public Target LibAlphaSkiaGitSyncDeps => _ => _ + private static readonly string[] RequiredDependencies = + [ + "buildtools", + "third_party/externals/harfbuzz" + ]; + + [PublicAPI] + public Target LibAlphaSkiaGitSyncDeps => t => t .Unlisted() .DependsOn(SetupDepotTools) - .Executes(() => - { - var requiredDependencies = new[] - { - "buildtools", - "third_party/externals/harfbuzz" - }; - - return GitSyncDepsCustom(requiredDependencies); - }); + .Executes(() => GitSyncDepsCustom(RequiredDependencies)); - public Target LibAlphaSkia => _ => _ - .DependsOn(PrepareGitHubArtifacts, LibAlphaSkiaGitSyncDeps, LibAlphaSkiaPatchSkiaBuildFiles, InstallDependenciesLinux) + [PublicAPI] + public Target LibAlphaSkia => t => t + .DependsOn(PrepareGitHubArtifacts, LibAlphaSkiaGitSyncDeps, LibAlphaSkiaPatchSkiaBuildFiles, + InstallDependenciesLinux) .Requires(() => Architecture) .Requires(() => Variant) .Requires(() => TargetOs) .Executes(BuildAlphaSkia); - public Target LibAlphaSkiaTest => _ => _ - .DependsOn(PrepareGitHubArtifacts, LibAlphaSkiaGitSyncDeps, LibAlphaSkiaPatchSkiaBuildFiles, InstallDependenciesLinux) + [PublicAPI] + public Target LibAlphaSkiaTest => t => t + .DependsOn(PrepareGitHubArtifacts, LibAlphaSkiaGitSyncDeps, LibAlphaSkiaPatchSkiaBuildFiles, + InstallDependenciesLinux) .After(LibAlphaSkia) .Requires(() => Architecture) .OnlyWhenStatic(() => Variant == Variant.Shared) .Requires(() => TargetOs) .Executes(BuildAlphaSkiaTest); - public Target LibAlphaSkiaPatchSkiaBuildFiles => _ => _ + [PublicAPI] + public Target LibAlphaSkiaPatchSkiaBuildFiles => t => t .Unlisted() .Executes(() => { @@ -47,143 +51,143 @@ partial class Build // and build through that, instead of setting up the whole configuration on our own. // this way we get the same compile settings and platform support const string buildConfigNew = """ - declare_args() { - is_shared_alphaskia = true - } - template("alphaskia_build") { - _alphaskia_mode = "shared_library" - if (!is_shared_alphaskia) { - _alphaskia_mode = "static_library" - } - - target(_alphaskia_mode, target_name) { - forward_variables_from(invoker, "*") - } - } - template("alphaskia_executable") { - _alphaskia_mode = "executable" - target(_alphaskia_mode, target_name) { - forward_variables_from(invoker, "*") - } - } - set_defaults("alphaskia_build") { - configs = default_configs - if (!is_shared_alphaskia) { - complete_static_lib = true - } - } - """; + declare_args() { + is_shared_alphaskia = true + } + template("alphaskia_build") { + _alphaskia_mode = "shared_library" + if (!is_shared_alphaskia) { + _alphaskia_mode = "static_library" + } + + target(_alphaskia_mode, target_name) { + forward_variables_from(invoker, "*") + } + } + template("alphaskia_executable") { + _alphaskia_mode = "executable" + target(_alphaskia_mode, target_name) { + forward_variables_from(invoker, "*") + } + } + set_defaults("alphaskia_build") { + configs = default_configs + if (!is_shared_alphaskia) { + complete_static_lib = true + } + } + """; PatchSkiaFile(SkiaPath / "gn" / "BUILDCONFIG.gn", buildConfigNew, "BuildConfig", "#"); const string buildNew = """ - alphaskia_wrapper_sources = [ - "../../wrapper/src/AlphaSkiaCanvas.cpp", - "../../wrapper/src/alphaskia_canvas.cpp", - "../../wrapper/src/alphaskia_image.cpp", - "../../wrapper/src/alphaskia_typeface.cpp", - "../../wrapper/src/alphaskia_data.cpp", - "../../wrapper/src/alphaskia_string.cpp" - ] - if (is_win) { - alphaskia_wrapper_sources += [ "../../wrapper/src/alphaskia.rc" ] - } - config("alphaskia_public") { - defines = [ "_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING", "ALPHASKIA_IMPLEMENTATION=1" ] - include_dirs = [ "." ] - - - if (is_shared_alphaskia) { - defines += [ "ALPHASKIA_DLL" ] - } - - if (is_win) { - libs = [ "skia.lib", "user32.lib", "OpenGL32.lib", "alphaskia.rc.obj" ] - } - - if (is_linux) { - libs = [ "skia", "fontconfig" ] - } - - if (is_android) { - libs = [ "skia" ] - } - - if (is_mac) { - libs = [ "skia" ] - - frameworks = [ - "AppKit.framework", - "ApplicationServices.framework", - - "OpenGL.framework", - - "Metal.framework", - "Foundation.framework" - ] - } - - if (is_ios) { - libs = [ "skia" ] - - frameworks = [ - "Foundation.framework", - "CoreFoundation.framework", - "CoreGraphics.framework", - "CoreText.framework", - "ImageIO.framework", - "MobileCoreServices.framework", - - "Metal.framework", - "UIKit.framework" - ] - } - } - - alphaskia_build("libalphaskia") { - public_configs = [ ":alphaskia_public" ] - configs += [ ":alphaskia_public" ] - sources = alphaskia_wrapper_sources - } - alphaskia_build("libalphaskiajni") { - public_configs = [ ":alphaskia_public" ] - configs += [ ":alphaskia_public" ] - sources = alphaskia_wrapper_sources - sources += [ - "../../lib/java/jni/src/AlphaSkiaCanvas.cpp", - "../../lib/java/jni/src/AlphaSkiaData.cpp", - "../../lib/java/jni/src/AlphaSkiaImage.cpp", - "../../lib/java/jni/src/AlphaSkiaTypeface.cpp" - ] - } - alphaskia_build("libalphaskianode") { - public_configs = [ ":alphaskia_public" ] - configs += [ ":alphaskia_public" ] - defines = [ "NODE_GYP_MODULE_NAME=libalphaskianode", "USING_UV_SHARED=1", "USING_V8_SHARED=1", "V8_DEPRECATION_WARNINGS=1", "BUILDING_NODE_EXTENSION" ] - sources = alphaskia_wrapper_sources - output_extension = "node" - sources += [ - "../../lib/node/addon/addon.cpp" - ] - if( is_win ) { - sources += [ "../../lib/node/addon/win_delay_load_hook.cpp"] - } - } - - alphaskia_executable("libalphaskiatest") { - sources = [ - "../../test/native/src/AlphaSkiaTestBridge.cpp", - "../../test/native/src/AlphaTabGeneratedTest.cpp", - "../../test/native/src/main.cpp", - "../../test/native/src/PixelMatch.cpp" - ] - if (is_win) { - libs = [ "libalphaskia.dll.lib" ] - } - else { - libs = [ "alphaskia" ] - } - } - """; + alphaskia_wrapper_sources = [ + "../../wrapper/src/AlphaSkiaCanvas.cpp", + "../../wrapper/src/alphaskia_canvas.cpp", + "../../wrapper/src/alphaskia_image.cpp", + "../../wrapper/src/alphaskia_typeface.cpp", + "../../wrapper/src/alphaskia_data.cpp", + "../../wrapper/src/alphaskia_string.cpp" + ] + if (is_win) { + alphaskia_wrapper_sources += [ "../../wrapper/src/alphaskia.rc" ] + } + config("alphaskia_public") { + defines = [ "_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING", "ALPHASKIA_IMPLEMENTATION=1" ] + include_dirs = [ "." ] + + + if (is_shared_alphaskia) { + defines += [ "ALPHASKIA_DLL" ] + } + + if (is_win) { + libs = [ "skia.lib", "user32.lib", "OpenGL32.lib", "alphaskia.rc.obj" ] + } + + if (is_linux) { + libs = [ "skia", "fontconfig" ] + } + + if (is_android) { + libs = [ "skia" ] + } + + if (is_mac) { + libs = [ "skia" ] + + frameworks = [ + "AppKit.framework", + "ApplicationServices.framework", + + "OpenGL.framework", + + "Metal.framework", + "Foundation.framework" + ] + } + + if (is_ios) { + libs = [ "skia" ] + + frameworks = [ + "Foundation.framework", + "CoreFoundation.framework", + "CoreGraphics.framework", + "CoreText.framework", + "ImageIO.framework", + "MobileCoreServices.framework", + + "Metal.framework", + "UIKit.framework" + ] + } + } + + alphaskia_build("libalphaskia") { + public_configs = [ ":alphaskia_public" ] + configs += [ ":alphaskia_public" ] + sources = alphaskia_wrapper_sources + } + alphaskia_build("libalphaskiajni") { + public_configs = [ ":alphaskia_public" ] + configs += [ ":alphaskia_public" ] + sources = alphaskia_wrapper_sources + sources += [ + "../../lib/java/jni/src/AlphaSkiaCanvas.cpp", + "../../lib/java/jni/src/AlphaSkiaData.cpp", + "../../lib/java/jni/src/AlphaSkiaImage.cpp", + "../../lib/java/jni/src/AlphaSkiaTypeface.cpp" + ] + } + alphaskia_build("libalphaskianode") { + public_configs = [ ":alphaskia_public" ] + configs += [ ":alphaskia_public" ] + defines = [ "NODE_GYP_MODULE_NAME=libalphaskianode", "USING_UV_SHARED=1", "USING_V8_SHARED=1", "V8_DEPRECATION_WARNINGS=1", "BUILDING_NODE_EXTENSION" ] + sources = alphaskia_wrapper_sources + output_extension = "node" + sources += [ + "../../lib/node/addon/addon.cpp" + ] + if( is_win ) { + sources += [ "../../lib/node/addon/win_delay_load_hook.cpp"] + } + } + + alphaskia_executable("libalphaskiatest") { + sources = [ + "../../test/native/src/AlphaSkiaTestBridge.cpp", + "../../test/native/src/AlphaTabGeneratedTest.cpp", + "../../test/native/src/main.cpp", + "../../test/native/src/PixelMatch.cpp" + ] + if (is_win) { + libs = [ "libalphaskia.dll.lib" ] + } + else { + libs = [ "alphaskia" ] + } + } + """; PatchSkiaFile(SkiaPath / "BUILD.gn", buildNew, "Build", "#"); PatchSkiaToolchain(); PatchSkiaMacOsVersion(); @@ -207,7 +211,7 @@ void PatchSkiaFile(AbsolutePath file, string newText, string patchName, string p { beforePatchIndex = findInsertOffset.Invoke(existingText); } - + if (beforePatchIndex == -1) { // not yet patched @@ -219,7 +223,8 @@ void PatchSkiaFile(AbsolutePath file, string newText, string patchName, string p if (afterPatchIndex == -1) { // corrupt patch (no end) or custom insert position - file.WriteAllText(existingText[..beforePatchIndex].TrimEnd() + newTextWithMarker + existingText[beforePatchIndex..]); + file.WriteAllText(existingText[..beforePatchIndex].TrimEnd() + newTextWithMarker + + existingText[beforePatchIndex..]); } else { @@ -264,7 +269,7 @@ void BuildAlphaSkia() { jniPlatformInclude = jniInclude / "darwin"; } - else if(TargetOs == TargetOperatingSystem.Android) + else if (TargetOs == TargetOperatingSystem.Android) { jniPlatformInclude = null; } @@ -273,14 +278,11 @@ void BuildAlphaSkia() throw new PlatformNotSupportedException(); } - if(jniPlatformInclude != null) - { - AppendToFlagList(gnArgs, "extra_cflags", $"'-I{alphaSkiaInclude}', '-I{jniInclude}', '-I{jniPlatformInclude}'"); - } - else - { - AppendToFlagList(gnArgs, "extra_cflags", $"'-I{alphaSkiaInclude}'"); - } + AppendToFlagList(gnArgs, "extra_cflags", + jniPlatformInclude != null + ? $"'-I{alphaSkiaInclude}', '-I{jniInclude}', '-I{jniPlatformInclude}'" + : $"'-I{alphaSkiaInclude}'" + ); } else if (Variant == Variant.Node) { @@ -353,11 +355,16 @@ void BuildAlphaSkia() void CopyBuildOutputTo(AbsolutePath path) { // libs - FileSystemTasks.CopyDirectoryRecursively(outDir, path, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer, null, file => !libExtensions.Contains(file.Extension)); + outDir.Copy(path, + ExistsPolicy.MergeAndOverwriteIfNewer, + null, + file => !libExtensions.Contains(file.Extension) + ); // copy header - FileSystemTasks.CopyFile(RootDirectory / "wrapper" / "include" / "alphaskia.h", - DistBasePath / "include" / "alphaskia" / "alphaskia.h", FileExistsPolicy.OverwriteIfNewer); + (RootDirectory / "wrapper" / "include" / "alphaskia.h").Copy( + DistBasePath / "include" / "alphaskia" / "alphaskia.h", + ExistsPolicy.MergeAndOverwriteIfNewer + ); } CopyBuildOutputTo(distPath); @@ -381,7 +388,7 @@ void BuildAlphaSkiaTest() Log.Information("Skipping build of BuildAlphaSkiaTest, not relevant for variant {Variant}", Variant); return; } - + var gnArgs = PrepareNativeBuild(Variant); var sharedLibPath = DistBasePath / GetLibDirectory("libalphaskia", variant: Variant); var gnFlags = new Dictionary(); @@ -394,15 +401,9 @@ void BuildAlphaSkiaTest() Log.Debug("Available libs for linking: " + string.Join(", ", sharedLibPath.GetFiles().Select(f => f.Name))); AppendToFlagList(gnArgs, "extra_cflags", $"'-DALPHASKIA_TEST_RID={TargetOs.RuntimeIdentifier}'"); - if (TargetOs == TargetOperatingSystem.Windows) - { - // TODO: check if clang-cl also works with the linux flags - AppendToFlagList(gnArgs, "extra_ldflags", $"'/LIBPATH:{sharedLibPath}'"); - } - else - { - AppendToFlagList(gnArgs, "extra_ldflags", $"'-L{sharedLibPath}'"); - } + // TODO: check if clang-cl also works with the linux flags + AppendToFlagList(gnArgs, "extra_ldflags", + TargetOs == TargetOperatingSystem.Windows ? $"'/LIBPATH:{sharedLibPath}'" : $"'-L{sharedLibPath}'"); var buildTarget = "libalphaskiatest"; var libDir = GetLibDirectory(buildTarget, TargetOs, Architecture, Variant); @@ -414,24 +415,26 @@ void BuildAlphaSkiaTest() // copy for artifacts var distPath = DistBasePath / libDir; var exePath = outDir / (buildTarget + exeExtension); - FileSystemTasks.CopyFile(exePath, distPath / exePath.Name, FileExistsPolicy.OverwriteIfNewer); + exePath.Copy(distPath / exePath.Name, ExistsPolicy.MergeAndOverwriteIfNewer); // copy shared lib beside executable var libExtensions = new HashSet(GetLibExtensions(Variant), StringComparer.OrdinalIgnoreCase); foreach (var file in sharedLibPath.GetFiles().Where(f => libExtensions.Contains(f.Extension))) { - FileSystemTasks.CopyFile(file, outDir / file.Name, FileExistsPolicy.OverwriteIfNewer); + file.Copy(outDir / file.Name, ExistsPolicy.MergeAndOverwriteIfNewer); } // run executable if (LibAlphaSkiaCanRunTests) { - Log.Information($"Running {TargetOs.RuntimeIdentifier}-{Architecture} tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (OS fonts)"); + Log.Information( + $"Running {TargetOs.RuntimeIdentifier}-{Architecture} tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (OS fonts)"); ToolResolver.GetTool(exePath)( "", workingDirectory: outDir ); - Log.Information($"Running {TargetOs.RuntimeIdentifier}-{Architecture} tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (FreeType fonts)"); + Log.Information( + $"Running {TargetOs.RuntimeIdentifier}-{Architecture} tests on {TargetOperatingSystem.Current.RuntimeIdentifier}-{Architecture.Current} host system (FreeType fonts)"); ToolResolver.GetTool(exePath)( "--freetype", workingDirectory: outDir @@ -444,7 +447,7 @@ void BuildAlphaSkiaTest() } } - public bool LibAlphaSkiaCanRunTests + bool LibAlphaSkiaCanRunTests { get { diff --git a/build/Build.LibSkia.cs b/build/Build.LibSkia.cs index 84f984e..b47b886 100644 --- a/build/Build.LibSkia.cs +++ b/build/Build.LibSkia.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.IO; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.IO; using Serilog; @@ -9,7 +10,8 @@ partial class Build { Lazy LibSkiaSkip => new(() => CanUseCachedBinaries("libskia", Variant.Static)); - public Target LibSkiaGitSyncDeps => _ => _ + [PublicAPI] + public Target LibSkiaGitSyncDeps => t => t .Unlisted() .OnlyWhenStatic(() => !LibSkiaSkip.Value) .DependsOn(SetupDepotTools) @@ -37,7 +39,7 @@ partial class Build return GitSyncDepsCustom(requiredDependencies); }); - public Target LibSkiaWithCache => _ => _ + public Target LibSkiaWithCache => t => t .Unlisted() .Requires(() => Architecture) .Requires(() => TargetOs) @@ -51,7 +53,7 @@ partial class Build if (File.Exists(outputsFile)) { File.AppendAllLines(outputsFile, - new[] { $"build-skipped={LibSkiaSkip.Value.ToString().ToLowerInvariant()}\n" }); + [$"build-skipped={LibSkiaSkip.Value.ToString().ToLowerInvariant()}\n"]); } else { @@ -61,8 +63,7 @@ partial class Build if (LibSkiaSkip.Value) { - FileSystemTasks.CopyDirectoryRecursively(DistBasePath, ArtifactBasePath, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer); + DistBasePath.Copy(ArtifactBasePath, ExistsPolicy.MergeAndOverwriteIfNewer); } else { @@ -71,14 +72,16 @@ partial class Build }) .Triggers(LibSkia); - public Target LibSkia => _ => _ + [PublicAPI] + public Target LibSkia => t => t .DependsOn(LibSkiaGitSyncDeps, LibSkiaPatchSkiaBuildFiles, InstallDependenciesLinux) .OnlyWhenStatic(() => !LibSkiaSkip.Value) .Requires(() => Architecture) .Requires(() => TargetOs) .Executes(BuildSkia); - public Target LibSkiaPatchSkiaBuildFiles => _ => _ + [PublicAPI] + public Target LibSkiaPatchSkiaBuildFiles => t => t .Unlisted() .OnlyWhenStatic(() => !LibSkiaSkip.Value) .After(LibSkiaGitSyncDeps) @@ -110,12 +113,12 @@ partial class Build var depsList = buildFileSource.Substring(depsListStart, depsListEnd - depsListStart); if (!depsList.Contains("//third_party/harfbuzz")) { - var newDepsList = depsList.TrimEnd('\r', '\n', '\t', ' ', ',') - + ", \"//third_party/harfbuzz\", \"//third_party/freetype2\", " - ; + var newDepsList = depsList.TrimEnd('\r', '\n', '\t', ' ', ',') + + ", \"//third_party/harfbuzz\", \"//third_party/freetype2\", " + ; buildFileSource = buildFileSource[..depsListStart] - + newDepsList - + buildFileSource[depsListEnd..]; + + newDepsList + + buildFileSource[depsListEnd..]; } var sourcesStartMarker = "sources = []"; @@ -200,8 +203,8 @@ partial class Build newSources += " }\n"; buildFileSource = buildFileSource[..sourcesEnd] - + newSources - + buildFileSource[sourcesEnd..]; + + newSources + + buildFileSource[sourcesEnd..]; } buildFile.WriteAllText(buildFileSource); @@ -217,10 +220,10 @@ void PatchVulcanAllocatorIncludes() var buildFile = SkiaPath / "third_party" / "externals" / "vulkanmemoryallocator" / "include" / "vk_mem_alloc.h"; var include = """ - #if VMA_STATS_STRING_ENABLED - #include // For snprintf - #endif - """; + #if VMA_STATS_STRING_ENABLED + #include // For snprintf + #endif + """; PatchSkiaFile(buildFile, include, "cstdio", "//", source => @@ -282,8 +285,8 @@ void BuildSkia() void CopyBuildOutputTo(AbsolutePath path) { // libs - FileSystemTasks.CopyDirectoryRecursively(outDir, path, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer, null, file => !libExtension.Contains(file.Extension)); + outDir.Copy(path, ExistsPolicy.MergeAndOverwriteIfNewer, null, + file => !libExtension.Contains(file.Extension)); } CopyBuildOutputTo(distPath); diff --git a/build/Build.Linux.cs b/build/Build.Linux.cs index 88b245b..53c49de 100644 --- a/build/Build.Linux.cs +++ b/build/Build.Linux.cs @@ -6,11 +6,10 @@ using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; -using Serilog; partial class Build { - Target InstallDependenciesLinux => _ => _ + Target InstallDependenciesLinux => t => t .Unlisted() .OnlyWhenStatic(() => OperatingSystem.IsLinux() && IsGitHubActions) .After(PrepareGitHubArtifacts, diff --git a/build/Build.MacOs.cs b/build/Build.MacOs.cs index 0500b43..7333507 100644 --- a/build/Build.MacOs.cs +++ b/build/Build.MacOs.cs @@ -5,14 +5,7 @@ partial class Build { void SetClangMacOs(Dictionary gnArgs) { - if (TargetOs == TargetOperatingSystem.MacOs) - { - AppendToFlagList(gnArgs, "extra_cflags", "'-DHAVE_ARC4RANDOM_BUF', '-stdlib=libc++'"); - } - else - { - AppendToFlagList(gnArgs, "extra_cflags", "'-DHAVE_ARC4RANDOM_BUF', '-stdlib=libc++'"); - } + AppendToFlagList(gnArgs, "extra_cflags", "'-DHAVE_ARC4RANDOM_BUF', '-stdlib=libc++'"); AppendToFlagList(gnArgs, "extra_ldflags", "'-stdlib=libc++'"); } diff --git a/build/Build.Native.cs b/build/Build.Native.cs index 8a584e5..42e8b3d 100644 --- a/build/Build.Native.cs +++ b/build/Build.Native.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; @@ -200,7 +201,8 @@ Dictionary ReadDepsData(TextReader reader) return deps; } - public Target SetupDepotTools => _ => _ + [PublicAPI] + public Target SetupDepotTools => t => t .Unlisted() .OnlyWhenStatic(() => !LibSkiaSkip.Value) .Executes(() => @@ -330,18 +332,18 @@ string[] GetLibExtensions(Variant variant) { if (variant == Variant.Node) { - return new[] { ".node" }; + return [".node"]; } if (TargetOs == TargetOperatingSystem.Windows) { - return variant.IsShared ? new[] { ".dll", ".lib" } : new[] { ".lib" }; + return variant.IsShared ? [".dll", ".lib"] : [".lib"]; } if (TargetOs == TargetOperatingSystem.Linux || TargetOs == TargetOperatingSystem.Android) { - return variant.IsShared ? new[] { ".so" } : new[] { ".a" }; + return variant.IsShared ? [".so"] : [".a"]; } @@ -349,7 +351,7 @@ string[] GetLibExtensions(Variant variant) TargetOs == TargetOperatingSystem.iOS || TargetOs == TargetOperatingSystem.iOSSimulator) { - return variant.IsShared ? new[] { ".dylib" } : new[] { ".a" }; + return variant.IsShared ? [".dylib"] : [".a"]; } throw new InvalidOperationException("Unhandled TargetOS: " + TargetOs); diff --git a/build/Build.Node.cs b/build/Build.Node.cs index 2299968..a35c95f 100644 --- a/build/Build.Node.cs +++ b/build/Build.Node.cs @@ -1,7 +1,9 @@ +using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Nodes; +using JetBrains.Annotations; using Nuke.Common; using Nuke.Common.IO; using Nuke.Common.Tooling; @@ -12,18 +14,20 @@ partial class Build { - public Target Node => _ => _ + [PublicAPI] + public Target Node => t => t .DependsOn(NodePack); - AbsolutePath[] AllNodePackages => new[] - { + AbsolutePath[] AllNodePackages => + [ RootDirectory / "lib" / "node" / "alphaskia", RootDirectory / "lib" / "node" / "alphaskia-windows", RootDirectory / "lib" / "node" / "alphaskia-linux", RootDirectory / "lib" / "node" / "alphaskia-macos" - }; + ]; - public Target NodePack => _ => _ + [PublicAPI] + public Target NodePack => t => t .Unlisted() .DependsOn(NodeBuild) .Executes(() => @@ -49,9 +53,7 @@ partial class Build foreach (var tgz in (RootDirectory / "lib" / "node").GetFiles("*.tgz", int.MaxValue)) { - FileSystemTasks.CopyFile(tgz, - RootDirectory / "dist" / "nodetars" / tgz.Name, - FileExistsPolicy.OverwriteIfNewer); + tgz.Copy(RootDirectory / "dist" / "nodetars" / tgz.Name, ExistsPolicy.MergeAndOverwriteIfNewer); } PrepareTgzForTest(); @@ -61,23 +63,24 @@ partial class Build void PrepareTgzForTest() { Log.Information("Preparing TGZ files for test by creating copy without version"); - var files = new System.Collections.Generic.List(); + var files = new List(); foreach (var tgz in (RootDirectory / "dist" / "nodetars").GetFiles("*.tgz")) { // coderline-alphaskia-2.3.0-local.0.tgz var nameWithoutVersion = string.Join("-", tgz.NameWithoutExtension.Split('-').TakeWhile(p => !char.IsDigit(p[0]))) + tgz.Extension; - FileSystemTasks.CopyFile(tgz, - RootDirectory / "dist" / "nodetars" / nameWithoutVersion, - FileExistsPolicy.OverwriteIfNewer); + + tgz.Copy(RootDirectory / "dist" / "nodetars" / nameWithoutVersion, + ExistsPolicy.MergeAndOverwriteIfNewer); files.Add(nameWithoutVersion); } Log.Information("Preparing TGZ files done {Files}", string.Join(", ", files)); } - public Target NodeBuild => _ => _ + [PublicAPI] + public Target NodeBuild => t => t .Unlisted() .DependsOn(PrepareGitHubArtifacts) .Executes(() => @@ -86,20 +89,20 @@ void PrepareTgzForTest() if (Rebuild) { - NpmTasks.NpmRun(_ => _ + NpmTasks.NpmRun(t => t .SetProcessWorkingDirectory(RootDirectory / "lib" / "node" / "alphaskia") .SetCommand("clean")); } foreach (var nodePackage in AllNodePackages) { - NpmTasks.NpmInstall(_ => - _.SetProcessWorkingDirectory(nodePackage)); + NpmTasks.NpmInstall(s => + s.SetProcessWorkingDirectory(nodePackage)); } CopyNodeAddonsToPackages(); - NpmTasks.NpmRun(_ => _ + NpmTasks.NpmRun(t => t .SetProcessWorkingDirectory(RootDirectory / "lib" / "node" / "alphaskia") .SetCommand("build")); }); @@ -157,7 +160,7 @@ void NodeWritePackageJson() } } - public Target NodeTest => _ => _ + public Target NodeTest => t => t .DependsOn(PrepareGitHubArtifacts) .Executes(() => { @@ -167,17 +170,17 @@ void NodeWritePackageJson() Log.Information("Deleting package-lock.json to avoid integrity checks failing"); (RootDirectory / "test" / "node" / "package-lock.json").DeleteFile(); - NpmTasks.NpmInstall(_ => _ + NpmTasks.NpmInstall(t => t .SetProcessWorkingDirectory(RootDirectory / "test" / "node") .SetForce(true)); - - Log.Information("Testing with Node with (OS fonts)", JavaHome, JavaVersion); - NpmTasks.NpmRun(_ => _ + + Log.Information("Testing with Node with (OS fonts)"); + NpmTasks.NpmRun(t => t .SetProcessWorkingDirectory(RootDirectory / "test" / "node") .SetCommand("start")); - - Log.Information("Testing with Node with (FreeType fonts)", JavaHome, JavaVersion); - NpmTasks.NpmRun(_ => _ + + Log.Information("Testing with Node with (FreeType fonts)"); + NpmTasks.NpmRun(t => t .SetProcessWorkingDirectory(RootDirectory / "test" / "node") .SetCommand("start") .SetArguments("--freetype")); @@ -211,15 +214,14 @@ void CopyNodeAddonsToPackages() continue; } - FileSystemTasks.CopyDirectoryRecursively(subDirectory, - RootDirectory / "lib" / "node" / packageName / "lib" / subDirectory.Name, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer, excludeFile: fi => fi.Extension != ".node"); + subDirectory.Copy(RootDirectory / "lib" / "node" / packageName / "lib" / subDirectory.Name, + ExistsPolicy.MergeAndOverwriteIfNewer, null, fi => fi.Extension != ".node"); } } [Parameter] [Secret] readonly string NpmjsAuthToken = GetVariable("NPMJS_AUTH_TOKEN"); - public Target NodePublish => _ => _ + public Target NodePublish => t => t .DependsOn(PrepareGitHubArtifacts) .Requires(() => IsGitHubActions) .Executes(() => diff --git a/build/Build.cs b/build/Build.cs index 107c86d..a198c19 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -23,7 +23,7 @@ static int LoadSkiaVersion() { throw new InvalidOperationException("Cannot load skia version before Nuke is initialized"); } - + var submodulesContent = NukeBuild.RootDirectory / ".gitmodules"; var text = submodulesContent.ReadAllText(); const string marker = "branch = chrome/m"; @@ -32,16 +32,18 @@ static int LoadSkiaVersion() { throw new IOException(".gitmodules does not contain the skia submodule branch"); } + var endOfMarker = text.IndexOf("\n", startOfMarker, StringComparison.Ordinal); return int.Parse(text[(startOfMarker + marker.Length)..endOfMarker].Trim()); } - static readonly Version FileVersionBase = GetVariable("ALPHASKIA_VERSION_TEMPLATE") ?? new Version(1, 0, 0, 0); + static readonly Version FileVersionBase = + GetVariable("ALPHASKIA_VERSION_TEMPLATE") ?? new Version(1, 0, 0, 0); #endregion public static Version FileVersion => - new (FileVersionBase.Major, FileVersionBase.Minor, SkiaVersion, BuildCounter); + new(FileVersionBase.Major, FileVersionBase.Minor, SkiaVersion, BuildCounter); public static readonly string Copyright = $"Copyright © {DateTime.Now.Year}, Daniel Kuschny"; public const string AuthorId = "danielku15"; @@ -67,7 +69,7 @@ partial class Build : NukeBuild [Parameter] readonly bool IsReleaseBuild = GetVariable("IS_RELEASE_BUILD") ?? false; [Parameter] readonly bool Rebuild; - + public static int Main() => Execute(); static void AppendToFlagList( @@ -97,7 +99,7 @@ static void AppendToFlagList( ".exe" }; - Target PrepareGitHubArtifacts => _ => _ + Target PrepareGitHubArtifacts => t => t .OnlyWhenStatic(() => IsGitHubActions) .Executes(() => { @@ -132,8 +134,10 @@ static void FlattenFolder(AbsolutePath subDir) // known include path if (subDir.Name == "include") { - FileSystemTasks.MoveDirectoryToDirectory(subDir, DistBasePath, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer); + subDir.MoveToDirectory( + DistBasePath, + ExistsPolicy.MergeAndOverwrite + ); Log.Debug(" Treated as header include dir"); return; } @@ -146,12 +150,14 @@ static void FlattenFolder(AbsolutePath subDir) { continue; } - + if (AllLibExtensions.Contains(file.Extension) || file.NameWithoutExtension == "libalphaskiatest") { // found a library or test executable dir - FileSystemTasks.MoveDirectoryToDirectory(subDir, DistBasePath, DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer); + subDir.MoveToDirectory( + DistBasePath, + ExistsPolicy.MergeAndOverwriteIfNewer + ); Log.Debug(" Treated as library dir"); return; } @@ -163,22 +169,27 @@ static void FlattenFolder(AbsolutePath subDir) var netDir = file / ".." / ".." / ".." / ".."; if (netDir.DirectoryExists() && netDir.Name == "net") { - FileSystemTasks.MoveDirectoryToDirectory(netDir.Parent, DistBasePath, - DirectoryExistsPolicy.Merge, - FileExistsPolicy.OverwriteIfNewer); + netDir.Parent.MoveToDirectory( + DistBasePath, + ExistsPolicy.MergeAndOverwriteIfNewer + ); return; } } else if (file.Extension is ".nupkg" or ".snupkg") { // flatten nugets - FileSystemTasks.MoveFileToDirectory(file, DistBasePath / "nupkgs", - FileExistsPolicy.OverwriteIfNewer); + file.MoveToDirectory( + DistBasePath / "nupkgs", + ExistsPolicy.MergeAndOverwriteIfNewer + ); } else if (file.Extension is ".tgz") { - FileSystemTasks.MoveFileToDirectory(file, DistBasePath / "nodetars", - FileExistsPolicy.OverwriteIfNewer); + file.MoveToDirectory( + DistBasePath / "nodetars", + ExistsPolicy.MergeAndOverwriteIfNewer + ); } } } diff --git a/build/Configuration.cs b/build/Configuration.cs deleted file mode 100644 index 9b22a3b..0000000 --- a/build/Configuration.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.ComponentModel; -using Nuke.Common.Tooling; - -[TypeConverter(typeof(TypeConverter))] -public class Configuration : Enumeration -{ - public static Configuration Debug = new Configuration { Value = nameof(Debug) }; - public static Configuration Release = new Configuration { Value = nameof(Release) }; - - public static implicit operator string(Configuration configuration) - { - return configuration.Value; - } -} diff --git a/build/TargetOperatingSystem.cs b/build/TargetOperatingSystem.cs index a4297e4..c51df58 100644 --- a/build/TargetOperatingSystem.cs +++ b/build/TargetOperatingSystem.cs @@ -31,7 +31,6 @@ public class TargetOperatingSystem : Enumeration ["skia_use_fontconfig"] = "false", ["skia_enable_fontmgr_empty"] = "false", - ["skia_enable_fontmgr_empty"] = "false", ["skia_enable_fontmgr_FontConfigInterface"] = "false", ["skia_enable_fontmgr_fontconfig"] = "false", ["skia_enable_fontmgr_custom_directory"] = "false", diff --git a/build/_build.csproj b/build/_build.csproj index 2a3f2c8..e1a98e3 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -12,7 +12,7 @@ - + diff --git a/build/_build.csproj.DotSettings b/build/_build.csproj.DotSettings index eb3f4c2..88a8824 100644 --- a/build/_build.csproj.DotSettings +++ b/build/_build.csproj.DotSettings @@ -17,6 +17,8 @@ False <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /> + <Policy><Descriptor Staticness="Instance" AccessRightKinds="Private" Description="Instance fields (private)"><ElementKinds><Kind Name="FIELD" /><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> + <Policy><Descriptor Staticness="Static" AccessRightKinds="Private" Description="Static fields (private)"><ElementKinds><Kind Name="FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="" Suffix="" Style="AaBb" /></Policy> True True True @@ -25,4 +27,5 @@ True True True - True + True + True From e33043b09bf872cba179f80c6249c6769bf52640 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Mon, 21 Apr 2025 16:20:00 +0200 Subject: [PATCH 16/18] build(java): Use vannitek maven publish plugin --- .github/workflows/publish.yml | 12 ++--- .github/workflows/~java.yml | 9 ++-- lib/java/.idea/gradle.xml | 1 + lib/java/.idea/misc.xml | 3 +- lib/java/.idea/vcs.xml | 3 ++ lib/java/android/build.gradle.kts | 23 +++++----- lib/java/build.gradle.kts | 42 +++++------------- lib/java/gradle.properties | 3 ++ lib/java/gradle/libs.versions.toml | 12 +++++ lib/java/gradle/wrapper/gradle-wrapper.jar | Bin 60756 -> 43504 bytes .../gradle/wrapper/gradle-wrapper.properties | 5 ++- lib/java/linux/build.gradle.kts | 13 ++++-- lib/java/macos/build.gradle.kts | 11 ++++- lib/java/main/build.gradle.kts | 17 ++++--- lib/java/windows/build.gradle.kts | 13 ++++-- 15 files changed, 102 insertions(+), 65 deletions(-) create mode 100644 lib/java/gradle.properties create mode 100644 lib/java/gradle/libs.versions.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 9553411..079668a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -46,12 +46,12 @@ jobs: runs-on: ubuntu-latest needs: [build] env: - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - SONATYPE_SIGNING_KEY: ${{ secrets.SONATYPE_SIGNING_KEY }} - SONATYPE_SIGNING_KEY_ID: ${{ secrets.SONATYPE_SIGNING_KEY_ID }} - SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.OSSRH_USERTOKEN_USERNAME}} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.OSSRH_USERTOKEN_PASSWORD}} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{secrets.SONATYPE_SIGNING_KEY_ID}} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.SONATYPE_SIGNING_PASSWORD}} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.SONATYPE_SIGNING_KEY}} + steps: - uses: actions/setup-dotnet@v4 with: diff --git a/.github/workflows/~java.yml b/.github/workflows/~java.yml index e141491..c7fe75d 100644 --- a/.github/workflows/~java.yml +++ b/.github/workflows/~java.yml @@ -19,10 +19,11 @@ jobs: java: runs-on: ubuntu-latest env: - SONATYPE_SIGNING_KEY: ${{ secrets.SONATYPE_SIGNING_KEY }} - SONATYPE_SIGNING_KEY_ID: ${{ secrets.SONATYPE_SIGNING_KEY_ID }} - SONATYPE_SIGNING_PASSWORD: ${{ secrets.SONATYPE_SIGNING_PASSWORD }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{secrets.OSSRH_USERTOKEN_USERNAME}} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{secrets.OSSRH_USERTOKEN_PASSWORD}} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{secrets.SONATYPE_SIGNING_KEY_ID}} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{secrets.SONATYPE_SIGNING_PASSWORD}} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{secrets.SONATYPE_SIGNING_KEY}} steps: - uses: actions/setup-java@v4 with: diff --git a/lib/java/.idea/gradle.xml b/lib/java/.idea/gradle.xml index d509473..780cb63 100644 --- a/lib/java/.idea/gradle.xml +++ b/lib/java/.idea/gradle.xml @@ -4,6 +4,7 @@