diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 98cb3f5..e93b354 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -16,60 +16,78 @@ jobs: matrix: config: - { name: "Ubuntu", os: "ubuntu-20.04", target: "android" } - python-version: [3.7] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Install System Packages + run: | + sudo apt-get -y update && \ + sudo apt-get remove -y php7.4-common && \ + sudo rm -rf /var/lib/apt/lists/* && \ + sudo apt-get clean + + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" - name: Upgrade PIP run: python3 -m pip install --upgrade pip setuptools wheel - - name: Display Python version - run: python3 --version + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: "3.24.0" - - name: Display PIP version - run: python3 -m pip --version + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + with: + version: "1.10.0" - - name: Python requirements - run: python3 -m pip install -r requirements.txt --user + - name: Install NDK + uses: nttld/setup-ndk@v1 + id: setup-ndk + with: + ndk-version: r25c + add-to-path: true - - name: Remove trash + - name: Verify run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "$AGENT_TOOLSDIRECTORY" + python3 --version + cmake --version + ninja --version + ndk-build -version + + - name: Python requirements + run: python3 -m pip install -r requirements.txt --user - - name: Docker build - run: docker build -t pdfium-android -f docker/android/Dockerfile docker/android + - name: Depot tools + run: python3 make.py build-depot-tools - - name: Docker test - run: docker run -v ${PWD}:/app -i -t=false pdfium-android echo "test" + - name: Environment + run: echo "$PWD/build/depot-tools" >> $GITHUB_PATH - name: PDFium - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py build-pdfium-${{ matrix.config.target }} + run: python3 make.py build-pdfium-${{ matrix.config.target }} - name: Patch - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py patch-${{ matrix.config.target }} + run: python3 make.py patch-${{ matrix.config.target }} - name: Patch - Check - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py patch-${{ matrix.config.target }} + run: python3 make.py patch-${{ matrix.config.target }} - name: Build - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py build-${{ matrix.config.target }} + run: python3 make.py build-${{ matrix.config.target }} - name: Install - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py install-${{ matrix.config.target }} + run: python3 make.py install-${{ matrix.config.target }} - name: Test - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py test-${{ matrix.config.target }} + run: python3 make.py test-${{ matrix.config.target }} - name: Archive - run: docker run -v ${PWD}:/app -i -t=false pdfium-android python3 make.py archive-${{ matrix.config.target }} + run: python3 make.py archive-${{ matrix.config.target }} - name: Save uses: actions/upload-artifact@v2 diff --git a/.github/workflows/ios.yml b/.github/workflows/ios.yml index a4f7976..2682200 100644 --- a/.github/workflows/ios.yml +++ b/.github/workflows/ios.yml @@ -7,10 +7,6 @@ on: - 'docs/**' - 'extras/images/**' -env: - CMAKE_VERSION: "3.24.0" - NINJA_VERSION: "1.10.0" - jobs: build: name: ${{ matrix.config.name }} @@ -20,66 +16,33 @@ jobs: matrix: config: - { name: "macOS", os: "macos-latest", target: "ios" } - python-version: [3.7] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" - name: Upgrade PIP run: python3 -m pip install --upgrade pip setuptools wheel - - name: Display Python version - run: python3 --version + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: "3.24.0" - - name: Display PIP version - run: python3 -m pip --version + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + with: + version: "1.10.0" - - name: Install Ninja and CMake - id: cmake_and_ninja - shell: cmake -P {0} + - name: Verify run: | - set(cmake_version $ENV{CMAKE_VERSION}) - set(ninja_version $ENV{NINJA_VERSION}) - - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - - if ("${{ runner.os }}" STREQUAL "Windows") - set(ninja_suffix "win.zip") - set(cmake_suffix "win64-x64.zip") - set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(ninja_suffix "linux.zip") - set(cmake_suffix "Linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(ninja_suffix "mac.zip") - set(cmake_suffix "Darwin-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin") - endif() - - set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") - file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) - - set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") - file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) - - # Save the path for other steps - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) - message("::set-output name=cmake_dir::${cmake_dir}") - - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process( - COMMAND chmod +x ninja - COMMAND chmod +x ${cmake_dir}/cmake - ) - endif() + python3 --version + cmake --version + ninja --version - name: Python requirements run: python3 -m pip install -r requirements.txt --user @@ -88,9 +51,7 @@ jobs: run: python3 make.py build-depot-tools - name: Environment - run: | - echo "$PWD/build/depot-tools" >> $GITHUB_PATH - echo "FORCE_MAC_SDK_MIN=10.15" >> $GITHUB_ENV + run: echo "$PWD/build/depot-tools" >> $GITHUB_PATH - name: PDFium run: python3 make.py build-pdfium-${{ matrix.config.target }} diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index c5222b4..ff30cdd 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -7,10 +7,6 @@ on: - 'docs/**' - 'extras/images/**' -env: - CMAKE_VERSION: "3.24.0" - NINJA_VERSION: "1.10.0" - jobs: build: name: ${{ matrix.config.name }} @@ -19,67 +15,34 @@ jobs: fail-fast: false matrix: config: - - { name: "macOS", os: "macos-12", target: "macos" } - python-version: [3.7] + - { name: "macOS", os: "macos-latest", target: "macos" } steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" - name: Upgrade PIP run: python3 -m pip install --upgrade pip setuptools wheel - - name: Display Python version - run: python3 --version + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: "3.24.0" - - name: Display PIP version - run: python3 -m pip --version + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + with: + version: "1.10.0" - - name: Install Ninja and CMake - id: cmake_and_ninja - shell: cmake -P {0} + - name: Verify run: | - set(cmake_version $ENV{CMAKE_VERSION}) - set(ninja_version $ENV{NINJA_VERSION}) - - message(STATUS "Using host CMake version: ${CMAKE_VERSION}") - - if ("${{ runner.os }}" STREQUAL "Windows") - set(ninja_suffix "win.zip") - set(cmake_suffix "win64-x64.zip") - set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") - elseif ("${{ runner.os }}" STREQUAL "Linux") - set(ninja_suffix "linux.zip") - set(cmake_suffix "Linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") - elseif ("${{ runner.os }}" STREQUAL "macOS") - set(ninja_suffix "mac.zip") - set(cmake_suffix "Darwin-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin") - endif() - - set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") - file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip) - - set(cmake_url "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/cmake-${cmake_version}-${cmake_suffix}") - file(DOWNLOAD "${cmake_url}" ./cmake.zip SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./cmake.zip) - - # Save the path for other steps - file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/${cmake_dir}" cmake_dir) - message("::set-output name=cmake_dir::${cmake_dir}") - - if (NOT "${{ runner.os }}" STREQUAL "Windows") - execute_process( - COMMAND chmod +x ninja - COMMAND chmod +x ${cmake_dir}/cmake - ) - endif() + python3 --version + cmake --version + ninja --version - name: Python requirements run: python3 -m pip install -r requirements.txt --user @@ -88,9 +51,7 @@ jobs: run: python3 make.py build-depot-tools - name: Environment - run: | - echo "$PWD/build/depot-tools" >> $GITHUB_PATH - echo "FORCE_MAC_SDK_MIN=10.15" >> $GITHUB_ENV + run: echo "$PWD/build/depot-tools" >> $GITHUB_PATH - name: PDFium run: python3 make.py build-pdfium-${{ matrix.config.target }} diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index a753a19..1cb581a 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -16,57 +16,85 @@ jobs: matrix: config: - { name: "Ubuntu", os: "ubuntu-20.04", target: "wasm" } - python-version: [3.7] steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} + - name: Install System Packages + run: | + sudo apt-get install -y doxygen + doxygen --version + + - name: Set up Python uses: actions/setup-python@v1 with: - python-version: ${{ matrix.python-version }} + python-version: "3.10" - name: Upgrade PIP run: python3 -m pip install --upgrade pip setuptools wheel - - name: Display Python version - run: python3 --version + - name: Install CMake + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: "3.24.0" + + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + with: + version: "1.10.0" - - name: Display PIP version - run: python3 -m pip --version + - name: Install EMSDK + uses: mymindstorm/setup-emsdk@v11 + with: + version: "3.1.50" + + - name: Install Node + uses: actions/setup-node@v3 + with: + node-version: '19' + architecture: 'x64' + + - name: Verify + run: | + python3 --version + cmake --version + ninja --version + node --version + npm --version + emcc -v - name: Python requirements run: python3 -m pip install -r requirements.txt --user - - name: Docker build - run: docker build -t pdfium-wasm -f docker/wasm/Dockerfile docker/wasm + - name: Depot tools + run: python3 make.py build-depot-tools - - name: Docker test - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm echo "test" + - name: Environment + run: echo "$PWD/build/depot-tools" >> $GITHUB_PATH - name: PDFium - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py build-pdfium-${{ matrix.config.target }} + run: python3 make.py build-pdfium-${{ matrix.config.target }} - name: Patch - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py patch-${{ matrix.config.target }} + run: python3 make.py patch-${{ matrix.config.target }} - name: Patch - Check - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py patch-${{ matrix.config.target }} + run: python3 make.py patch-${{ matrix.config.target }} - name: Build - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py build-${{ matrix.config.target }} + run: python3 make.py build-${{ matrix.config.target }} - name: Install - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py install-${{ matrix.config.target }} + run: python3 make.py install-${{ matrix.config.target }} - name: Test - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py test-${{ matrix.config.target }} + run: python3 make.py test-${{ matrix.config.target }} - name: Generate - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py generate-${{ matrix.config.target }} + run: python3 make.py generate-${{ matrix.config.target }} - name: Archive - run: docker run -v ${PWD}:/app -i -t=false pdfium-wasm python3 make.py archive-${{ matrix.config.target }} + run: python3 make.py archive-${{ matrix.config.target }} - name: Save uses: actions/upload-artifact@v2 diff --git a/docker/android/Dockerfile b/docker/android/Dockerfile index 7fbe331..e60c09b 100644 --- a/docker/android/Dockerfile +++ b/docker/android/Dockerfile @@ -49,17 +49,36 @@ RUN wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-b RUN gradle --version # google depot tools -RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /opt/depot-tools +ENV DEPOT_TOOLS_UPDATE=0 +ENV DEPOT_TOOLS_WIN_TOOLCHAIN=0 +RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -b main /opt/depot-tools ENV PATH=${PATH}:/opt/depot-tools -# pdfium - dependencies +# pdfium RUN mkdir /build WORKDIR /build -RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git -RUN gclient sync +RUN gclient config --custom-var checkout_configuration=minimal --unmanaged https://pdfium.googlesource.com/pdfium.git +RUN echo "target_os = [ 'android' ]" >> .gclient +RUN gclient sync -r origin/chromium/6183 --no-history --shallow + +# pdfium reset and clean directories +RUN git -C /build/pdfium reset --hard +RUN git -C /build/pdfium clean -df + +RUN git -C /build/pdfium/build reset --hard +RUN git -C /build/pdfium/build clean -df + +RUN git -C /build/pdfium/third_party/libjpeg_turbo reset --hard +RUN git -C /build/pdfium/third_party/libjpeg_turbo clean -df + +RUN git -C /build/pdfium/base/allocator/partition_allocator reset --hard +RUN git -C /build/pdfium/base/allocator/partition_allocator clean -df + +# pdfium checkout WORKDIR /build/pdfium -RUN git checkout 9eec95782c4ecdae50cd8c8e9f88d3f8941db1cd +RUN git status +# system dependencies RUN ln -s /usr/bin/python3 /usr/bin/python RUN ln -s /usr/bin/pip3 /usr/bin/pip diff --git a/docker/wasm/Dockerfile b/docker/wasm/Dockerfile index 41f6880..0fe9521 100644 --- a/docker/wasm/Dockerfile +++ b/docker/wasm/Dockerfile @@ -28,17 +28,36 @@ RUN echo ${JAVA_HOME} RUN java -version # google depot tools -RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /opt/depot-tools +ENV DEPOT_TOOLS_UPDATE=0 +ENV DEPOT_TOOLS_WIN_TOOLCHAIN=0 +RUN git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git -b main /opt/depot-tools ENV PATH=${PATH}:/opt/depot-tools -# pdfium - dependencies +# pdfium RUN mkdir /build WORKDIR /build -RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git -RUN gclient sync +RUN gclient config --custom-var checkout_configuration=minimal --unmanaged https://pdfium.googlesource.com/pdfium.git +RUN echo "target_os = [ 'wasm' ]" >> .gclient +RUN gclient sync -r origin/chromium/6183 --no-history --shallow + +# pdfium reset and clean directories +RUN git -C /build/pdfium reset --hard +RUN git -C /build/pdfium clean -df + +RUN git -C /build/pdfium/build reset --hard +RUN git -C /build/pdfium/build clean -df + +RUN git -C /build/pdfium/third_party/libjpeg_turbo reset --hard +RUN git -C /build/pdfium/third_party/libjpeg_turbo clean -df + +RUN git -C /build/pdfium/base/allocator/partition_allocator reset --hard +RUN git -C /build/pdfium/base/allocator/partition_allocator clean -df + +# pdfium checkout WORKDIR /build/pdfium -RUN git checkout 9eec95782c4ecdae50cd8c8e9f88d3f8941db1cd +RUN git status +# system dependencies RUN ln -s /usr/bin/python3 /usr/bin/python RUN ln -s /usr/bin/pip3 /usr/bin/pip @@ -60,8 +79,8 @@ RUN pip3 install setuptools docopt pygemstones RUN mkdir /emsdk WORKDIR /emsdk RUN git clone https://github.com/emscripten-core/emsdk.git . -RUN ./emsdk install 3.1.45 -RUN ./emsdk activate 3.1.45 +RUN ./emsdk install 3.1.50 +RUN ./emsdk activate 3.1.50 ENV PATH="${PATH}:/emsdk:/emsdk/upstream/emscripten" # cache system libraries diff --git a/extras/wasm/template/index.html b/extras/wasm/template/index.html index ec05ee8..b28acd1 100644 --- a/extras/wasm/template/index.html +++ b/extras/wasm/template/index.html @@ -145,7 +145,7 @@ getRender(i = 0, w, h) { const flag = FPDF.REVERSE_BYTE_ORDER | FPDF.ANNOT; - const heap = Module.asm.malloc(w * h * C); + const heap = Module.wasmExports.malloc(w * h * C); for (let i = 0; i < w * h * C; i++) { Module.HEAPU8[heap + i] = 0; @@ -170,7 +170,7 @@ pageRenderData.push(Module.HEAPU8[pageRenderPtr + v]); } - Module.asm.free(pageRenderPtr); + Module.wasmExports.free(pageRenderPtr); return pageRenderData; } @@ -255,7 +255,7 @@ page.render(); if (index === doc.pages.length - 1) { - Module.asm.free(wasmBuffer); + Module.wasmExports.free(wasmBuffer); FPDF.CloseDocument(wasm); FPDF.DestroyLibrary(); @@ -375,7 +375,7 @@ // load document to memory console.log('Loading data to buffer...'); - let wasmBuffer = Module.asm.malloc(fileSize); + let wasmBuffer = Module.wasmExports.malloc(fileSize); Module.HEAPU8.set(fileByteArray, wasmBuffer); // create document @@ -852,8 +852,8 @@ case Float32Array: E = Module.HEAPF32; break; case Float64Array: E = Module.HEAPF64; break; } - const Z = J.BYTES_PER_ELEMENT; const m = Module.asm.malloc(s * Z); - const a = Array(1 + s); a[0] = ({ s, J, Z, E, m, free: () => Module.asm.free(m) }); + const Z = J.BYTES_PER_ELEMENT; const m = Module.wasmExports.malloc(s * Z); + const a = Array(1 + s); a[0] = ({ s, J, Z, E, m, free: () => Module.wasmExports.free(m) }); for (let i = 0; i < s; i++) a[i + 1] = ({ p: m + (i * Z), get v() { return E[m / Z + i]; } }); return a; }; @@ -1199,7 +1199,7 @@

PDF Viewer

everything run only on client side.

- PDFium branch "{pdfium-branch}" and commit "{pdfium-commit}". + PDFium branch "{pdfium-branch}".

diff --git a/modules/android.py b/modules/android.py index a8626b1..d02e9db 100644 --- a/modules/android.py +++ b/modules/android.py @@ -20,62 +20,36 @@ def run_task_patch(): source_dir = os.path.join("build", "android", "pdfium") - # build gn - source_file = os.path.join( - source_dir, - "BUILD.gn", - ) + # shared lib + source_file = os.path.join(source_dir, "BUILD.gn") - original_content = 'include_dirs = [ "." ]\n defines = []' - has_patch = f.file_has_content(source_file, original_content) + original_content = 'component("pdfium") {' + has_content = f.file_has_content(source_file, original_content) - if has_patch: - new_content = 'include_dirs = [ "." ]\n defines = ["FPDFSDK_EXPORTS"]' + if has_content: + new_content = 'shared_library("pdfium") {' f.replace_in_file(source_file, original_content, new_content) - l.bullet("Applied: build gn", l.GREEN) + l.bullet("Applied: shared lib", l.GREEN) else: - l.bullet("Skipped: build gn", l.PURPLE) + l.bullet("Skipped: shared lib", l.PURPLE) - # build gn flags + # build config source_file = os.path.join( source_dir, - "BUILD.gn", - ) - - line_content = "cflags = []" - line_number = f.get_file_line_number_with_content( - source_file, line_content, strip=True + "build", + "config", + "BUILDCONFIG.gn", ) - if line_number: - content = ' cflags = [ "-fvisibility=default" ]' - - f.set_file_line_content(source_file, line_number, content, new_line=True) - - # more one - line_number = f.get_file_line_number_with_content( - source_file, line_content, strip=True - ) - - f.set_file_line_content(source_file, line_number, content, new_line=True) - - # more one - line_number = f.get_file_line_number_with_content( - source_file, line_content, strip=True - ) - - f.set_file_line_content(source_file, line_number, content, new_line=True) + original_content = 'set_defaults("shared_library") {\n configs = default_shared_library_configs\n}' + has_content = f.file_has_content(source_file, original_content) - # more one - line_number = f.get_file_line_number_with_content( - source_file, line_content, strip=True - ) - - f.set_file_line_content(source_file, line_number, content, new_line=True) - - l.bullet("Applied: build gn flags", l.GREEN) + if has_content: + new_content = 'set_defaults("shared_library") {\n configs = default_shared_library_configs\n\n if (is_android) {\n configs -= [ "//build/config/android:hide_all_but_jni_onload" ]\n }\n}' + f.replace_in_file(source_file, original_content, new_content) + l.bullet("Applied: build config", l.GREEN) else: - l.bullet("Skipped: build gn flags", l.PURPLE) + l.bullet("Skipped: build config", l.PURPLE) l.ok() @@ -125,10 +99,9 @@ def run_task_build(): args.append("is_debug={0}".format(arg_is_debug)) args.append("treat_warnings_as_errors=false") args.append("pdf_use_skia=false") - args.append("pdf_use_skia_paths=false") args.append("pdf_enable_xfa=false") args.append("pdf_enable_v8=false") - args.append("is_component_build=true") + args.append("is_component_build=false") args.append("pdf_is_standalone=true") args.append("pdf_bundle_freetype=true") diff --git a/modules/common.py b/modules/common.py index 7c0b026..e2a5765 100644 --- a/modules/common.py +++ b/modules/common.py @@ -30,6 +30,9 @@ def run_task_build_depot_tools(): l.colored("Execute on your terminal:", l.PURPLE) l.m("export PATH=$PATH:$PWD/build/depot-tools") + os.environ["DEPOT_TOOLS_UPDATE"] = "0" + os.environ["DEPOT_TOOLS_WIN_TOOLCHAIN"] = "0" + l.ok() diff --git a/modules/config.py b/modules/config.py index f69fddf..102c414 100644 --- a/modules/config.py +++ b/modules/config.py @@ -3,14 +3,13 @@ task = "" # pdfium -pdfium_git_branch = "6008" -pdfium_git_commit = "9eec95782c4ecdae50cd8c8e9f88d3f8941db1cd" -# ^ ref: https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/6008 +pdfium_git_branch = "chromium/6183" +# ^ ref: https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/6183 # OBS 1: don't forget change in android docker file (docker/android/Dockerfile) # OBS 2: don't forget change in wasm docker file (docker/wasm/Dockerfile) # emsdk -emsdk_version = "3.1.45" +emsdk_version = "3.1.50" # OBS 1: don't forget change in wasm docker file (docker/wasm/Dockerfile) # macos diff --git a/modules/ios.py b/modules/ios.py index 25d6d55..1c7dafd 100644 --- a/modules/ios.py +++ b/modules/ios.py @@ -125,7 +125,6 @@ def run_task_build(): args.append("is_debug={0}".format(arg_is_debug)) args.append("treat_warnings_as_errors=false") args.append("pdf_use_skia=false") - args.append("pdf_use_skia_paths=false") args.append("pdf_enable_xfa=false") args.append("pdf_enable_v8=false") args.append("is_component_build=false") diff --git a/modules/macos.py b/modules/macos.py index 349645f..46d9fd6 100644 --- a/modules/macos.py +++ b/modules/macos.py @@ -69,7 +69,6 @@ def run_task_build(): args.append("is_debug={0}".format(arg_is_debug)) args.append("treat_warnings_as_errors=false") args.append("pdf_use_skia=false") - args.append("pdf_use_skia_paths=false") args.append("pdf_enable_xfa=false") args.append("pdf_enable_v8=false") args.append("is_component_build=false") @@ -79,8 +78,9 @@ def run_task_build(): args.append("pdf_is_complete_lib=true") args.append("use_custom_libcxx=false") args.append("use_sysroot=false") - args.append('mac_deployment_target="10.13.0"') + args.append('mac_deployment_target="11.0.0"') args.append("pdf_use_partition_alloc=false") + args.append("use_allocator_shim=false") if config == "release": args.append("symbol_level=0") diff --git a/modules/pdfium.py b/modules/pdfium.py index e999796..db30b4e 100644 --- a/modules/pdfium.py +++ b/modules/pdfium.py @@ -8,45 +8,66 @@ # ----------------------------------------------------------------------------- -def get_pdfium_by_target(target, append_target_os=None): +def get_pdfium_by_target(target, append_target_os=True, enable_v8=False): l.colored("Building PDFium...", l.YELLOW) build_dir = os.path.join("build", target) f.create_dir(build_dir) + # remove old data l.colored("Removing old PDFium directory...", l.YELLOW) target_dir = os.path.join(build_dir, "pdfium") f.remove_dir(target_dir) + # clone pdfium l.colored("Cloning PDFium with gclient...", l.YELLOW) - - cwd = build_dir - command = [ + config_args = [ "gclient", "config", "--unmanaged", "https://pdfium.googlesource.com/pdfium.git", ] - r.run(command, cwd=cwd) + if not enable_v8: + config_args.extend(["--custom-var", "checkout_configuration=minimal"]) + + r.run(config_args, cwd=build_dir) + + # append target os if append_target_os: l.colored( - "Appending target os ({0}) to gclient file...".format(append_target_os), + "Appending target os ({}) to gclient file...".format(append_target_os), l.YELLOW, ) gclient_file = os.path.join(build_dir, ".gclient") - f.append_to_file(gclient_file, "target_os = [ '{0}' ]".format(append_target_os)) + f.append_to_file(gclient_file, "target_os = [ '{}' ]".format(append_target_os)) - l.colored("Syncing repository with gclient...", l.YELLOW) + l.colored(f"Syncing repository with branch {c.pdfium_git_branch}...", l.YELLOW) + r.run( + [ + "gclient", + "sync", + "-r", + f"origin/{c.pdfium_git_branch}", + "--no-history", + "--shallow", + ], + cwd=build_dir, + ) - cwd = build_dir - command = ["gclient", "sync"] - r.run(command, cwd=cwd) + # reset and clean directories + folders_to_reset = [ + "pdfium", + "pdfium/build", + "pdfium/third_party/libjpeg_turbo", + "pdfium/base/allocator/partition_allocator", + ] - l.colored("Checkout to git commit {0}...".format(c.pdfium_git_commit), l.YELLOW) + for folder in folders_to_reset: + full_path = os.path.join(build_dir, folder) - cwd = target_dir - command = ["git", "checkout", c.pdfium_git_commit] - r.run(command, cwd=cwd) + if os.path.exists(full_path): + r.run(["git", "reset", "--hard"], cwd=full_path) + r.run(["git", "clean", "-df"], cwd=full_path) l.ok() diff --git a/modules/wasm.py b/modules/wasm.py index e8b64a0..a2f3763 100644 --- a/modules/wasm.py +++ b/modules/wasm.py @@ -75,7 +75,8 @@ def run_task_patch(): # build overrides target source_file = os.path.join( source_dir, - "build_overrides", + "build", + "config", "BUILDCONFIG.gn", ) @@ -103,7 +104,8 @@ def run_task_patch(): # build overrides os source_file = os.path.join( source_dir, - "build_overrides", + "build", + "config", "BUILDCONFIG.gn", ) @@ -205,32 +207,32 @@ def run_task_patch(): else: l.bullet("Skipped: lib extension", l.PURPLE) - # partition allocator - source_file = os.path.join( - source_dir, - "base", - "allocator", - "partition_allocator", - "partition_alloc_base", - "threading", - "platform_thread_posix.cc", - ) - - line_content = ( - "#elif BUILDFLAG(IS_POSIX) && (BUILDFLAG(IS_AIX) || defined(OS_ASMJS))" - ) - line_number = f.get_file_line_number_with_content( - source_file, line_content, strip=True - ) - - if not line_number: - source = "#elif BUILDFLAG(IS_POSIX) && BUILDFLAG(IS_AIX)" - target = "#elif BUILDFLAG(IS_POSIX) && (BUILDFLAG(IS_AIX) || defined(OS_ASMJS))" - - f.replace_in_file(source_file, source, target) - l.bullet("Applied: partition allocator", l.GREEN) - else: - l.bullet("Skipped: partition allocator", l.PURPLE) + # # partition allocator + # source_file = os.path.join( + # source_dir, + # "base", + # "allocator", + # "partition_allocator", + # "partition_alloc_base", + # "threading", + # "platform_thread_posix.cc", + # ) + + # line_content = ( + # "#elif BUILDFLAG(IS_POSIX) && (BUILDFLAG(IS_AIX) || defined(OS_ASMJS))" + # ) + # line_number = f.get_file_line_number_with_content( + # source_file, line_content, strip=True + # ) + + # if not line_number: + # source = "#elif BUILDFLAG(IS_POSIX) && BUILDFLAG(IS_AIX)" + # target = "#elif BUILDFLAG(IS_POSIX) && (BUILDFLAG(IS_AIX) || defined(OS_ASMJS))" + + # f.replace_in_file(source_file, source, target) + # l.bullet("Applied: partition allocator", l.GREEN) + # else: + # l.bullet("Skipped: partition allocator", l.PURPLE) # fxcrt source_file = os.path.join( @@ -403,7 +405,6 @@ def run_task_build(): args.append("is_debug={0}".format(arg_is_debug)) args.append("treat_warnings_as_errors=false") args.append("pdf_use_skia=false") - args.append("pdf_use_skia_paths=false") args.append("pdf_enable_xfa=false") args.append("pdf_enable_v8=false") args.append("is_component_build=false") @@ -412,10 +413,9 @@ def run_task_build(): args.append("use_debug_fission=false") args.append("use_custom_libcxx=false") args.append("use_sysroot=false") - args.append("use_system_libjpeg=true") - args.append("use_system_zlib=true") args.append("pdf_is_complete_lib=true") args.append("pdf_use_partition_alloc=false") + args.append("is_clang=false") if config == "release": args.append("symbol_level=0") @@ -696,13 +696,13 @@ def run_task_generate(): command = [ "em++", - "{0}".format("-g" if config == "debug" else "-O3"), + "{0}".format("-g" if config == "debug" else "-O2"), "-o", output_file, "-s", 'EXPORTED_FUNCTIONS="$(node function-names ../xml/index.xml)"', "-s", - 'EXPORTED_RUNTIME_METHODS=\'["ccall", "cwrap"]\'', + 'EXPORTED_RUNTIME_METHODS=\'["ccall", "cwrap", "wasmExports"]\'', "custom.cpp", lib_file_out, "-I{0}".format(include_dir), @@ -749,12 +749,6 @@ def run_task_generate(): c.pdfium_git_branch, ) - f.replace_in_file( - os.path.join(node_dir, "index.html"), - "{pdfium-commit}", - c.pdfium_git_commit, - ) - # test l.colored( "Test on browser with: python3 -m http.server --directory {0}".format( @@ -815,7 +809,7 @@ def run_task_publish_to_web(): command = "git add ." r.run(command, cwd=publish_dir, shell=True) - command = 'git commit -m "new version published"' + command = f'git commit -m "version {c.pdfium_git_branch} published"' r.run(command, cwd=publish_dir, shell=True) command = "git branch -M master"