Vincent Rabaud 2022-10-03 14:08:44 +02:00
parent e68765af42
commit cb90f76b68
2 changed files with 17 additions and 14 deletions

View File

@ -631,9 +631,9 @@ if(WEBP_BUILD_WEBP_JS)
set(WEBP_HAVE_SDL 1)
set_target_properties(
webp_js
PROPERTIES LINK_FLAGS "-s WASM=0 \
-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \
-s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
PROPERTIES LINK_FLAGS "-sWASM=0 \
-sEXPORTED_FUNCTIONS=_WebpToSDL -sINVOKE_RUN=0 \
-sEXPORTED_RUNTIME_METHODS=cwrap")
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp)
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
endif()
@ -644,9 +644,9 @@ if(WEBP_BUILD_WEBP_JS)
target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
set_target_properties(
webp_wasm
PROPERTIES LINK_FLAGS "-s WASM=1 \
-s EXPORTED_FUNCTIONS='[\"_WebpToSDL\"]' -s INVOKE_RUN=0 \
-s EXPORTED_RUNTIME_METHODS='[\"cwrap\"]'")
PROPERTIES LINK_FLAGS "-sWASM=1 \
-sEXPORTED_FUNCTIONS=_WebpToSDL -sINVOKE_RUN=0 \
-sEXPORTED_RUNTIME_METHODS=cwrap")
target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL)
target_compile_definitions(webpdspdecode PUBLIC EMSCRIPTEN)

View File

@ -26,8 +26,8 @@ Emscripten and CMake.
- compile webp.js using 'emmake make'.
- that's it! Upon completion, you should have the webp.js and webp.wasm files
generated.
- that's it! Upon completion, you should have the 'webp.js', 'webp.js.mem',
'webp_wasm.js' and 'webp_wasm.wasm' files generated.
The callable JavaScript function is WebPToSDL(), which decodes a raw WebP
bitstream into a canvas. See webp_js/index.html for a simple usage sample (see
@ -35,11 +35,12 @@ below for instructions).
## Demo HTML page
The HTML page webp_js/index.html requires an HTTP server to serve the WebP image
example. It's easy to just use Python for that.
The HTML page webp_js/index.html requires the built files 'webp.js' and
'webp.js.mem' to be copied to webp_js/. An HTTP server to serve the WebP image
example is also needed. With Python, just run:
```shell
cd webp_js && python -m SimpleHTTPServer 8080
cd webp_js && python3 -m http.server 8080
```
and then navigate to http://localhost:8080 in your favorite browser.
@ -48,9 +49,11 @@ and then navigate to http://localhost:8080 in your favorite browser.
CMakeLists.txt is configured to build the WASM version when using the option
WEBP_BUILD_WEBP_JS=ON. The compilation step will assemble the files
'webp_wasm.js', 'webp_wasm.wasm' in the webp_js/ directory. See
webp_js/index_wasm.html for a simple demo page using the WASM version of the
library.
'webp_wasm.js' and 'webp_wasm.wasm' that you then need to copy to the
webp_js/ directory.
See webp_js/index_wasm.html for a simple demo page using the WASM version of
the library.
You will need a fairly recent version of Emscripten (at least 2.0.18,
latest-upstream is recommended) and of your WASM-enabled browser to run this