Skip to content

Build on Windows

Build on Windows #33

Workflow file for this run

name: Build native dependencies (FreeType)
# Change target FreeType version based on https://github.com/freetype/freetype/tags.
env:
FREETYPE_VERSION: VER-2-14-1 # Make sure this matches the version mentioned in the description in the .nuspec file.
on:
pull_request:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
windows:
name: Windows (x64)
runs-on: windows-2022
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Setup Dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts/x64 | Out-Null
- name: Compile natives
shell: pwsh
run: |
$zip = "${env:FREETYPE_VERSION}.zip"
Invoke-WebRequest -Uri "https://github.com/freetype/freetype/archive/refs/tags/$zip" -OutFile $zip
Expand-Archive -Path $zip -DestinationPath .
$src = "freetype-${env:FREETYPE_VERSION}"
Copy-Item "win64.patch" "$src\win64.patch" -Force
cmake -S $src -B "$src\build-x64" `
-A x64 `
-DBUILD_SHARED_LIBS=TRUE `
-DCMAKE_BUILD_TYPE=Release `
-DFT_DISABLE_ZLIB=TRUE `
-DFT_DISABLE_BZIP2=TRUE `
-DFT_DISABLE_PNG=TRUE `
-DFT_DISABLE_HARFBUZZ=TRUE `
-DFT_DISABLE_BROTLI=TRUE
cmake --build "$src\build-x64" --config Release
Copy-Item "$src\build-x64\Release\freetype.dll" "artifacts\x64\freetype6.dll" -Force
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Windows
path: ./artifacts
windows-arm64:
name: Windows (arm64)
runs-on: windows-11-arm
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Setup Dependencies
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path artifacts/arm64 | Out-Null
- name: Compile natives
shell: pwsh
run: |
$zip = "${env:FREETYPE_VERSION}.zip"
Invoke-WebRequest -Uri "https://github.com/freetype/freetype/archive/refs/tags/$zip" -OutFile $zip
Expand-Archive -Path $zip -DestinationPath .
$src = "freetype-${env:FREETYPE_VERSION}"
Copy-Item "win64.patch" "$src\win64.patch" -Force
cmake -S $src -B "$src\build-arm64" `
-A ARM64 `
-DBUILD_SHARED_LIBS=TRUE `
-DCMAKE_BUILD_TYPE=Release `
-DFT_DISABLE_ZLIB=TRUE `
-DFT_DISABLE_BZIP2=TRUE `
-DFT_DISABLE_PNG=TRUE `
-DFT_DISABLE_HARFBUZZ=TRUE `
-DFT_DISABLE_BROTLI=TRUE
cmake --build "$src\build-arm64" --config Release
Copy-Item "$src\build-arm64\Release\freetype.dll" "artifacts\arm64\freetype6.dll" -Force
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Windows(arm64)
path: ./artifacts
macos:
name: macOS (x64 + arm64)
runs-on: macos-14
steps:
- name: Setup Dependencies
run: |
mkdir -p artifacts/x86_64
mkdir artifacts/arm64
- name: Compile natives
run: |
curl -s -L -O https://github.com/freetype/freetype/archive/refs/tags/${FREETYPE_VERSION}.zip
unzip ${FREETYPE_VERSION}.zip
cd freetype-${FREETYPE_VERSION}
cmake -B build -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 -DFT_DISABLE_ZLIB=TRUE -DFT_DISABLE_BZIP2=TRUE -DFT_DISABLE_PNG=TRUE -DFT_DISABLE_HARFBUZZ=TRUE -DFT_DISABLE_BROTLI=TRUE
cmake --build build
lipo -thin x86_64 build/libfreetype.6.dylib -output ../artifacts/x86_64/freetype6.dylib
lipo -thin arm64 build/libfreetype.6.dylib -output ../artifacts/arm64/freetype6.dylib
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-MacOS
path: ./artifacts
# Note: Running inside a Rocky Linux container because we want to compile using a version of glibc
# that is as old as reasonably possible to ensure backwards compatibility of the compiled binaries.
linux-x64:
name: Linux (x64)
runs-on: ubuntu-22.04
container: rockylinux:8
steps:
- name: Setup Dependencies
run: |
mkdir -p artifacts/x64
dnf install -y "dnf-command(config-manager)"
dnf config-manager --set-enabled powertools
dnf install -y epel-release cmake
dnf groupinstall -y "Development Tools"
dnf -y update
- name: Compile natives
run: |
curl -s -L -O https://github.com/freetype/freetype/archive/refs/tags/${FREETYPE_VERSION}.zip
unzip ${FREETYPE_VERSION}.zip
mkdir freetype-${FREETYPE_VERSION}/build
cd freetype-${FREETYPE_VERSION}/build
cmake .. -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DFT_DISABLE_ZLIB=TRUE -DFT_DISABLE_BZIP2=TRUE -DFT_DISABLE_PNG=TRUE -DFT_DISABLE_HARFBUZZ=TRUE -DFT_DISABLE_BROTLI=TRUE
cmake --build .
cp libfreetype.so ../../artifacts/x64/freetype6.so
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Linux(x64)
path: ./artifacts
linux-arm64:
name: Linux (arm64)
runs-on: ubuntu-22.04-arm
steps:
- name: Setup Dependencies
run: |
mkdir -p artifacts/arm64
sudo apt-get install -y build-essential curl cmake unzip
- name: Compile Natives
run: |
curl -s -L -O https://github.com/freetype/freetype/archive/refs/tags/${FREETYPE_VERSION}.zip
unzip ${FREETYPE_VERSION}.zip
mkdir freetype-${FREETYPE_VERSION}/build
cd freetype-${FREETYPE_VERSION}/build
cmake .. -DBUILD_SHARED_LIBS=true -DCMAKE_BUILD_TYPE=Release -DFT_DISABLE_ZLIB=TRUE -DFT_DISABLE_BZIP2=TRUE -DFT_DISABLE_PNG=TRUE -DFT_DISABLE_HARFBUZZ=TRUE -DFT_DISABLE_BROTLI=TRUE
cmake --build .
cp libfreetype.so ../../artifacts/arm64/freetype6.so
- name: Upload Artifacts
uses: actions/upload-artifact@v7
with:
name: Natives-Linux(arm64)
path: ./artifacts