~mcf/mupdf

ref: e27ceb2b0e64b9a56ba79d844ea96553d87dc113 mupdf/platform/wasm/Makefile -rw-r--r-- 1.3 KiB
e27ceb2b — Robin Watts OSS-Fuzz 29728: Avoid buffer overflow. 1 year, 6 months ago
                                                                                
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
MUPDF_JS := libmupdf.js
MUPDF_WASM := libmupdf.wasm

SAMPLE_PDF := pdfref13.pdf

all: $(MUPDF_JS)

EMSDK_DIR := /opt/emsdk
MUPDF_CORE := ../../build/wasm/libmupdf.a ../../build/wasm/libmupdf-third.a
$(MUPDF_CORE) : .FORCE
	$(MAKE) -j4 -C ../.. \
		OUT=wasm build=release \
		XCFLAGS='-DTOFU -DTOFU_CJK -DFZ_ENABLE_SVG=0 -DFZ_ENABLE_HTML=0 -DFZ_ENABLE_EPUB=0 -DFZ_ENABLE_JS=0' \
		generate
	BASH_SOURCE=$(EMSDK_DIR)/emsdk_env.sh; \
	. $(EMSDK_DIR)/emsdk_env.sh; \
	$(MAKE) -j4 -C ../.. \
		OS=wasm build=release \
		XCFLAGS='-DTOFU -DTOFU_CJK -DFZ_ENABLE_SVG=0 -DFZ_ENABLE_HTML=0 -DFZ_ENABLE_EPUB=0 -DFZ_ENABLE_JS=0' \
		libs

wasm: $(MUPDF_JS) $(MUPDF_WASM)
$(MUPDF_JS) $(MUPDF_WASM) : $(MUPDF_CORE) wrap.c wrap.js
	BASH_SOURCE=$(EMSDK_DIR)/emsdk_env.sh; . $(EMSDK_DIR)/emsdk_env.sh; \
	emcc -Wall -Os -o $@ \
		-s WASM=1 \
		-s VERBOSE=0 \
		-s ABORTING_MALLOC=0 \
		-s TOTAL_MEMORY=134217728 \
		-s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall","cwrap"]' \
		-I ../../include \
		--pre-js wrap.js \
		wrap.c \
		../../build/wasm/release/libmupdf.a \
		../../build/wasm/release/libmupdf-third.a

run: $(SAMPLE_PDF) $(MUPDF_JS) $(MUDPF_WASM)
	python3 -m http.server 8000
	sleep 3
	xdg-open http://127.0.0.1:8000/view.html?file=$(SAMPLE_PDF) &

clean:
	rm -f $(MUPDF_JS) $(MUPDF_WASM)

nuke: clean
	$(MAKE) -C ../../ OS=wasm build=release clean

.PHONY: .FORCE clean