-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RE2 support + full Abseil Related cleanups: - Simpler Docker container - Single Makefile - Support for -flto - SDK proto upgrade to v26.1 - Updated build docs - More/independent examples - Remove protobuf CI check Signed-off-by: Martijn Stevenson <[email protected]>
- Loading branch information
1 parent
6b3dc93
commit 9dc95ae
Showing
20 changed files
with
17,981 additions
and
17,848 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
FROM ubuntu:noble | ||
|
||
COPY ./sdk_container.sh / | ||
COPY ./build_wasm.sh / | ||
COPY *.sh / | ||
COPY *.cc *.h *.js *.proto Makefile* /sdk/ | ||
|
||
RUN ./sdk_container.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,57 @@ | ||
CPP_API ?= . | ||
ifdef NO_CONTEXT | ||
CPP_CONTEXT_LIB = | ||
else | ||
CPP_CONTEXT_LIB = ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.cc | ||
endif | ||
|
||
all: proxy_wasm_intrinsics.pb.h proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h ${CPP_API}/libprotobuf.a ${CPP_API}/libprotobuf-lite.a | ||
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 | ||
|
||
protobuf: proxy_wasm_intrinsics.pb.h proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h | ||
# Provide a list of libraries that the wasm depends on (absl_*, re2, etc). | ||
WASM_DEPS ?= | ||
|
||
proxy_wasm_intrinsics.pb.h: proxy_wasm_intrinsics.proto | ||
protoc --cpp_out=. proxy_wasm_intrinsics.proto | ||
# 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') | ||
|
||
proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h: proxy_wasm_intrinsics_lite.proto | ||
protoc --cpp_out=. -I. proxy_wasm_intrinsics_lite.proto | ||
protoc --cpp_out=. struct_lite.proto | ||
debug-deps: | ||
# WASM_DEPS : ${WASM_DEPS} | ||
# WASM_LIBS : ${WASM_LIBS} | ||
# PROTO_DEPS: ${PROTO_DEPS} | ||
# PROTO_OPTS: ${PROTO_OPTS} | ||
|
||
${CPP_API}/libprotobuf.a ${CPP_API}/libprotobuf-lite.a: | ||
rm -rf protobuf-wasm \ | ||
&& git clone https://github.com/protocolbuffers/protobuf protobuf-wasm \ | ||
&& cd protobuf-wasm \ | ||
&& git checkout v3.9.1 \ | ||
&& ./autogen.sh \ | ||
&& emconfigure ./configure --disable-shared CXXFLAGS="-O3 -flto" \ | ||
&& emmake make \ | ||
&& cd .. \ | ||
&& cp protobuf-wasm/src/.libs/libprotobuf-lite.a ${CPP_API}/libprotobuf-lite.a \ | ||
&& cp protobuf-wasm/src/.libs/libprotobuf.a ${CPP_API}/libprotobuf.a | ||
# 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 -f proxy_wasm_intrinsics.pb.h proxy_wasm_intrinsics_lite.pb.h struct_lite.pb.h ${CPP_API}/libprotobuf.a ${CPP_API}/libprotobuf-lite.a | ||
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
|
||
source /root/emsdk/emsdk_env.sh | ||
export PATH=/usr/local/bin:$PATH | ||
make | ||
make "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.