-
Notifications
You must be signed in to change notification settings - Fork 68
/
Makefile
57 lines (50 loc) · 1.82 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
ifdef NO_CONTEXT
CPP_CONTEXT_LIB =
else
CPP_CONTEXT_LIB = ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.cc
endif
PROTOBUF ?= none
ifeq ($(PROTOBUF), full)
PROTO_DEPS := protobuf
PROTO_OPTS := -DPROXY_WASM_PROTOBUF_FULL=1 \
${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.pb.cc
else ifeq ($(PROTOBUF), lite)
PROTO_DEPS := protobuf-lite
PROTO_OPTS := -DPROXY_WASM_PROTOBUF_LITE=1 \
${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics_lite.pb.cc \
${PROXY_WASM_CPP_SDK}/struct_lite.pb.cc
else
PROTO_DEPS :=
PROTO_OPTS :=
endif
# Provide a list of libraries that the wasm depends on (absl_*, re2, etc).
WASM_DEPS ?=
# Determine dependency link options.
# NOTE: Strip out -pthread which RE2 claims to need...
PKG_CONFIG ?= pkg-config
PKG_CONFIG_PATH = ${EMSDK}/upstream/emscripten/cache/sysroot/lib/pkgconfig
WASM_LIBS = $(shell $(PKG_CONFIG) $(WASM_DEPS) $(PROTO_DEPS) \
--with-path=$(PKG_CONFIG_PATH) --libs | sed -e 's/-pthread //g')
debug-deps:
# WASM_DEPS : ${WASM_DEPS}
# WASM_LIBS : ${WASM_LIBS}
# PROTO_DEPS: ${PROTO_DEPS}
# PROTO_OPTS: ${PROTO_OPTS}
# TODO(mpwarres): Add Emscripten stack/heap size params in PR#174.
%.wasm %.wat: %.cc
em++ --no-entry -sSTANDALONE_WASM -sEXPORTED_FUNCTIONS=_malloc \
--std=c++17 -O3 -flto \
--js-library ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.js \
-I${PROXY_WASM_CPP_SDK} \
${CPP_CONTEXT_LIB} \
${PROTO_OPTS} \
${WASM_LIBS} \
$*.cc -o $*.wasm
clean:
rm *.wasm
# NOTE: How to regenerate .pb.h and .pb.cc files for a protobuf update:
# - download + extract protobuf release (currently v26.1)
# - regenerate:
# ./bin/protoc --cpp_out=../ -I../ -Iinclude/google/protobuf/ ../struct_lite.proto
# ./bin/protoc --cpp_out=../ -I../ -Iinclude/google/protobuf/ ../proxy_wasm_intrinsics_lite.proto
# ./bin/protoc --cpp_out=../ -I../ -Iinclude/google/protobuf/ ../proxy_wasm_intrinsics.proto