diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 1b453323..883dec49 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -287,7 +287,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: arm64 - target_libc: musl + target_environment: musl enable_v8: false linux_musl_arm64_v8: @@ -301,7 +301,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: arm64 - target_libc: musl + target_environment: musl enable_v8: true linux_musl_x64: @@ -313,7 +313,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: x64 - target_libc: musl + target_environment: musl enable_v8: false linux_musl_x64_v8: @@ -327,7 +327,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: x64 - target_libc: musl + target_environment: musl enable_v8: true linux_musl_x86: @@ -339,7 +339,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: x86 - target_libc: musl + target_environment: musl enable_v8: false linux_musl_x86_v8: @@ -353,7 +353,7 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: linux target_cpu: x86 - target_libc: musl + target_environment: musl enable_v8: true mac_arm64: diff --git a/.github/workflows/build-one.yml b/.github/workflows/build-one.yml index 83dad895..3ac9ac24 100644 --- a/.github/workflows/build-one.yml +++ b/.github/workflows/build-one.yml @@ -30,12 +30,16 @@ on: - x64 - x86 - wasm - target_libc: - description: Target libc + target_environment: + description: Target environment type: choice + default: '' options: - - default + - '' + - device + - catalyst - musl + - simulator enable_v8: description: Enable V8 type: boolean @@ -62,6 +66,6 @@ jobs: is_debug: ${{ github.event.inputs.is_debug == 'true' }} target_os: ${{ github.event.inputs.target_os }} target_cpu: ${{ github.event.inputs.target_cpu }} - target_libc: ${{ github.event.inputs.target_libc }} + target_environment: ${{ github.event.inputs.target_environment }} enable_v8: ${{ github.event.inputs.enable_v8 == 'true' }} emsdk_version: ${{ github.event.inputs.emsdk_version }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 610c6901..29aa9665 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,8 +31,8 @@ on: description: Target (CPU arm|arm64|x64|x86|wasm) type: string required: true - target_libc: - description: Target libc (empty string or "musl") + target_environment: + description: Target environment (device|catalyst|musl|simulator) type: string required: false default: '' @@ -59,7 +59,7 @@ jobs: ARTIFACT="pdfium" [ "${{inputs.enable_v8}}" == "true" ] && ARTIFACT="$ARTIFACT-v8" ARTIFACT="$ARTIFACT-${{inputs.target_os}}" - [ "${{inputs.target_libc}}" != "" ] && ARTIFACT="$ARTIFACT-${{inputs.target_libc}}" + [ "${{inputs.target_environment}}" != "" ] && ARTIFACT="$ARTIFACT-${{inputs.target_environment}}" [ "${{inputs.target_os}}" != "${{inputs.target_cpu}}" ] && ARTIFACT="$ARTIFACT-${{inputs.target_cpu}}" [ "${{inputs.is_debug}}" == "true" ] && ARTIFACT="$ARTIFACT-debug" echo "artifact=$ARTIFACT" >> $GITHUB_OUTPUT @@ -72,7 +72,7 @@ jobs: PDFium_IS_DEBUG=${{ inputs.is_debug }} PDFium_TARGET_CPU=${{ inputs.target_cpu }} PDFium_TARGET_OS=${{ inputs.target_os }} - PDFium_TARGET_LIBC=${{ inputs.target_libc }} + PDFium_TARGET_ENVIRONMENT=${{ inputs.target_environment }} PDFium_ENABLE_V8=${{ inputs.enable_v8 }} PDFium_VERSION=${{ inputs.version }} EMSDK_VERSION=${{ inputs.emsdk_version }} diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 1c187f67..e2da7937 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -86,4 +86,4 @@ jobs: if: always() && steps.checkout.outcome == 'success' env: PDFium_TARGET_OS: linux - PDFium_TARGET_LIBC: musl \ No newline at end of file + PDFium_TARGET_ENVIRONMENT: musl diff --git a/build.sh b/build.sh index da7bf788..8aa3ec18 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,8 @@ OS_NAMES="android|ios|linux|mac|wasm|win" CPU_NAMES="arm|arm64|x64|x86|wasm" +ENV_NAMES="catalyst|device|musl|simulator" +OS_ENV_COMBINATIONS="linux musl|ios (catalyst|device|simulator)" STEP_REGEX="[0-9]" START_STEP=0 @@ -11,18 +13,18 @@ then echo "PDFium build script. https://github.com/bblanchon/pdfium-binaries -Usage $0 [options] os cpu +Usage $0 [options] os cpu [env] Arguments: os = Target OS ($OS_NAMES) cpu = Target CPU ($CPU_NAMES) + env = Target environment ($ENV_NAMES) Options: -b branch = Chromium branch (default=main) -s 0-9 = Set start step (default=0) -d = debug build - -j = enable v8 - -m = build fo musl" + -j = enable v8" exit fi @@ -41,10 +43,6 @@ do export PDFium_ENABLE_V8=true ;; - m) - export PDFium_TARGET_LIBC=musl - ;; - s) START_STEP="$OPTARG" ;; @@ -62,7 +60,7 @@ then exit 1 fi -if [[ $# -gt 2 ]] +if [[ $# -gt 3 ]] then echo "Too many arguments" exit 1 @@ -80,6 +78,21 @@ then exit 1 fi +if [[ $# -eq 3 ]] +then + if [[ ! $3 =~ ^($ENV_NAMES)$ ]] + then + echo "Unknown environment: $3" + exit 1 + fi + + if [[ ! "$1 $3" =~ ^($OS_ENV_COMBINATIONS)$ ]] + then + echo "OS $1 doesn't support environment $3" + exit 1 + fi +fi + if [[ ! $START_STEP =~ ^($STEP_REGEX)$ ]] then echo "Invalid step number: $START_STEP" @@ -88,6 +101,7 @@ fi export PDFium_TARGET_OS=$1 export PDFium_TARGET_CPU=$2 +export PDFium_TARGET_ENVIRONMENT=${3:-} set -x diff --git a/steps/01-install.sh b/steps/01-install.sh index c2d75d07..0f4762b8 100755 --- a/steps/01-install.sh +++ b/steps/01-install.sh @@ -2,7 +2,7 @@ PATH_FILE=${GITHUB_PATH:-$PWD/.path} TARGET_OS=${PDFium_TARGET_OS:?} -TARGET_LIBC=${PDFium_TARGET_LIBC:-default} +TARGET_ENVIRONMENT=${PDFium_TARGET_ENVIRONMENT:-} TARGET_CPU=${PDFium_TARGET_CPU:?} CURRENT_CPU=${PDFium_CURRENT_CPU:-x64} MUSL_URL=${MUSL_URL:-https://musl.cc} @@ -40,7 +40,7 @@ case "$TARGET_OS" in sudo apt-get update sudo apt-get install -y cmake pkg-config - if [ "$TARGET_LIBC" == "musl" ]; then + if [ "$TARGET_ENVIRONMENT" == "musl" ]; then case "$TARGET_CPU" in x86) diff --git a/steps/03-patch.sh b/steps/03-patch.sh index c8f29351..8d80f474 100755 --- a/steps/03-patch.sh +++ b/steps/03-patch.sh @@ -3,7 +3,7 @@ PATCHES="$PWD/patches" SOURCE="${PDFium_SOURCE_DIR:-pdfium}" OS="${PDFium_TARGET_OS:?}" -TARGET_LIBC="${PDFium_TARGET_LIBC:-default}" +TARGET_ENVIRONMENT="${PDFium_TARGET_ENVIRONMENT:-}" pushd "${SOURCE}" @@ -42,7 +42,7 @@ case "$OS" in ;; esac -case "$TARGET_LIBC" in +case "$TARGET_ENVIRONMENT" in musl) git -C build apply -v "$PATCHES/musl/build.patch" mkdir -p "build/toolchain/linux/musl" diff --git a/steps/05-configure.sh b/steps/05-configure.sh index 778bf1ba..c1f65ccc 100755 --- a/steps/05-configure.sh +++ b/steps/05-configure.sh @@ -4,7 +4,7 @@ OS=${PDFium_TARGET_OS:?} SOURCE=${PDFium_SOURCE_DIR:-pdfium} BUILD=${PDFium_BUILD_DIR:-$SOURCE/out} TARGET_CPU=${PDFium_TARGET_CPU:?} -TARGET_LIBC=${PDFium_TARGET_LIBC:-default} +TARGET_ENVIRONMENT=${PDFium_TARGET_ENVIRONMENT:-default} ENABLE_V8=${PDFium_ENABLE_V8:-false} IS_DEBUG=${PDFium_IS_DEBUG:-false} @@ -32,6 +32,7 @@ mkdir -p "$BUILD" echo "default_min_sdk_version = 21" ;; ios) + [ -n "$TARGET_ENVIRONMENT" ] && echo "target_environment = \"$TARGET_ENVIRONMENT\"" echo "ios_enable_code_signing = false" echo "use_blink = true" [ "$ENABLE_V8" == "true" ] && [ "$TARGET_CPU" == "arm64" ] && echo 'arm_control_flow_integrity = "none"' @@ -50,7 +51,7 @@ mkdir -p "$BUILD" ;; esac - case "$TARGET_LIBC" in + case "$TARGET_ENVIRONMENT" in musl) echo 'is_musl = true' echo 'is_clang = false' diff --git a/steps/08-test.sh b/steps/08-test.sh index 700b8ec7..54cd9661 100755 --- a/steps/08-test.sh +++ b/steps/08-test.sh @@ -2,7 +2,7 @@ OS=${PDFium_TARGET_OS:?} CPU="${PDFium_TARGET_CPU:?}" -TARGET_LIBC="${PDFium_TARGET_LIBC:-default}" +TARGET_ENVIRONMENT="${PDFium_TARGET_ENVIRONMENT:-}" SOURCE_DIR="$PWD/example" CMAKE_ARGS=() CAN_RUN_ON_HOST=false @@ -56,7 +56,7 @@ case "$OS" in linux) case "$CPU" in arm) - if [ "$TARGET_LIBC" == "musl" ]; then + if [ "$TARGET_ENVIRONMENT" == "musl" ]; then PREFIX="arm-linux-musleabihf-" else PREFIX="arm-linux-gnueabihf-" @@ -64,7 +64,7 @@ case "$OS" in fi ;; arm64) - if [ "$TARGET_LIBC" == "musl" ]; then + if [ "$TARGET_ENVIRONMENT" == "musl" ]; then PREFIX="aarch64-linux-musl-" else PREFIX="aarch64-linux-gnu-" @@ -72,7 +72,7 @@ case "$OS" in fi ;; x86) - if [ "$TARGET_LIBC" == "musl" ]; then + if [ "$TARGET_ENVIRONMENT" == "musl" ]; then PREFIX="i686-linux-musl-" else CAN_RUN_ON_HOST=true @@ -83,7 +83,7 @@ case "$OS" in ) ;; x64) - if [ "$TARGET_LIBC" == "musl" ]; then + if [ "$TARGET_ENVIRONMENT" == "musl" ]; then PREFIX="x86_64-linux-musl-" else CAN_RUN_ON_HOST=true diff --git a/steps/09-pack.sh b/steps/09-pack.sh index 0d6ce0b5..88802193 100755 --- a/steps/09-pack.sh +++ b/steps/09-pack.sh @@ -3,18 +3,18 @@ IS_DEBUG=${PDFium_IS_DEBUG:-false} ENABLE_V8=${PDFium_ENABLE_V8:-false} OS=${PDFium_TARGET_OS:?} -TARGET_LIBC=${PDFium_TARGET_LIBC:-default} +TARGET_ENVIRONMENT=${PDFium_TARGET_ENVIRONMENT:-} CPU=${PDFium_TARGET_CPU:?} STAGING="$PWD/staging" ARTIFACT_BASE="$PWD/pdfium" [ "$ENABLE_V8" == "true" ] && ARTIFACT_BASE="$ARTIFACT_BASE-v8" ARTIFACT_BASE="$ARTIFACT_BASE-$OS" -[ "$TARGET_LIBC" != "default" ] && ARTIFACT_BASE="$ARTIFACT_BASE-$TARGET_LIBC" +[ -n "$TARGET_ENVIRONMENT" ] && ARTIFACT_BASE="$ARTIFACT_BASE-$TARGET_ENVIRONMENT" [ "$OS" != "$CPU" ] && ARTIFACT_BASE="$ARTIFACT_BASE-$CPU" [ "$IS_DEBUG" == "true" ] && ARTIFACT_BASE="$ARTIFACT_BASE-debug" ARTIFACT="$ARTIFACT_BASE.tgz" pushd "$STAGING" tar cvzf "$ARTIFACT" -- * -popd \ No newline at end of file +popd