mirror of
https://github.com/opencv/opencv.git
synced 2024-11-27 12:40:05 +08:00
Add possibility for disabling inlining wasm
in opencv.js
This commit is contained in:
parent
e03e2e7f94
commit
6c763e1ea5
@ -83,6 +83,9 @@ Building OpenCV.js from Source
|
||||
It requires `python` and `cmake` installed in your development environment.
|
||||
|
||||
-# The build script builds asm.js version by default. To build WebAssembly version, append `--build_wasm` switch.
|
||||
By default everything is bundled into one JavaScript file by `base64` encoding the WebAssembly code. For production
|
||||
builds you can add `--disable_single_file` which will reduce total size by writing the WebAssembly code
|
||||
to a dedicated `.wasm` file which the generated JavaScript file will automatically load.
|
||||
|
||||
For example, to build wasm version in `build_wasm` directory:
|
||||
@code{.bash}
|
||||
|
@ -70,7 +70,7 @@ if(COMPILE_FLAGS)
|
||||
endif()
|
||||
|
||||
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} --memory-init-file 0 -s TOTAL_MEMORY=128MB -s WASM_MEM_MAX=1GB -s ALLOW_MEMORY_GROWTH=1")
|
||||
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1 -s SINGLE_FILE=1")
|
||||
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s MODULARIZE=1")
|
||||
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s EXPORT_NAME=\"'cv'\" -s DEMANGLE_SUPPORT=1")
|
||||
set(EMSCRIPTEN_LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS} -s FORCE_FILESYSTEM=1 --use-preload-plugins --bind --post-js ${JS_HELPER} ${COMPILE_FLAGS}")
|
||||
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS}")
|
||||
|
@ -180,6 +180,8 @@ class Builder:
|
||||
flags += "-s WASM=1 "
|
||||
elif self.options.disable_wasm:
|
||||
flags += "-s WASM=0 "
|
||||
if not self.options.disable_single_file:
|
||||
flags += "-s SINGLE_FILE=1 "
|
||||
if self.options.threads:
|
||||
flags += "-s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 "
|
||||
else:
|
||||
@ -233,6 +235,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument('--emscripten_dir', default=emscripten_dir, help="Path to Emscripten to use for build (deprecated in favor of 'emcmake' launcher)")
|
||||
parser.add_argument('--build_wasm', action="store_true", help="Build OpenCV.js in WebAssembly format")
|
||||
parser.add_argument('--disable_wasm', action="store_true", help="Build OpenCV.js in Asm.js format")
|
||||
parser.add_argument('--disable_single_file', action="store_true", help="Do not merge JavaScript and WebAssembly into one single file")
|
||||
parser.add_argument('--threads', action="store_true", help="Build OpenCV.js with threads optimization")
|
||||
parser.add_argument('--simd', action="store_true", help="Build OpenCV.js with SIMD optimization")
|
||||
parser.add_argument('--build_test', action="store_true", help="Build tests")
|
||||
|
Loading…
Reference in New Issue
Block a user