Build Skia + QuestPDF WASM #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Skia + QuestPDF WASM | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
name: ${{ matrix.runtime.name }} | |
runs-on: ${{ matrix.runtime.runs-on }} | |
container: ${{ matrix.runtime.container }} | |
strategy: | |
fail-fast: false | |
matrix: | |
runtime: | |
- name: browser-wasm | |
runs-on: ubuntu-latest-xlarge | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build Skia | |
shell: bash | |
run: | | |
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
echo "${PWD}/depot_tools" >> $GITHUB_PATH | |
export PATH="${PWD}/depot_tools:${PATH}" | |
git clone https://github.com/google/skia.git --branch chrome/m127 --single-branch | |
cd skia | |
bin/fetch-ninja | |
python3 tools/git-sync-deps | |
source "/home/runner/work/QuestPDF.Native/QuestPDF.Native/skia/third_party/externals/emsdk/emsdk_env.sh" | |
# bin/activate-emsdk | |
# EMSDK_PATH='/Users/runner/work/QuestPDF.Native/QuestPDF.Native/skia/third_party/externals/emsdk' | |
# source "${EMSDK_PATH}/emsdk_env.sh" | |
# echo 'source "${EMSDK_PATH}/emsdk_env.sh"' >> $HOME/.bash_profile | |
# an unsuccessful attempt to fix: | |
# [753/1041] ACTION //third_party/libgrapheme:generate_headers(//gn/toolchain:wasm) | |
# FAILED: gen/third_party/libgrapheme/gen/character.h | |
# python3 ../../third_party/libgrapheme/generate_headers.py /home/runner/work/QuestPDF.Native/QuestPDF.Native/skia/out/release/character gen/third_party/libgrapheme/gen/character.h gen/third_party/libgrapheme | |
# /bin/sh: 1: /home/runner/work/QuestPDF.Native/QuestPDF.Native/skia/out/release/character: Permission denied | |
mkdir -p out/release | |
cd out/release | |
touch line bidirectional case character sentence word | |
chmod -R u+w . | |
cd ../../ | |
COMMON_ARGS=' | |
is_official_build=true | |
is_component_build=false | |
is_debug=false | |
skia_enable_optimize_size=true | |
skia_enable_tools=true | |
skia_use_system_expat=false | |
skia_use_system_icu=false | |
skia_use_system_harfbuzz=false | |
skia_use_system_libjpeg_turbo=false | |
skia_use_system_libpng=false | |
skia_use_system_libwebp=false | |
skia_use_system_zlib=false | |
skia_use_system_freetype2=false | |
skia_use_dng_sdk=false | |
skia_use_harfbuzz=true | |
skia_use_icu=false | |
skia_use_icu4x=false | |
skia_use_libgrapheme=true | |
skia_use_fontconfig=false | |
skia_use_gl=false | |
skia_use_libjpeg_turbo_decode=true | |
skia_use_libjpeg_turbo_encode=true | |
skia_use_libpng_encode=true | |
skia_use_libpng_decode=true | |
skia_use_libwebp_encode=true | |
skia_use_libwebp_decode=true | |
skia_enable_android_utils=false | |
skia_enable_spirv_validation=false | |
skia_enable_gpu=false | |
skia_enable_gpu_debug_layers=false | |
skia_enable_fontmgr_custom_directory=true | |
skia_use_freetype=true | |
skia_use_jpeg_gainmaps=false | |
skia_use_libheif=false | |
skia_use_lua=false | |
skia_enable_svg=true | |
skia_use_expat=true | |
skia_enable_skshaper=true | |
skia_enable_skunicode=true | |
skia_pdf_subset_harfbuzz=true | |
skia_enable_pdf=true | |
skia_compile_modules=false | |
extra_cflags=["-fPIC", "-fno-rtti"]' | |
COMMON_ARGS+=' is_wasm=true skia_emsdk_dir="'$EMSDK_PATH'" is_trivial_abi=true target_os="wasm" target_cpu="wasm"' | |
bin/gn gen out/release --args="$COMMON_ARGS" | |
ninja -C out/release skia svg skparagraph | |
- name: Configure CMake | |
shell: bash | |
run: | | |
CMAKE_ARGS=" | |
-S ${PWD}/native | |
-B ${PWD}/native/build | |
-DSKIA_DIR=${PWD}/skia | |
-DCMAKE_CXX_COMPILER=clang++ | |
-DCMAKE_C_COMPILER=clang | |
-DCMAKE_BUILD_TYPE=Release" | |
cmake $CMAKE_ARGS | |
- name: Build CMake | |
shell: bash | |
run: > | |
cmake | |
--build ${PWD}/native/build | |
--config Release | |
- name: Copy build artifact to output directory | |
shell: bash | |
run: | | |
mkdir -p output/runtimes/${{ matrix.runtime.name }}/native | |
find native/build -type f \( -name "*.dylib" -o -name "*.dll" -o -name "*.so" -o -name "*.wasm" \) -exec cp {} output/runtimes/${{ matrix.runtime.name }}/native \; | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: questpdf-native-libraries | |
path: output | |