Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/wasm/cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
all: proxy_wasm_intrinsics.pb.h proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h

proxy_wasm_intrinsics.pb.h: proxy_wasm_intrinsics.proto
protoc --cpp_out=. proxy_wasm_intrinsics.proto

proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h: proxy_wasm_intrinsics_lite.proto
protoc --cpp_out=. proxy_wasm_intrinsics_lite.proto
protoc --cpp_out=. struct_lite.proto

2 changes: 1 addition & 1 deletion api/wasm/cpp/Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ else
endif

%.wasm %.wat: %.cc ${API}/proxy_wasm_intrinsics.h ${API}/proxy_wasm_intrinsics.js
em++ -s WASM=1 -s LEGALIZE_JS_FFI=0 -s EMIT_EMSCRIPTEN_METADATA=1 --std=c++17 -O3 -g3 -I${API} --js-library ${API}/proxy_wasm_intrinsics.js $*.cc ${CONTEXT_LIB} -o $*.js
em++ -s WASM=1 -s LEGALIZE_JS_FFI=0 -s EMIT_EMSCRIPTEN_METADATA=1 --std=c++17 -O3 -g3 -I${API} -I/usr/local/include --js-library ${API}/proxy_wasm_intrinsics.js $*.cc ${API}/proxy_wasm_intrinsics.pb.cc ${CONTEXT_LIB} ${API}/libprotobuf.bc -o $*.js
wavm-disas $*.wasm $*.wat
wavm-compile $*.wasm $*.wasm
rm -f $*.js $*.wast
Expand Down
17 changes: 17 additions & 0 deletions api/wasm/cpp/Makefile.base_lite
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
API:=$(shell git rev-parse --show-toplevel)/api/wasm/cpp

ifdef NO_CONTEXT
CONTEXT_LIB =
else
CONTEXT_LIB = ${API}/proxy_wasm_intrinsics.cc
endif

%.wasm %.wat: %.cc ${API}/proxy_wasm_intrinsics.h ${API}/proxy_wasm_intrinsics.js
em++ -s WASM=1 -s LEGALIZE_JS_FFI=0 -s EMIT_EMSCRIPTEN_METADATA=1 --std=c++17 -O3 -g3 -DEMSCRIPTEN_PROTOBUF_LITE=1 -I${API} -I${API}/google/protobuf -I/usr/local/include --js-library ${API}/proxy_wasm_intrinsics.js $*.cc ${API}/proxy_wasm_intrinsics_lite.pb.cc ${API}/struct_lite.pb.cc ${CONTEXT_LIB} ${API}/libprotobuf-lite.bc -o $*.js
wavm-disas $*.wasm $*.wat
wavm-compile $*.wasm $*.wasm
rm -f $*.js $*.wast
chmod 644 $*.wat

clean:
rm *.wasm *.wat
7 changes: 7 additions & 0 deletions api/wasm/cpp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dependencies for building WASM modules:

- You must install the version of protobuf on your build system that matches the libprotobuf.bc files (without any patches) so that the generated code matches the .bc library.
Currently this is based on tag v3.6.1 of https://github.com/protocolbuffers/protobuf.

- If want to rebuild the .bc files or use a different version see the instructions at https://github.com/kwonoj/protobuf-wasm (note: this is pinned to git tag v3.6.1)
A pre-patched repo is available at https://github.com/jplevyak/protobuf branch envoy-wasm
Binary file added api/wasm/cpp/libprotobuf-lite.bc
Binary file not shown.
Binary file added api/wasm/cpp/libprotobuf.bc
Binary file not shown.
Loading