Skip to content

Commit

Permalink
Replace target_libc with target_environment
Browse files Browse the repository at this point in the history
  • Loading branch information
bblanchon committed Sep 16, 2024
1 parent 21cce31 commit 91942b7
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 37 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/build-one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand All @@ -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
Expand All @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ jobs:
if: always() && steps.checkout.outcome == 'success'
env:
PDFium_TARGET_OS: linux
PDFium_TARGET_LIBC: musl
PDFium_TARGET_ENVIRONMENT: musl
30 changes: 22 additions & 8 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -41,10 +43,6 @@ do
export PDFium_ENABLE_V8=true
;;

m)
export PDFium_TARGET_LIBC=musl
;;

s)
START_STEP="$OPTARG"
;;
Expand All @@ -62,7 +60,7 @@ then
exit 1
fi

if [[ $# -gt 2 ]]
if [[ $# -gt 3 ]]
then
echo "Too many arguments"
exit 1
Expand All @@ -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"
Expand All @@ -88,6 +101,7 @@ fi

export PDFium_TARGET_OS=$1
export PDFium_TARGET_CPU=$2
export PDFium_TARGET_ENVIRONMENT=${3:-}

set -x

Expand Down
4 changes: 2 additions & 2 deletions steps/01-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions steps/03-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions steps/05-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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"'
Expand All @@ -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'
Expand Down
10 changes: 5 additions & 5 deletions steps/08-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,23 +56,23 @@ 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-"
SUFFIX="-10"
fi
;;
arm64)
if [ "$TARGET_LIBC" == "musl" ]; then
if [ "$TARGET_ENVIRONMENT" == "musl" ]; then
PREFIX="aarch64-linux-musl-"
else
PREFIX="aarch64-linux-gnu-"
SUFFIX="-10"
fi
;;
x86)
if [ "$TARGET_LIBC" == "musl" ]; then
if [ "$TARGET_ENVIRONMENT" == "musl" ]; then
PREFIX="i686-linux-musl-"
else
CAN_RUN_ON_HOST=true
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions steps/09-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
popd

0 comments on commit 91942b7

Please sign in to comment.