-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-wasm.sh
56 lines (45 loc) · 1.31 KB
/
build-wasm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash -eux
while getopts b: OPTION
do
case $OPTION in
b)
BRANCH="$OPTARG"
;;
esac
done
# chckout
gclient config \
--unmanaged https://pdfium.googlesource.com/pdfium.git \
--custom-var "checkout_configuration=minimal"
gclient sync --no-history --shallow -r ${BRANCH:-main}
cd pdfium
# patch
git apply -v /root/build-host/patch/pdfium.patch
git -C build apply -v /root/build-host/patch/build/build.patch
mkdir -p build/toolchain/wasm
cp /root/build-host/patch/build/toolchain/wasm/BUILD.gn build/toolchain/wasm
mkdir -p build/config/wasm
cp /root/build-host/patch/build/config/wasm/BUILD.gn build/config/wasm
mkdir -p out
cp /root/build-host/patch/out/args.gn out
# install additional tools
./build/install-build-deps.sh
# build
EXPORTED_FUNCTIONS=`grep -v -e '^\s*#' -e '^\s*$' /root/build-host/exported-functions.txt | sed 's/^/_/' | tr '\n' ',' | sed -e 's/,$/\n/g'`
gn gen out
ninja -C out pdfium
em++ \
--no-entry \
-s LLD_REPORT_UNDEFINED \
-s ALLOW_MEMORY_GROWTH=1 \
-s WASM=1 \
-s MODULARIZE=1 \
-s EXPORT_ES6=0 \
-s EXPORT_NAME=pdfium \
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" \
-s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \
-o out/pdfium.js \
out/obj/libpdfium.a
# copy wasm
mkdir -p /root/build-host/dist
cp -f out/pdfium.js out/pdfium.wasm /root/build-host/dist