forked from desertnet/pcre
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
43 lines (33 loc) · 1.28 KB
/
Makefile
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
# ----------------------------------------------------------------------
# Compile dependencies and our bridge C code to WebAssembly,
# using emscripten.
# ----------------------------------------------------------------------
EMSCRIPTEN_DOCKER_RUN=docker run --rm -v $(CURDIR)/deps/build:/src -v $(CURDIR)/src/lib:/src/lib -u emscripten trzeci/emscripten:sdk-tag-1.39.4-64bit
CC=$(EMSCRIPTEN_DOCKER_RUN) emcc
export
# ----------------------------------------------------------------------
.PHONY: all deps
all: dist/libpcre2.js
dist:
mkdir -p dist
deps:
$(MAKE) -C deps
# ----------------------------------------------------------------------
dist/libpcre2.js: src/lib/libpcre2.c src/lib/config.js | deps dist
$(CC) /src/lib/libpcre2.c \
-s WASM=1 \
-O3 \
-g2 \
--pre-js /src/lib/config.js \
-s EXPORTED_FUNCTIONS='["_malloc", "_free"]' \
-s EXTRA_EXPORTED_RUNTIME_METHODS='["cwrap", "ccall", "getValue"]' \
-s BINARYEN=1 \
-s FILESYSTEM=0 \
-s ASSERTIONS=2 \
-I/src/local/include \
-L/src/local/lib \
-lpcre2-16 \
-o libpcre2.js
sed -i '' 's/throw new WebAssembly.RuntimeError(what)/\/\/ throw new WebAssembly.RuntimeError(what)/' deps/build/libpcre2.js
cp deps/build/libpcre2.{wasm,js} dist/
# ----------------------------------------------------------------------