From 56ecee95adc4bb4cbe2cd9dca2b0c4e5dcab55a4 Mon Sep 17 00:00:00 2001 From: reece394 <31659691+reece394@users.noreply.github.com> Date: Mon, 12 Aug 2024 15:01:04 +0100 Subject: [PATCH] Revert "Conda: add `shell: bash -l {0}`" This reverts commit e1e445d89c3187c60abd18c0c3f199a007b5259a. --- .github/workflows/build-all.yml | 88 +++++-------------- .github/workflows/build-one.yml | 6 -- .github/workflows/build.yml | 19 ++-- .github/workflows/mac-univ.yml | 6 +- .github/workflows/patch.yml | 6 +- .github/workflows/trigger.yml | 9 +- .gitignore | 2 +- README.md | 11 +-- nuget/bblanchon.PDFium.Linux.nuspec | 6 -- nuget/bblanchon.PDFium.Linux.targets | 44 ---------- nuget/bblanchon.PDFium.WebAssembly.nuspec | 9 ++ nuget/bblanchon.PDFium.WebAssembly.props | 6 ++ nuget/bblanchon.PDFium.macOS.nuspec | 5 -- nuget/bblanchon.PDFium.macOS.targets | 12 --- nuget/bblanchon.PDFiumV8.Linux.nuspec | 6 -- nuget/bblanchon.PDFiumV8.macOS.nuspec | 5 -- patches/android/{build.patch => pdfium.patch} | 10 +-- patches/ios/v8.patch | 14 --- patches/musl/build.patch | 41 ++------- patches/musl/pdfium.patch | 25 ++++++ patches/musl/toolchain.gn | 45 ---------- patches/musl/zlib.patch | 13 --- patches/v8/pdfium.patch | 26 +++--- patches/wasm/build.patch | 41 +++------ patches/wasm/pdfium.patch | 37 ++++++-- patches/win/build.patch | 6 +- patches/win/pdfium.patch | 12 +++ steps/01-install.sh | 21 +---- steps/03-patch.sh | 6 +- steps/04-install-extras.sh | 4 +- steps/05-configure.sh | 22 +---- steps/07-stage.sh | 1 + steps/08-test.sh | 18 ++-- 33 files changed, 180 insertions(+), 402 deletions(-) delete mode 100644 nuget/bblanchon.PDFium.Linux.targets create mode 100644 nuget/bblanchon.PDFium.WebAssembly.props delete mode 100644 nuget/bblanchon.PDFium.macOS.targets rename patches/android/{build.patch => pdfium.patch} (53%) delete mode 100644 patches/ios/v8.patch create mode 100644 patches/musl/pdfium.patch delete mode 100644 patches/musl/zlib.patch create mode 100644 patches/win/pdfium.patch diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 754ba23f..bac2eed8 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -21,18 +21,8 @@ on: type: boolean required: false default: false - release: - description: Publish GitHub release - type: boolean - required: false - default: false - nuget: - description: Publish on nuget.org - type: boolean - required: false - default: false - anaconda: - description: Publish on anaconda.org + publish: + description: Publish release type: boolean required: false default: false @@ -278,32 +268,6 @@ jobs: target_cpu: x86 enable_v8: true - linux_musl_arm64: - name: Linux musl ARM64 - uses: ./.github/workflows/build.yml - with: - branch: ${{ github.event.inputs.branch }} - version: ${{ github.event.inputs.version }} - is_debug: ${{ github.event.inputs.is_debug == 'true' }} - target_os: linux - target_cpu: arm64 - target_libc: musl - enable_v8: false - - linux_musl_arm64_v8: - name: Linux musl ARM64 V8 - if: github.event.inputs.enable_v8 == 'true' - needs: linux_musl_arm64 - uses: ./.github/workflows/build.yml - with: - branch: ${{ github.event.inputs.branch }} - version: ${{ github.event.inputs.version }} - is_debug: ${{ github.event.inputs.is_debug == 'true' }} - target_os: linux - target_cpu: arm64 - target_libc: musl - enable_v8: true - linux_musl_x64: name: Linux musl x64 uses: ./.github/workflows/build.yml @@ -531,8 +495,6 @@ jobs: - linux_x64_v8 - linux_x86 - linux_x86_v8 - - linux_musl_arm64 - - linux_musl_arm64_v8 - linux_musl_x64 - linux_musl_x64_v8 - linux_musl_x86 @@ -550,38 +512,29 @@ jobs: - win_x86_v8 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: path: nuget - name: Prepare header files shell: bash run: mkdir -p nuget/include/pdfium && cp -r nuget/pdfium-win-x86/include/* nuget/include/pdfium/ - - name: Define properties - shell: bash - run: | - VERSION="${{ github.event.inputs.version || '0.0.0.0' }}" - BRANCH="${GITHUB_REF#refs/heads/}" - COMMIT="${GITHUB_SHA}" - RELEASE_NOTES="${{github.server_url}}/${{github.repository}}/releases" - ${{ github.event.inputs.release }} && RELEASE_NOTES+="/tag/${{ github.event.inputs.branch }}" - echo "NUSPEC_PROPERTIES=version=$VERSION;branch=$BRANCH;commit=$COMMIT;releaseNotes=$RELEASE_NOTES" >> "$GITHUB_ENV" - name: Pack shell: bash run: | for NUSPEC in nuget/*.nuspec; do echo "::group::$NUSPEC" - nuget pack "$NUSPEC" -p "$NUSPEC_PROPERTIES" + nuget pack "$NUSPEC" -properties "version=${{ github.event.inputs.version || '0.0.0.0' }};branch=${GITHUB_REF#refs/heads/};commit=${GITHUB_SHA}" echo "::endgroup::" done - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: NuGet packages path: '*.nupkg' - name: Push to nuget.org - if: env.NUGET_API_KEY && startsWith(github.event.inputs.branch, 'chromium/') && github.event.inputs.version && github.event.inputs.nuget == 'true' + if: env.NUGET_API_KEY && startsWith(github.event.inputs.branch, 'chromium/') && github.event.inputs.version && github.event.inputs.publish == 'true' run: nuget push -Source nuget.org -ApiKey ${{ secrets.NUGET_API_KEY }} *.nupkg env: NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} @@ -591,17 +544,20 @@ jobs: if: github.event.inputs.version runs-on: ubuntu-latest needs: + - linux_arm - linux_arm64 - linux_x64 + - linux_x86 - mac_arm64 - mac_x64 - win_arm64 - win_x64 + - win_x86 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Download artifacts - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 - name: Create build script run: | cat >conda-build.sh <> $GITHUB_OUTPUT - name: Checkout this repo - uses: actions/checkout@v4 + uses: actions/checkout@v3 + - name: Workaround for libpcre2 i386 # https://github.com/actions/virtual-environments/issues/4589#issuecomment-1100899313 + if: inputs.target_os == 'android' + run: | + sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list + sudo apt-get update -qq + sudo apt-get install -yqq --allow-downgrades libpcre2-8-0/focal libpcre2-16-0/focal libpcre2-32-0/focal libpcre2-posix2/focal - name: Set environment variables run: | cat >>$GITHUB_ENV <> $GITHUB_OUTPUT - name: Download ${{ inputs.artifact_x64 }} - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: ${{ inputs.artifact_x64 }} path: ${{ inputs.artifact_x64 }} - name: Download ${{ inputs.artifact_arm64 }} - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: name: ${{ inputs.artifact_arm64 }} path: ${{ inputs.artifact_arm64 }} @@ -45,7 +45,7 @@ jobs: ${{ inputs.artifact_x64 }}/lib/libpdfium.dylib \ -output ${{ steps.init.outputs.artifact }}/lib/libpdfium.dylib - name: Upload artifact - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: ${{ steps.init.outputs.artifact }} path: ${{ steps.init.outputs.artifact }} diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml index 1c187f67..a4a2fd4a 100644 --- a/.github/workflows/patch.yml +++ b/.github/workflows/patch.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout this repo - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Install depot_tools run: | @@ -23,10 +23,8 @@ jobs: id: checkout timeout-minutes: 15 run: | - PDFium_BRANCH=$(git ls-remote --sort version:refname --refs https://pdfium.googlesource.com/pdfium.git 'chromium/*' | tail -n 1 | cut -d/ -f3-4) - echo "Checking out branch $PDFium_BRANCH" gclient config --unmanaged "https://pdfium.googlesource.com/pdfium.git" --custom-var "checkout_configuration=minimal" - gclient sync -r "origin/${PDFium_BRANCH}" --no-history --shallow + gclient sync --no-history --shallow - name: Create patch script run: | diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index 3ca23f6f..9b4633d0 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -19,21 +19,16 @@ jobs: BUILD=$(echo "$VERSION" | cut -d. -f3) echo "version=$VERSION" >> $GITHUB_OUTPUT echo "branch=chromium/$BUILD" >> $GITHUB_OUTPUT - - name: Get date - id: date - run: | - echo "day=$(date +%-d)" >> $GITHUB_OUTPUT - name: Trigger build uses: benc-uk/workflow-dispatch@v1 with: workflow: Build all + token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" inputs: | { "branch": "${{ steps.chromium.outputs.branch }}", "version": "${{ steps.chromium.outputs.version }}", "is_debug": "false", "enable_v8": "true", - "release": "true", - "nuget": "true", - "anaconda": "${{ steps.date.outputs.day <= 7 && 'true' || 'false' }}" + "publish": "true" } diff --git a/.gitignore b/.gitignore index d2c1508b..461ebab5 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,6 @@ /staging/ /build/ *.tgz -/*-musl*-cross/ +/*-musl-cross/ /android-ndk* /conda/out/ \ No newline at end of file diff --git a/README.md b/README.md index 8f0114e8..7e77c53c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Latest release](https://img.shields.io/github/v/release/bblanchon/pdfium-binaries?display_name=release&label=github)](https://github.com/bblanchon/pdfium-binaries/releases/latest/) [![Nuget](https://img.shields.io/nuget/v/bblanchon.PDFium)](https://www.nuget.org/packages/bblanchon.PDFium/) -[![Conda](https://img.shields.io/conda/v/bblanchon/pdfium-binaries?label=conda)](https://anaconda.org/bblanchon/pdfium-binaries) +![Conda](https://img.shields.io/conda/v/bblanchon/pdfium-binaries?label=conda) This project hosts pre-compiled binaries of the [PDFium library](https://pdfium.googlesource.com/pdfium/), an open-source library for PDF manipulation and rendering. @@ -87,12 +87,7 @@ Here are the download links for latest release: - Linux
musl - arm64 - pdfium-linux-musl-arm64.tgz - pdfium-v8-linux-musl-arm64.tgz - - + Linux
musl x64 pdfium-linux-musl-x64.tgz pdfium-v8-linux-musl-x64.tgz @@ -246,7 +241,6 @@ The following projects use (or recommend using) our PDFium builds: | [PDFtoZPL][pdftozpl] | C# | A .NET library to convert PDF files (and bitmaps) into Zebra Programming Language code | | [PDFx][pdfx] | Dart | Flutter Render & show PDF documents on Web, MacOs 10.11+, Android 5.0+, iOS and Windows | | [PyPDFium2][pypdfium2] | Python | Python bindings to PDFium | -| [Spacedrive][spacedrive] | Rust/TS | Cross-platform file manager, powered by a virtual distributed filesystem | | [wxPDFView][wxpdfview] | C++ | wxWidgets components to display PDF content | *Did we miss a project? Please open a PR!* @@ -318,4 +312,3 @@ The following projects use (or recommend using) our PDFium builds: [pdflibcore]: https://github.com/jbaarssen/PdfLibCore [dtronixpdf]: https://github.com/Dtronix/DtronixPdf [pdftozpl]: https://github.com/sungaila/PDFtoZPL -[spacedrive]: https://github.com/spacedriveapp/spacedrive diff --git a/nuget/bblanchon.PDFium.Linux.nuspec b/nuget/bblanchon.PDFium.Linux.nuspec index d9944eb5..bd3be848 100644 --- a/nuget/bblanchon.PDFium.Linux.nuspec +++ b/nuget/bblanchon.PDFium.Linux.nuspec @@ -30,11 +30,6 @@ - - - - - @@ -46,7 +41,6 @@ - diff --git a/nuget/bblanchon.PDFium.Linux.targets b/nuget/bblanchon.PDFium.Linux.targets deleted file mode 100644 index a1210af3..00000000 --- a/nuget/bblanchon.PDFium.Linux.targets +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - PreserveNewest - x86\libpdfium.so - false - - - PreserveNewest - x64\libpdfium.so - false - - - PreserveNewest - arm\libpdfium.so - false - - - PreserveNewest - arm64\libpdfium.so - false - - - - - PreserveNewest - musl-x86\libpdfium.so - false - - - PreserveNewest - musl-x64\libpdfium.so - false - - - PreserveNewest - musl-arm64\libpdfium.so - false - - - \ No newline at end of file diff --git a/nuget/bblanchon.PDFium.WebAssembly.nuspec b/nuget/bblanchon.PDFium.WebAssembly.nuspec index 0205ebc9..bda6fbc4 100644 --- a/nuget/bblanchon.PDFium.WebAssembly.nuspec +++ b/nuget/bblanchon.PDFium.WebAssembly.nuspec @@ -18,6 +18,7 @@ README.md + @@ -27,6 +28,14 @@ + + + + + + + + diff --git a/nuget/bblanchon.PDFium.WebAssembly.props b/nuget/bblanchon.PDFium.WebAssembly.props new file mode 100644 index 00000000..2438b0a5 --- /dev/null +++ b/nuget/bblanchon.PDFium.WebAssembly.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nuget/bblanchon.PDFium.macOS.nuspec b/nuget/bblanchon.PDFium.macOS.nuspec index 762fd30c..c1979d09 100644 --- a/nuget/bblanchon.PDFium.macOS.nuspec +++ b/nuget/bblanchon.PDFium.macOS.nuspec @@ -30,11 +30,6 @@ - - - - - diff --git a/nuget/bblanchon.PDFium.macOS.targets b/nuget/bblanchon.PDFium.macOS.targets deleted file mode 100644 index 91c15b69..00000000 --- a/nuget/bblanchon.PDFium.macOS.targets +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - PreserveNewest - libpdfium.dylib - false - - - \ No newline at end of file diff --git a/nuget/bblanchon.PDFiumV8.Linux.nuspec b/nuget/bblanchon.PDFiumV8.Linux.nuspec index c27ec769..111ecd97 100644 --- a/nuget/bblanchon.PDFiumV8.Linux.nuspec +++ b/nuget/bblanchon.PDFiumV8.Linux.nuspec @@ -30,11 +30,6 @@ - - - - - @@ -46,7 +41,6 @@ - diff --git a/nuget/bblanchon.PDFiumV8.macOS.nuspec b/nuget/bblanchon.PDFiumV8.macOS.nuspec index 8268ec47..c79bfbc8 100644 --- a/nuget/bblanchon.PDFiumV8.macOS.nuspec +++ b/nuget/bblanchon.PDFiumV8.macOS.nuspec @@ -30,11 +30,6 @@ - - - - - diff --git a/patches/android/build.patch b/patches/android/pdfium.patch similarity index 53% rename from patches/android/build.patch rename to patches/android/pdfium.patch index 41d4fc66..c1b025d1 100644 --- a/patches/android/build.patch +++ b/patches/android/pdfium.patch @@ -1,8 +1,8 @@ -diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn -index 105e194..50499f6 100644 ---- a/config/BUILDCONFIG.gn -+++ b/config/BUILDCONFIG.gn -@@ -479,6 +479,9 @@ if (is_fuchsia) { +diff --git a/build_overrides/BUILDCONFIG.gn b/build_overrides/BUILDCONFIG.gn +index 768fe60e0..72c510471 100644 +--- a/build_overrides/BUILDCONFIG.gn ++++ b/build_overrides/BUILDCONFIG.gn +@@ -475,6 +475,9 @@ if (is_android) { } set_defaults("shared_library") { configs = default_shared_library_configs diff --git a/patches/ios/v8.patch b/patches/ios/v8.patch deleted file mode 100644 index 65f41ec3..00000000 --- a/patches/ios/v8.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/BUILD.gn b/BUILD.gn -index d905b219a22..1610f1adae9 100644 ---- a/BUILD.gn -+++ b/BUILD.gn -@@ -4753,9 +4753,6 @@ v8_header_set("v8_internal_headers") { - } - - frameworks = [] -- if (is_ios) { -- frameworks += [ "BrowserEngineKit.framework" ] -- } - - public_deps = [ - ":torque_runtime_support", diff --git a/patches/musl/build.patch b/patches/musl/build.patch index a4aa21bf..17458d61 100644 --- a/patches/musl/build.patch +++ b/patches/musl/build.patch @@ -1,38 +1,13 @@ -diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn -index 26a23e459..666d775c3 100644 ---- a/config/BUILDCONFIG.gn -+++ b/config/BUILDCONFIG.gn -@@ -135,6 +135,9 @@ declare_args() { - # set "is_official_build" to true for any build intended to ship to end-users. - is_official_build = false - -+ # Use musl instead of glibc -+ is_musl = false -+ - # Set to true when compiling with the Clang compiler. - is_clang = current_os != "linux" || - (current_cpu != "s390x" && current_cpu != "s390" && -@@ -237,7 +240,9 @@ if (target_os == "android") { - _default_toolchain = "//build/toolchain/android:android_clang_$target_cpu" - } else if (target_os == "chromeos" || target_os == "linux") { - # See comments in build/toolchain/cros/BUILD.gn about board compiles. -- if (is_clang) { -+ if (is_musl) { -+ _default_toolchain = "//build/toolchain/linux/musl:$target_cpu" -+ } else if (is_clang) { - _default_toolchain = "//build/toolchain/linux:clang_$target_cpu" - } else { - _default_toolchain = "//build/toolchain/linux:$target_cpu" diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn -index f991e525c..ff42e2799 100644 +index cbf73722e..73b048a6a 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn -@@ -379,7 +379,7 @@ config("compiler") { - } else { - cflags += [ "-fstack-protector" ] +@@ -362,7 +362,7 @@ config("compiler") { } -- } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) { -+ } else if ((is_posix && !is_chromeos && !is_nacl && !is_musl) || is_fuchsia) { - if (current_os != "aix") { + + # The x86 toolchain currently has problems with stack-protector. +- if (is_android && current_cpu == "x86") { ++ if ((is_android || is_musl) && current_cpu == "x86") { + cflags += [ "-fno-stack-protector" ] + } else if (current_os != "aix") { # Not available on aix. - cflags += [ "-fstack-protector" ] diff --git a/patches/musl/pdfium.patch b/patches/musl/pdfium.patch new file mode 100644 index 00000000..877cba2f --- /dev/null +++ b/patches/musl/pdfium.patch @@ -0,0 +1,25 @@ +diff --git a/build_overrides/BUILDCONFIG.gn b/build_overrides/BUILDCONFIG.gn +index 2b9bbd6..a7f3b6e 100644 +--- a/build_overrides/BUILDCONFIG.gn ++++ b/build_overrides/BUILDCONFIG.gn +@@ -139,6 +139,9 @@ declare_args() { + # set "is_official_build" to true for any build intended to ship to end-users. + is_official_build = false + ++ # Use musl instead of glibc ++ is_musl = false ++ + # Set to true when compiling with the Clang compiler. + is_clang = current_os != "linux" || + (current_cpu != "s390x" && current_cpu != "s390" && +@@ -241,7 +244,9 @@ if (target_os == "android") { + _default_toolchain = "//build/toolchain/android:android_clang_$target_cpu" + } else if (target_os == "chromeos" || target_os == "linux") { + # See comments in build/toolchain/cros/BUILD.gn about board compiles. +- if (is_clang) { ++ if (is_musl) { ++ _default_toolchain = "//build/toolchain/linux/musl:$target_cpu" ++ } else if (is_clang) { + _default_toolchain = "//build/toolchain/linux:clang_$target_cpu" + } else { + _default_toolchain = "//build/toolchain/linux:$target_cpu" diff --git a/patches/musl/toolchain.gn b/patches/musl/toolchain.gn index ab4b39f7..f3fe091b 100644 --- a/patches/musl/toolchain.gn +++ b/patches/musl/toolchain.gn @@ -43,48 +43,3 @@ gcc_toolchain("x64") { is_clang = false } } - -gcc_toolchain("arm") { - toolprefix = "arm-linux-musleabihf-" - - cc = "${toolprefix}gcc" - cxx = "${toolprefix}g++" - - readelf = "${toolprefix}readelf" - nm = "${toolprefix}nm" - ar = "${toolprefix}ar" - ld = cxx - - extra_ldflags = "-static-libgcc -static-libstdc++" - - toolchain_args = { - current_cpu = "arm" - current_os = "linux" - - use_remoteexec = false - is_clang = false - } -} - -gcc_toolchain("arm64") { - toolprefix = "aarch64-linux-musl-" - - cc = "${toolprefix}gcc" - cxx = "${toolprefix}g++" - - readelf = "${toolprefix}readelf" - nm = "${toolprefix}nm" - ar = "${toolprefix}ar" - ld = cxx - - extra_cxxflags= "-flax-vector-conversions" # issue #150 - extra_ldflags = "-static-libgcc -static-libstdc++" - - toolchain_args = { - current_cpu = "arm64" - current_os = "linux" - - use_remoteexec = false - is_clang = false - } -} diff --git a/patches/musl/zlib.patch b/patches/musl/zlib.patch deleted file mode 100644 index 95f0a9c0..00000000 --- a/patches/musl/zlib.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/crc32_simd.c b/crc32_simd.c -index cbe9739..4d01b1b 100644 ---- a/crc32_simd.c -+++ b/crc32_simd.c -@@ -398,7 +398,7 @@ uint32_t ZLIB_INTERNAL crc32_sse42_simd_( /* SSE4.2+PCLMUL */ - */ - #include - #include --#define TARGET_ARMV8_WITH_CRC __attribute__((target("arch=armv8-a+crc"))) -+#define TARGET_ARMV8_WITH_CRC - #else // !defined(__GNUC__) && !defined(_aarch64__) - #error ARM CRC32 SIMD extensions only supported for Clang and GCC - #endif diff --git a/patches/v8/pdfium.patch b/patches/v8/pdfium.patch index 952235f1..a199045a 100644 --- a/patches/v8/pdfium.patch +++ b/patches/v8/pdfium.patch @@ -1,18 +1,18 @@ diff --git a/fpdfsdk/fpdf_view.cpp b/fpdfsdk/fpdf_view.cpp -index 6b0a1c161..7a8788676 100644 +index 723af28..8088d0c 100644 --- a/fpdfsdk/fpdf_view.cpp +++ b/fpdfsdk/fpdf_view.cpp -@@ -57,6 +57,9 @@ - +@@ -60,6 +60,9 @@ #ifdef PDF_ENABLE_V8 #include "fxjs/cfx_v8_array_buffer_allocator.h" + #include "third_party/base/no_destructor.h" +#include "v8/include/libplatform/libplatform.h" +#include "v8/include/v8-array-buffer.h" +#include "v8/include/v8-initialization.h" #endif #ifdef PDF_ENABLE_XFA -@@ -117,6 +120,11 @@ namespace { +@@ -116,6 +119,11 @@ namespace { bool g_bLibraryInitialized = false; @@ -21,10 +21,10 @@ index 6b0a1c161..7a8788676 100644 +v8::Isolate* g_isolate = nullptr; +#endif + - void SetRendererType(FPDF_RENDERER_TYPE public_type) { + void UseRendererType(FPDF_RENDERER_TYPE public_type) { // Internal definition of renderer types must stay updated with respect to // the public definition, such that all public definitions can be mapped to -@@ -229,6 +237,22 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config) { +@@ -221,6 +229,22 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config) { if (g_bLibraryInitialized) return; @@ -45,9 +45,9 @@ index 6b0a1c161..7a8788676 100644 +#endif // PDF_ENABLE_V8 + FX_InitializeMemoryAllocators(); - CFX_Timer::InitializeGlobals(); CFX_GEModule::Create(config ? config->m_pUserFontPaths : nullptr); -@@ -242,14 +266,13 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config) { + CPDF_PageModule::Create(); +@@ -229,14 +253,13 @@ FPDF_InitLibraryWithConfig(const FPDF_LIBRARY_CONFIG* config) { CPDFXFA_ModuleInit(); #endif // PDF_ENABLE_XFA @@ -60,17 +60,17 @@ index 6b0a1c161..7a8788676 100644 +#endif // PDF_ENABLE_V8 + + if (config && config->version >= 4) -+ SetRendererType(config->m_RendererType); ++ UseRendererType(config->m_RendererType); - if (config->version >= 4) -- SetRendererType(config->m_RendererType); +- UseRendererType(config->m_RendererType); - } g_bLibraryInitialized = true; } -@@ -275,6 +298,19 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary() { - CFX_Timer::DestroyGlobals(); - FX_DestroyMemoryAllocators(); +@@ -252,6 +275,19 @@ FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyLibrary() { + CFX_GEModule::Destroy(); + IJS_Runtime::Destroy(); +#ifdef PDF_ENABLE_XFA + cppgc::ShutdownProcess(); diff --git a/patches/wasm/build.patch b/patches/wasm/build.patch index 31f8bb39..f851de37 100644 --- a/patches/wasm/build.patch +++ b/patches/wasm/build.patch @@ -1,29 +1,8 @@ -diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn -index 894e82b45..abce54b59 100644 ---- a/config/BUILDCONFIG.gn -+++ b/config/BUILDCONFIG.gn -@@ -268,6 +268,8 @@ if (target_os == "android") { - _default_toolchain = "//build/toolchain/aix:$target_cpu" - } else if (target_os == "zos") { - _default_toolchain = "//build/toolchain/zos:$target_cpu" -+} else if (target_cpu == "wasm") { -+ _default_toolchain = "//build/toolchain/wasm:emscripten" - } else { - assert(false, "Unsupported target_os: $target_os") - } -@@ -306,6 +308,7 @@ is_linux = current_os == "linux" - is_mac = current_os == "mac" - is_nacl = current_os == "nacl" - is_win = current_os == "win" || current_os == "winuwp" -+is_wasm = current_os == "wasm" - - is_apple = is_ios || is_mac - is_posix = !is_win && !is_fuchsia diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn -index 3c7b4d82d..da0d72cc1 100644 +index cbf73722e..34f92c793 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn -@@ -318,6 +318,8 @@ config("compiler") { +@@ -293,6 +293,8 @@ config("compiler") { configs += [ "//build/config/aix:compiler" ] } else if (current_os == "zos") { configs += [ "//build/config/zos:compiler" ] @@ -32,20 +11,20 @@ index 3c7b4d82d..da0d72cc1 100644 } configs += [ -@@ -380,7 +382,7 @@ config("compiler") { - cflags += [ "-fstack-protector" ] - } - } else if ((is_posix && !is_chromeos && !is_nacl) || is_fuchsia) { -- if (current_os != "aix") { -+ if (current_os != "aix" && current_os != "wasm") { +@@ -364,7 +366,7 @@ config("compiler") { + # The x86 toolchain currently has problems with stack-protector. + if (is_android && current_cpu == "x86") { + cflags += [ "-fno-stack-protector" ] +- } else if (current_os != "aix") { ++ } else if (current_os != "aix" && current_os != "wasm") { # Not available on aix. cflags += [ "-fstack-protector" ] } diff --git a/toolchain/toolchain.gni b/toolchain/toolchain.gni -index 14aa5f76d..b4af1af50 100644 +index 42973fa82..f46dcde12 100644 --- a/toolchain/toolchain.gni +++ b/toolchain/toolchain.gni -@@ -58,6 +58,8 @@ if (is_apple) { +@@ -52,6 +52,8 @@ if (is_apple) { shlib_extension = ".so" } else if (is_win) { shlib_extension = ".dll" diff --git a/patches/wasm/pdfium.patch b/patches/wasm/pdfium.patch index 6fe9052c..f745b1f5 100644 --- a/patches/wasm/pdfium.patch +++ b/patches/wasm/pdfium.patch @@ -1,26 +1,47 @@ +diff --git a/build_overrides/BUILDCONFIG.gn b/build_overrides/BUILDCONFIG.gn +index 768fe60e0..65afd1de4 100644 +--- a/build_overrides/BUILDCONFIG.gn ++++ b/build_overrides/BUILDCONFIG.gn +@@ -272,6 +272,8 @@ if (target_os == "android") { + _default_toolchain = "//build/toolchain/aix:$target_cpu" + } else if (target_os == "zos") { + _default_toolchain = "//build/toolchain/zos:$target_cpu" ++} else if (target_cpu == "wasm") { ++ _default_toolchain = "//build/toolchain/wasm:emscripten" + } else { + assert(false, "Unsupported target_os: $target_os") + } +@@ -310,6 +312,7 @@ is_linux = current_os == "linux" + is_mac = current_os == "mac" + is_nacl = current_os == "nacl" + is_win = current_os == "win" || current_os == "winuwp" ++is_wasm = current_os == "wasm" + + is_apple = is_ios || is_mac + is_posix = !is_win && !is_fuchsia diff --git a/core/fxcrt/BUILD.gn b/core/fxcrt/BUILD.gn -index 90b9ec7..1e9be68 100644 +index 09400e881..f05d55a04 100644 --- a/core/fxcrt/BUILD.gn +++ b/core/fxcrt/BUILD.gn -@@ -150,7 +150,7 @@ source_set("fxcrt") { +@@ -140,7 +140,7 @@ source_set("fxcrt") { } else { sources += [ "fx_memory_malloc.cpp" ] } -- if (is_posix) { -+ if (is_posix || is_wasm) { +- if (is_posix || is_fuchsia) { ++ if (is_posix || is_fuchsia || is_wasm) { sources += [ "cfx_fileaccess_posix.cpp", "cfx_fileaccess_posix.h", diff --git a/core/fxge/BUILD.gn b/core/fxge/BUILD.gn -index 215a63b..e52e9b6 100644 +index 8d4138131..958650952 100644 --- a/core/fxge/BUILD.gn +++ b/core/fxge/BUILD.gn -@@ -160,7 +160,7 @@ source_set("fxge") { +@@ -163,7 +163,7 @@ source_set("fxge") { ] } -- if (is_linux || is_chromeos) { -+ if (is_linux || is_chromeos || is_wasm) { +- if (is_linux || is_chromeos || is_fuchsia) { ++ if (is_linux || is_chromeos || is_fuchsia || is_wasm) { sources += [ "linux/fx_linux_impl.cpp" ] } diff --git a/patches/win/build.patch b/patches/win/build.patch index 129438fa..5a62bb1d 100644 --- a/patches/win/build.patch +++ b/patches/win/build.patch @@ -1,13 +1,13 @@ diff --git a/toolchain/win/toolchain.gni b/toolchain/win/toolchain.gni -index abb7d6228..3b74bda76 100644 +index 968a4a20e..536295050 100644 --- a/toolchain/win/toolchain.gni +++ b/toolchain/win/toolchain.gni -@@ -259,7 +259,7 @@ template("msvc_toolchain") { +@@ -235,7 +235,7 @@ template("single_msvc_toolchain") { } tool("rc") { - command = "\"$python_path\" $_tool_wrapper_path rc-wrapper $env rc.exe /nologo $sys_include_flags{{defines}} {{include_dirs}} /fo{{output}} {{source}}" -+ command = "rc.exe /nologo $sys_include_flags{{defines}} {{include_dirs}} /fo{{output}} /dENV=$env {{source}}" ++ command = "rc.exe /nologo $sys_include_flags{{defines}} {{include_dirs}} /fo{{output}} {{source}}" depsformat = "msvc" outputs = [ "$object_subdir/{{source_name_part}}.res" ] description = "RC {{output}}" diff --git a/patches/win/pdfium.patch b/patches/win/pdfium.patch new file mode 100644 index 00000000..9c244fa6 --- /dev/null +++ b/patches/win/pdfium.patch @@ -0,0 +1,12 @@ +diff --git a/core/fxge/win32/cgdi_printer_driver.cpp b/core/fxge/win32/cgdi_printer_driver.cpp +index 28bc516bc..aa4cb0452 100644 +--- a/core/fxge/win32/cgdi_printer_driver.cpp ++++ b/core/fxge/win32/cgdi_printer_driver.cpp +@@ -15,6 +15,7 @@ + #include "core/fxcrt/fx_memory.h" + #include "core/fxcrt/fx_system.h" + #include "core/fxcrt/retain_ptr.h" ++#include "core/fxcrt/widestring.h" + #include "core/fxge/cfx_font.h" + #include "core/fxge/cfx_windowsrenderdevice.h" + #include "core/fxge/dib/cfx_dibbase.h" diff --git a/steps/01-install.sh b/steps/01-install.sh index f01210a0..e87b3ba5 100755 --- a/steps/01-install.sh +++ b/steps/01-install.sh @@ -20,9 +20,6 @@ echo "$DepotTools_DIR" >> "$PATH_FILE" case "$TARGET_OS" in android) - sudo apt-get update - sudo apt-get install -y unzip - # pdfium installs its version of the NDK, but we need one for compiling the example ANDROID_NDK_VERSION="r25c" ANDROID_NDK_FOLDER="android-ndk-$ANDROID_NDK_VERSION" @@ -52,16 +49,6 @@ case "$TARGET_OS" in MUSL_VERSION="x86_64-linux-musl-cross" PACKAGES="g++-10" ;; - - arm) - MUSL_VERSION="arm-linux-musleabihf-cross" - PACKAGES="g++-10" - ;; - - arm64) - MUSL_VERSION="aarch64-linux-musl-cross" - PACKAGES="g++-10" - ;; esac [ -d "$MUSL_VERSION" ] || curl -L "$MUSL_URL/$MUSL_VERSION.tgz" | tar xz @@ -75,11 +62,11 @@ case "$TARGET_OS" in case "$TARGET_CPU" in arm) - sudo apt-get install -y libc6-i386 gcc-10-multilib g++-10-arm-linux-gnueabihf gcc-10-arm-linux-gnueabihf + sudo apt-get install -y libc6-i386 gcc-9-multilib g++-9-arm-linux-gnueabihf gcc-9-arm-linux-gnueabihf ;; arm64) - sudo apt-get install -y libc6-i386 gcc-10-multilib g++-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu + sudo apt-get install -y libc6-i386 gcc-9-multilib g++-9-aarch64-linux-gnu gcc-9-aarch64-linux-gnu ;; x86) @@ -101,8 +88,8 @@ case "$TARGET_OS" in git clone https://github.com/emscripten-core/emsdk.git fi pushd emsdk - ./emsdk install ${EMSDK_VERSION:-3.1.34} - ./emsdk activate ${EMSDK_VERSION:-3.1.34} + ./emsdk install 3.1.34 + ./emsdk activate 3.1.34 echo "$PWD/upstream/emscripten" >> "$PATH_FILE" echo "$PWD/upstream/bin" >> "$PATH_FILE" popd diff --git a/steps/03-patch.sh b/steps/03-patch.sh index d3edc8e3..d71c3c46 100755 --- a/steps/03-patch.sh +++ b/steps/03-patch.sh @@ -14,12 +14,11 @@ git apply -v "$PATCHES/public_headers.patch" case "$OS" in android) - git -C build apply -v "$PATCHES/android/build.patch" + git apply -v "$PATCHES/android/pdfium.patch" ;; ios) git apply -v "$PATCHES/ios/pdfium.patch" - [ "${PDFium_ENABLE_V8:-}" == "true" ] && git -C v8 apply -v "$PATCHES/ios/v8.patch" ;; wasm) @@ -32,6 +31,7 @@ case "$OS" in ;; win) + git apply -v "$PATCHES/win/pdfium.patch" git -C build apply -v "$PATCHES/win/build.patch" VERSION=${PDFium_VERSION:-0.0.0.0} @@ -44,8 +44,8 @@ esac case "$TARGET_LIBC" in musl) + git apply -v "$PATCHES/musl/pdfium.patch" git -C build apply -v "$PATCHES/musl/build.patch" - git -C third_party/zlib apply -v "$PATCHES/musl/zlib.patch" mkdir -p "build/toolchain/linux/musl" cp "$PATCHES/musl/toolchain.gn" "build/toolchain/linux/musl/BUILD.gn" ;; diff --git a/steps/04-install-extras.sh b/steps/04-install-extras.sh index cc577e57..43479b1c 100755 --- a/steps/04-install-extras.sh +++ b/steps/04-install-extras.sh @@ -8,12 +8,12 @@ pushd "$SOURCE" case "$OS" in linux) - build/install-build-deps.sh - gclient runhooks build/linux/sysroot_scripts/install-sysroot.py "--arch=$CPU" ;; android) + sudo apt-get update + sudo apt-get remove -y php7.4-common build/install-build-deps.sh --android gclient runhooks ;; diff --git a/steps/05-configure.sh b/steps/05-configure.sh index 778bf1ba..634caca2 100755 --- a/steps/05-configure.sh +++ b/steps/05-configure.sh @@ -13,7 +13,6 @@ mkdir -p "$BUILD" ( echo "is_debug = $IS_DEBUG" echo "pdf_is_standalone = true" - echo "pdf_use_partition_alloc = false" echo "target_cpu = \"$TARGET_CPU\"" echo "target_os = \"$OS\"" echo "pdf_enable_v8 = $ENABLE_V8" @@ -27,25 +26,20 @@ mkdir -p "$BUILD" fi case "$OS" in - android) - echo "clang_use_chrome_plugins = false" - echo "default_min_sdk_version = 21" - ;; ios) echo "ios_enable_code_signing = false" echo "use_blink = true" [ "$ENABLE_V8" == "true" ] && [ "$TARGET_CPU" == "arm64" ] && echo 'arm_control_flow_integrity = "none"' - echo "clang_use_chrome_plugins = false" ;; linux) - echo "clang_use_chrome_plugins = false" + echo 'use_allocator_shim = false' ;; mac) echo 'mac_deployment_target = "10.13.0"' - echo "clang_use_chrome_plugins = false" ;; wasm) echo 'pdf_is_complete_lib = true' + echo 'pdf_use_partition_alloc = false' echo 'is_clang = false' ;; esac @@ -55,17 +49,7 @@ mkdir -p "$BUILD" echo 'is_musl = true' echo 'is_clang = false' echo 'use_custom_libcxx = false' - [ "$ENABLE_V8" == "true" ] && case "$TARGET_CPU" in - arm) - echo "v8_snapshot_toolchain = \"//build/toolchain/linux:clang_x86_v8_arm\"" - ;; - arm64) - echo "v8_snapshot_toolchain = \"//build/toolchain/linux:clang_x64_v8_arm64\"" - ;; - *) - echo "v8_snapshot_toolchain = \"//build/toolchain/linux:$TARGET_CPU\"" - ;; - esac + [ "$ENABLE_V8" == "true" ] && echo "v8_snapshot_toolchain = \"//build/toolchain/linux:$TARGET_CPU\"" ;; esac diff --git a/steps/07-stage.sh b/steps/07-stage.sh index ae73273e..d8497156 100755 --- a/steps/07-stage.sh +++ b/steps/07-stage.sh @@ -37,6 +37,7 @@ case "$OS" in mv "$BUILD/pdfium.html" "$STAGING_LIB" mv "$BUILD/pdfium.js" "$STAGING_LIB" mv "$BUILD/pdfium.wasm" "$STAGING_LIB" + mv "$BUILD/obj/libpdfium.a" "$STAGING_LIB" rm -rf "$STAGING/include/cpp" rm "$STAGING/PDFiumConfig.cmake" ;; diff --git a/steps/08-test.sh b/steps/08-test.sh index 700b8ec7..adf9c98e 100755 --- a/steps/08-test.sh +++ b/steps/08-test.sh @@ -56,20 +56,12 @@ case "$OS" in linux) case "$CPU" in arm) - if [ "$TARGET_LIBC" == "musl" ]; then - PREFIX="arm-linux-musleabihf-" - else - PREFIX="arm-linux-gnueabihf-" - SUFFIX="-10" - fi + PREFIX="arm-linux-gnueabihf-" + SUFFIX="-9" ;; arm64) - if [ "$TARGET_LIBC" == "musl" ]; then - PREFIX="aarch64-linux-musl-" - else - PREFIX="aarch64-linux-gnu-" - SUFFIX="-10" - fi + PREFIX="aarch64-linux-gnu-" + SUFFIX="-9" ;; x86) if [ "$TARGET_LIBC" == "musl" ]; then @@ -126,7 +118,7 @@ case "$OS" in ;; esac CMAKE_ARGS+=( - -G "Visual Studio 17 2022" + -G "Visual Studio 16 2019" -A "$ARCH" ) ;;