Skip to content

Commit

Permalink
Merge pull request #53 from paulo-coutinho/version-4692
Browse files Browse the repository at this point in the history
version 4692
  • Loading branch information
Paulo Coutinho authored Nov 6, 2021
2 parents 540c05f + 5a98361 commit 6a89bec
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 58 deletions.
2 changes: 1 addition & 1 deletion docker/android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ WORKDIR /build
RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
RUN gclient sync
WORKDIR /build/pdfium
RUN git checkout affa0ec49277441f4f42efcf8d0894d82e2d4604
RUN git checkout 31722577db9dc12a249ca6cdf2ff34e51a998360

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip
Expand Down
2 changes: 1 addition & 1 deletion docker/wasm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ WORKDIR /build
RUN gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
RUN gclient sync
WORKDIR /build/pdfium
RUN git checkout c2ff7477dae94b94de39d11b7bde23169ea8a306
RUN git checkout 31722577db9dc12a249ca6cdf2ff34e51a998360

RUN ln -s /usr/bin/python3 /usr/bin/python
RUN ln -s /usr/bin/pip3 /usr/bin/pip
Expand Down
10 changes: 5 additions & 5 deletions docs/BUILD_ANDROID.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

1. Execute all **general** steps

2. PDFium android dependencies
```./build/android/pdfium/build/install-build-deps-android.sh```

3. Get PDFium:
2. Get PDFium:
```python3 make.py run build-pdfium-android```

4. Patch:
3. Patch:
```python3 make.py run patch-android```

4. PDFium Android dependencies
```./build/android/pdfium/build/install-build-deps-android.sh```

5. Compile:
```python3 make.py run build-android```

Expand Down
12 changes: 6 additions & 6 deletions docs/BUILD_WASM.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

1. Execute all **general** steps

2. PDFium linux dependencies
```./build/linux/pdfium/build/install-build-deps.sh```

3. Get Emscripten SDK:
2. Get Emscripten SDK:
```python3 make.py run build-emsdk```

4. Get PDFium:
3. Get PDFium:
```python3 make.py run build-pdfium-wasm```

5. Patch:
4. Patch:
```python3 make.py run patch-wasm```

5. PDFium Linux dependencies
```./build/linux/pdfium/build/install-build-deps.sh```

6. Compile:
```python3 make.py run build-wasm```

Expand Down
4 changes: 2 additions & 2 deletions extras/wasm/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.2/css/bulma.min.css">

<script src="pdfium.js?v=4637"></script>
<script src="pdfium.js?v={pdfium-branch}"></script>

<script>
// variables
Expand Down Expand Up @@ -1032,7 +1032,7 @@ <h1 id="fileTitle" class="title" style="display: none;">PDF Viewer</h1>
everything run only on client side.
</p>
<p>
PDFium branch "4637" and commit "affa0ec49277441f4f42efcf8d0894d82e2d4604".
PDFium branch "{pdfium-branch}" and commit "{pdfium-commit}".
</p>
</div>
</footer>
Expand Down
6 changes: 2 additions & 4 deletions modules/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def run_task_patch():
source_dir,
"BUILD.gn",
)
if f.file_line_has_content(source_file, 25, " ]\n"):
f.replace_line_in_file(source_file, 25, ' "FPDFSDK_EXPORTS",\n ]\n')
if f.file_line_has_content(source_file, 26, " ]\n"):
f.replace_line_in_file(source_file, 26, ' "FPDFSDK_EXPORTS",\n ]\n')

f.debug("Applied: Build GN")
else:
Expand All @@ -71,8 +71,6 @@ def run_task_patch():
else:
f.debug("Skipped: Build GN Flags")

pass


def run_task_build():
f.debug("Building libraries...")
Expand Down
6 changes: 3 additions & 3 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
targets = ["ios", "macos", "android"]

# pdfium
pdfium_git_branch = "4637"
pdfium_git_commit = "affa0ec49277441f4f42efcf8d0894d82e2d4604"
# ^ ref: https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/4637
pdfium_git_branch = "4692"
pdfium_git_commit = "31722577db9dc12a249ca6cdf2ff34e51a998360"
# ^ ref: https://pdfium.googlesource.com/pdfium/+/refs/heads/chromium/4692
# 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)

Expand Down
29 changes: 14 additions & 15 deletions modules/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ def run_task_patch():
source_dir,
"BUILD.gn",
)
if not f.file_line_has_content(source_file, 247, '#test("pdfium_unittests") {\n'):
f.file_line_comment_range(
source_file, 247, 294
) # comment all lines of "pdfium_unittests"
f.file_line_comment_range(
source_file, 385, 386
) # group "pdfium_all", comment all tests
if not f.file_line_has_content(source_file, 408, '#test("pdfium_unittests") {\n'):
# comment all lines of "pdfium_unittests"
f.file_line_comment_range(source_file, 408, 455)

# group "pdfium_all", comment all tests (pdfium_embeddertests and pdfium_unittests)
f.file_line_comment_range(source_file, 546, 547)

f.debug("Applied: Build GN")
else:
Expand All @@ -65,9 +64,9 @@ def run_task_patch():
"BUILD.gn",
)
if f.file_line_has_content(
source_file, 56, ' cflags += [ "-Wdeprecated-copy" ]\n'
source_file, 217, ' cflags += [ "-Wdeprecated-copy" ]\n'
):
f.file_line_comment(source_file, 56)
f.file_line_comment(source_file, 217)

f.debug("Applied: Deprecated Warning")
else:
Expand Down Expand Up @@ -116,8 +115,8 @@ def run_task_patch():
"compiler",
"BUILD.gn",
)
if f.file_line_has_content(source_file, 1707, ' "-Wimplicit-fallthrough",\n'):
f.file_line_comment(source_file, 1707)
if f.file_line_has_content(source_file, 1611, ' "-Wimplicit-fallthrough",\n'):
f.file_line_comment(source_file, 1611)

f.debug("Applied: Compiler")
else:
Expand Down Expand Up @@ -174,9 +173,9 @@ def run_task_patch():
"rules.gni",
)
if not f.file_line_has_content(
source_file, 954, '# data_deps += [ "//testing/iossim" ]\n'
source_file, 964, '# data_deps += [ "//testing/iossim" ]\n'
):
f.file_line_comment(source_file, 954)
f.file_line_comment(source_file, 964)

f.debug("Applied: iOS Simulator")
else:
Expand Down Expand Up @@ -240,11 +239,11 @@ def run_task_patch():
"BUILD.gn",
)
if f.file_line_has_content(
source_file, 1237, ' cflags += [ "-ffile-compilation-dir=." ]\n'
source_file, 1262, ' cflags += [ "-ffile-compilation-dir=." ]\n'
):
f.replace_line_in_file(
source_file,
1237,
1262,
' cflags += ["-Xclang","-fdebug-compilation-dir","-Xclang","."]\n',
)

Expand Down
4 changes: 2 additions & 2 deletions modules/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ def run_task_patch():
)
if not f.file_line_has_content(
source_file,
55,
57,
'use_arm_neon_optimizations = (current_cpu == "arm" || current_cpu == "arm64")\n',
):
f.replace_line_in_file(
source_file,
55,
57,
'use_arm_neon_optimizations = (current_cpu == "arm" || current_cpu == "arm64")\n\n',
)

Expand Down
67 changes: 48 additions & 19 deletions modules/wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
219,
380,
' configs -= [ "//build/config/compiler:thin_archive" ]\n',
):
f.replace_line_in_file(
source_file,
219,
380,
' #configs -= [ "//build/config/compiler:thin_archive" ]\n',
)

Expand All @@ -115,22 +115,22 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
853,
878,
' "-m64",\n',
):
f.replace_line_in_file(
source_file,
853,
878,
' #"-m64",\n',
)
f.replace_line_in_file(
source_file,
854,
879,
' #"-march=$x64_arch",\n',
)
f.replace_line_in_file(
source_file,
855,
880,
' #"-msse3",\n',
)

Expand All @@ -148,12 +148,12 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
1626,
1520,
' "-Wno-ignored-pragma-optimize",\n',
):
f.replace_line_in_file(
source_file,
1626,
1520,
' "-Wno-deprecated-register",\n',
)

Expand All @@ -171,12 +171,12 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
2406,
2308,
' cflags += [ "-ggnu-pubnames" ]\n',
):
f.replace_line_in_file(
source_file,
2406,
2308,
' #cflags += [ "-ggnu-pubnames" ]\n',
)

Expand All @@ -193,17 +193,17 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
677,
740,
' cc = "$prefix/clang"\n',
):
f.replace_line_in_file(
source_file,
677,
740,
' cc = "emcc"\n',
)
f.replace_line_in_file(
source_file,
678,
741,
' cxx = "em++"\n',
)

Expand Down Expand Up @@ -245,18 +245,18 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
333,
335,
' cflags += [ "-fstack-protector" ]\n',
):
f.replace_line_in_file(
source_file,
333,
335,
' cflags += [ "-fno-stack-protector" ]\n',
)

f.replace_line_in_file(
source_file,
345,
347,
' cflags += [ "-fno-stack-protector" ]\n',
)

Expand Down Expand Up @@ -296,12 +296,12 @@ def run_task_patch():
)
if f.file_line_has_content(
source_file,
494,
497,
' cflags += [ "-pthread" ]\n',
):
f.replace_line_in_file(
source_file,
494,
497,
' #cflags += [ "-pthread" ]\n',
)

Expand Down Expand Up @@ -333,6 +333,29 @@ def run_task_patch():
else:
f.debug("Skipped: skia pthread")

# compiler bitwise
source_file = os.path.join(
source_dir,
"build",
"config",
"compiler",
"BUILD.gn",
)
if f.file_line_has_content(
source_file,
1534,
' "-Wno-bitwise-instead-of-logical",\n',
):
f.replace_line_in_file(
source_file,
1534,
' #"-Wno-bitwise-instead-of-logical",\n',
)

f.debug("Applied: compiler bitwise")
else:
f.debug("Skipped: compiler bitwise")

# copy files required
f.debug("Copying required files...")

Expand Down Expand Up @@ -519,10 +542,16 @@ def run_task_test():
current_dir = os.getcwd()
sample_dir = os.path.join(current_dir, "sample-wasm")
build_dir = os.path.join(sample_dir, "build")
http_dir = os.path.join("sample-wasm", "build")
http_dir = os.path.join(sample_dir, "build")

for config in c.configurations_wasm:
for target in c.targets_wasm:
f.debug(
'Generating test files to arch "{0}" and configuration "{1}"...'.format(
target["target_cpu"], config
)
)

lib_file_out = os.path.join(
current_dir,
"build",
Expand Down
2 changes: 2 additions & 0 deletions sample-wasm/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

int main(int argc, char **argv)
{
// sample: https://github.com/lukas-w/pdfium/blob/master/docs/getting-started.md

std::cout << "Starting..." << std::endl;

FPDF_LIBRARY_CONFIG config;
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

int main(int argc, char **argv)
{
// sample: https://github.com/lukas-w/pdfium/blob/master/docs/getting-started.md

std::cout << "Starting..." << std::endl;

FPDF_LIBRARY_CONFIG config;
Expand Down

0 comments on commit 6a89bec

Please sign in to comment.