Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build harfbuzz and nativeaot afs.cmd with GHA #23

Merged
merged 31 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4ebaf04
test
MIRIMIRIM Nov 13, 2024
31ed75b
Update macos-x64.ini
MIRIMIRIM Nov 13, 2024
ddedfed
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
f9be531
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
5e9df89
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
6922748
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
9e63a72
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
1d45a60
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
0097497
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
9b21013
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
17fcf6e
Update build-harfbuzz-subset.yml
MIRIMIRIM Nov 13, 2024
07c49cd
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
1f03aad
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
cf7e4fb
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
907a99b
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
30b5da0
rename
MIRIMIRIM Nov 13, 2024
f71abbe
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
98f6d08
update
MIRIMIRIM Nov 13, 2024
3ecea55
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
2666435
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
f7c2fbc
Update afs-cmd-ci.yml
MIRIMIRIM Nov 13, 2024
5f1ebbf
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
1c3057f
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
2f9828a
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
0a5313c
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
58e4b89
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
5c83c1e
Update AssFontSubset.Console.csproj
MIRIMIRIM Nov 14, 2024
f237570
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
8028ba0
Update afs-cmd-ci.yml
MIRIMIRIM Nov 14, 2024
85c9d8d
Update osx-x64.ini
MIRIMIRIM Nov 14, 2024
6b60a5e
Update osx-x64.ini
MIRIMIRIM Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 46 additions & 56 deletions .github/workflows/afs-cmd-ci.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
name: afs.cmd
name: Build afs.cmd

on:
push:
branches: [ "master" ]
paths:
- 'AssFontSubset.Core/**.cs'
- 'AssFontSubset.Core/**.csproj'
- 'AssFontSubset.Console/**.cs'
- 'AssFontSubset.Console/**.csproj'
pull_request:
branches: [ "master" ]
paths:
- 'AssFontSubset.Core/**.cs'
- 'AssFontSubset.Core/**.csproj'
- 'AssFontSubset.Console/**.cs'
- 'AssFontSubset.Console/**.csproj'
workflow_run:
workflows: ["Build hb-subset"]
types:
- completed
workflow_dispatch:

env:
hb_ver: 10.1.0

jobs:
build:
name: build-${{ matrix.target }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
#if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
identifier: ${{ matrix.target }}-${{ matrix.arch }}
strategy:
matrix:
env:
harfbuzz_ver: ['10.1.0']
target: [win, linux-musl, osx]
arch: [x64, arm64]
include:
- os: windows-latest
target: win
- os: windows-latest
identifier: win
# - os: macos-latest
# identifier: osx
# - os: ubuntu-latest
# identifier: linux
arch: ['x64'] # 'arm64'
target: linux-musl
- os: macos-latest
target: osx
dotnet_version: ['8.x']

name: build-${{ matrix.env.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.env.os }}

steps:

- name: Setup .NET
Expand All @@ -58,35 +49,34 @@ jobs:
dotnet test
cd ..

# - name: Install linux arm64 prereqs
# # copy from https://github.com/dn-vm/dnvm
# if: matrix.env.identifier == 'linux' && matrix.arch == 'arm64'
# run: |
# sudo dpkg --add-architecture arm64
# sudo bash -c 'cat > /etc/apt/sources.list.d/arm64.list <<EOF
# deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy main restricted ports
# deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
# deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
# EOF'
# sudo sed -i -e 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
# sudo sed -i -e 's/deb mirror/deb [arch=amd64] mirror/g' /etc/apt/sources.list
# sudo apt update
# sudo apt install -y clang llvm binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu zlib1g-dev:arm64
- name: Setup Zig Compiler (target linux)
if: matrix.target == 'linux-musl'
uses: mlugg/setup-zig@v1
with:
version: "master"

- name: Download prebuilt harfbuzz libs
if: matrix.env.identifier == 'win' && matrix.arch == 'x64'
- name: Add llvm-objcopy
if: matrix.target == 'linux-musl'
run: |
mkdir native
Invoke-WebRequest -Uri https://github.com/MIRIMIRIM/FontFlat/releases/download/harfbuzz-libs/harfbuzz_win-x64_${{ env.hb_ver }}.7z -OutFile ./native/harfbuzz_win-x64.7z
cd ./native
7z x harfbuzz_win-x64.7z
cd ..
Invoke-WebRequest -Uri https://github.com/MIRIMIRIM/FontFlat/releases/download/harfbuzz-libs/llvm-objcopy.exe -OutFile ./AssFontSubset.Console/llvm-objcopy.exe

- name: Use prebuilt harfbuzz subset
uses: actions/cache/restore@v4
with:
path: ./HarfBuzzBinding/target
key: hb-subset-${{ matrix.harfbuzz_ver }}-${{ env.identifier }}-static
# restore-keys: |
# hb-subset-${{ matrix.harfbuzz_ver }}-${{ env.identifier }}-static-

- name: Change to afs.cmd and Publish
run: |
mkdir native
mv ./HarfBuzzBinding/target/* ./native/

cd ./AssFontSubset.Console
dotnet restore
dotnet publish -c Release -r "${{ matrix.env.identifier }}-${{ matrix.arch }}" /p:PublishAot=true
dotnet publish -c Release -r ${{ env.identifier }}

cd ..

- name: Set short version
Expand All @@ -98,10 +88,10 @@ jobs:
- name: Upload exe files
uses: actions/upload-artifact@v4
with:
name: AssFontSubset.Console_g${{ env.VERSION }}_${{ matrix.env.identifier }}-${{ matrix.arch }}
name: AssFontSubset.Console_g${{ env.VERSION }}_${{ env.identifier }}
path: |
AssFontSubset.Console/bin/Release/net8.0/${{ matrix.env.identifier }}-${{ matrix.arch }}/publish/
!AssFontSubset.Console/bin/Release/net8.0/${{ matrix.env.identifier }}-${{ matrix.arch }}/publish/*.pdb
!AssFontSubset.Console/bin/Release/net8.0/${{ matrix.env.identifier }}-${{ matrix.arch }}/publish/*.dbg
!AssFontSubset.Console/bin/Release/net8.0/${{ matrix.env.identifier }}-${{ matrix.arch }}/publish/*.dwarf
!AssFontSubset.Console/bin/Release/net8.0/${{ matrix.env.identifier }}-${{ matrix.arch }}/publish/*.dsym
AssFontSubset.Console/bin/Release/net8.0/${{ env.identifier }}/publish/
!AssFontSubset.Console/bin/Release/net8.0/${{ env.identifier }}/publish/*.pdb
!AssFontSubset.Console/bin/Release/net8.0/${{ env.identifier }}/publish/*.dbg
!AssFontSubset.Console/bin/Release/net8.0/${{ env.identifier }}/publish/*.dwarf
!AssFontSubset.Console/bin/Release/net8.0/${{ env.identifier }}/publish/*.dsym
118 changes: 118 additions & 0 deletions .github/workflows/build-harfbuzz-subset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Build hb-subset

on:
push:
branches: [ "master" ]
paths:
- 'AssFontSubset.Core/**.cs'
- 'AssFontSubset.Core/**.csproj'
- 'AssFontSubset.Console/**.cs'
- 'AssFontSubset.Console/**.csproj'
pull_request:
branches: [ "master" ]
paths:
- 'AssFontSubset.Core/**.cs'
- 'AssFontSubset.Core/**.csproj'
- 'AssFontSubset.Console/**.cs'
- 'AssFontSubset.Console/**.csproj'
workflow_dispatch:

jobs:
build:
name: build-${{ matrix.target }}-${{ matrix.arch }}
runs-on: ${{ matrix.os }}
env:
identifier: ${{ matrix.target }}-${{ matrix.arch }}
strategy:
matrix:
harfbuzz_ver: ['10.1.0']
target: [win, osx, linux-musl]
arch: [x64, arm64]
include:
- os: windows-latest
target: win
- os: windows-latest
target: linux-musl
- os: macos-latest
target: osx

steps:
- name: Set up cache
id: cache
uses: actions/cache@v4
with:
path: ./HarfBuzzBinding/target
key: hb-subset-${{ matrix.harfbuzz_ver }}-${{ env.identifier }}-static
restore-keys: |
hb-subset-${{ matrix.harfbuzz_ver }}-${{ env.identifier }}-static

- name: Check out code
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4

- name: Prepare
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install meson ninja
cd ./HarfBuzzBinding
git clone --recurse-submodules https://github.com/harfbuzz/harfbuzz.git -b ${{ matrix.harfbuzz_ver }} --depth=1 harfbuzz-${{ matrix.harfbuzz_ver }}

- name: Setup msbuild (target windows x64)
if: matrix.target == 'win' && matrix.arch == 'x64' && steps.cache.outputs.cache-hit != 'true'
uses: ilammy/msvc-dev-cmd@v1

- name: Setup msbuild (target windows arm64)
if: matrix.target == 'win' && matrix.arch == 'arm64' && steps.cache.outputs.cache-hit != 'true'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64_arm64

- name: Setup Zig Compiler (target linux)
if: matrix.target == 'linux-musl' && steps.cache.outputs.cache-hit != 'true'
uses: mlugg/setup-zig@v1
with:
version: "master"

- name: Configure (windows-x64)
if: matrix.target == 'win' && matrix.arch == 'x64' && steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson --native-file ../scripts/project.ini -Ddefault_library=static -Db_vscrt=static_from_buildtype build/${{ env.identifier }}-static

- name: Configure (windows-arm64)
if: matrix.target == 'win' && matrix.arch == 'arm64' && steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson --cross-file ../scripts/project.ini --cross-file ../scripts/${{ env.identifier }}.ini -Ddefault_library=static -Db_vscrt=static_from_buildtype build/${{ env.identifier }}-static

- name: Configure (linux-musl)
if: matrix.target == 'linux-musl' && steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson --native-file ../scripts/zig.ini --cross-file ../scripts/zig.ini --cross-file ../scripts/project.ini --cross-file ../scripts/${{ env.identifier }}.ini -Ddefault_library=static build/${{ env.identifier }}-static

- name: Configure (osx-arm64)
if: matrix.target == 'osx' && matrix.arch == 'arm64' && steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson --native-file ../scripts/project.ini -Ddefault_library=static build/${{ env.identifier }}-static

- name: Configure (osx-x64)
if: matrix.target == 'osx' && matrix.arch == 'x64' && steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson --cross-file ../scripts/project.ini --cross-file ../scripts/${{ env.identifier }}.ini -Ddefault_library=static build/${{ env.identifier }}-static

- name: Build
if: steps.cache.outputs.cache-hit != 'true'
run: |
cd ./HarfBuzzBinding/harfbuzz-${{ matrix.harfbuzz_ver }}
meson compile -C build/${{ env.identifier }}-static
mkdir ../target
cp build/${{ env.identifier }}-static/src/*.a ../target/

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: hb-subset-${{ matrix.harfbuzz_ver }}-${{ env.identifier }}-static
path: ./HarfBuzzBinding/target
4 changes: 2 additions & 2 deletions AssFontSubset.Console/AssFontSubset.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

<ItemGroup>
<DirectPInvoke Include="harfbuzz" />
<NativeLibrary Include="../native/libharfbuzz.a" Condition="$(RuntimeIdentifier.StartsWith('win-x64'))" />
<NativeLibrary Include="../native/libharfbuzz.a"/>
<DirectPInvoke Include="harfbuzz-subset" />
<NativeLibrary Include="../native/libharfbuzz-subset.a" Condition="$(RuntimeIdentifier.StartsWith('win-x64'))" />
<NativeLibrary Include="../native/libharfbuzz-subset.a"/>
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions HarfBuzzBinding/scripts/linux-musl-arm64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[built-in options]
c_args = ['-target', 'aarch64-linux-musl']
cpp_args = ['-target', 'aarch64-linux-musl']
c_link_args = ['-target', 'aarch64-linux-musl']
cpp_link_args = ['-target', 'aarch64-linux-musl']

[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'

; meson --native-file .\build_scripts\zig.ini --cross-file .\build_scripts\zig.ini --cross-file .\build_scripts\linux-musl-arm64.ini -Ddefault_library=static ./build/linux-arm64-static-musl
11 changes: 11 additions & 0 deletions HarfBuzzBinding/scripts/linux-musl-x64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[built-in options]
c_args = ['-target', 'x86_64-linux-musl']
cpp_args = ['-target', 'x86_64-linux-musl']
c_link_args = ['-target', 'x86_64-linux-musl']
cpp_link_args = ['-target', 'x86_64-linux-musl']

[host_machine]
system = 'linux'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
13 changes: 13 additions & 0 deletions HarfBuzzBinding/scripts/osx-x64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[binaries]
c = ['clang']
cpp = ['clang']

[built-in options]
c_args = ['-target', 'x86_64-apple-darwin']
cpp_args = ['-target', 'x86_64-apple-darwin']

[host_machine]
system = 'darwin'
cpu_family = 'x86_64'
cpu = 'x86_64'
endian = 'little'
16 changes: 16 additions & 0 deletions HarfBuzzBinding/scripts/project.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project options]
glib='disabled'
gobject='disabled'
cairo='disabled'
chafa='disabled'
icu='disabled'
freetype='disabled'
tests='disabled'
introspection='disabled'
docs='disabled'
doc_tests=false
utilities='disabled'
experimental_api=true

[built-in options]
buildtype='release'
12 changes: 12 additions & 0 deletions HarfBuzzBinding/scripts/win-arm64.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[binaries]
c = ['cl']
cpp = ['cl']

[host_machine]
system = 'windows'
cpu_family = 'aarch64'
cpu = 'aarch64'
endian = 'little'

; vcvarsall.bat x64_arm64
; meson --cross-file .\build_scripts\project.ini --cross-file .\build_scripts\win-arm64.ini -Ddefault_library=static -Db_vscrt=static_from_buildtype ./build/win-arm64-static
10 changes: 10 additions & 0 deletions HarfBuzzBinding/scripts/zig.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[binaries]
c = ['zig', 'cc']
cpp = ['zig', 'c++']
ar = ['zig', 'ar']
ranlib = ['zig', 'ranlib']
lib = ['zig', 'lib']
dlltool = ['zig', 'dlltool']

[built-in options]
cpp_std = ['c++14']
Loading