diff --git a/docs/assets/chrome_develop_tool.png b/docs/assets/chrome_develop_tool.png new file mode 100644 index 000000000..41cd93b71 Binary files /dev/null and b/docs/assets/chrome_develop_tool.png differ diff --git a/docs/debug_wasm.md b/docs/debug_wasm.md new file mode 100644 index 000000000..ed25a1618 --- /dev/null +++ b/docs/debug_wasm.md @@ -0,0 +1,46 @@ +# AVS WASM Debugging + +## Develop + +When working with the web app it is sometimes helpful to debug the AVS. +To do this you need to create the WASM file with debug information. + +### Build WASM with source map + +This creates wasm file with debug information + +```bash +$ make dist_wasm WASM_DEBUG=1 +``` + +### Link avs project ro wire_webapp + +After you have built the wasm, link your local build of `@wireapp/avs` to your local `wire-webapp` like: + +```bash +$ cd cd build/dist/wasm/ +$ yarn link +``` +Use `yarn link @wireapp/avs` in the root directory of your local `wire-webapp`. + +If that doesn't work, there is still the hard way ;) + +Add `@wireapp/avs` directly in the `package.json` of `wire-webapp` like + +```json +{ + "dependencies": { + "@wireapp/avs": "file:../wire-avs/build/dist/wasm/" + } +} +``` + +### Debugging WebAssembly in Chrome + +To get the debug information you need a Chrome extension: +Install the [C/C++ DevTools Support (DWARF) Chrome extension](https://chromewebstore.google.com/detail/cc++-devtools-support-dwa/pdcpmagijalfljmkmjngeonclgbbannb) + +![DevTools](./assets/chrome_develop_tool.png "DevTools") + +Have fun! + diff --git a/mk/dist.mk b/mk/dist.mk index dd903c117..fcdc9d5cb 100644 --- a/mk/dist.mk +++ b/mk/dist.mk @@ -431,11 +431,16 @@ else EMCC := $(WASM_PATH)/emcc endif +ifeq ($(WASM_DEBUG),1) +DIST_WASM_WITH_SOURCE_MAP := -gsource-map -g +else +DIST_WASM_WITH_SOURCE_MAP := +endif $(DIST_WASM_JS_TARGET): $(MAKE) AVS_OS=wasm AVS_ARCH=generic avs @mkdir -p $(BUILD_DIST_WASM)/src - $(EMCC) -o $(DIST_WASM_JS_TARGET) \ + $(EMCC) $(DIST_WASM_WITH_SOURCE_MAP) -o $(DIST_WASM_JS_TARGET) \ $(BUILD_BASE)/wasm-generic/lib/libavscore.a \ $(BUILD_BASE)/wasm-generic/lib/libre.a \ $(BUILD_BASE)/wasm-generic/lib/libsodium.a \