Skip to content

Commit

Permalink
Merge pull request google#405 from ggetz/ie-compatibility-js-decoder
Browse files Browse the repository at this point in the history
Add a flag for cmake to generate IE11 compatible JS decoder modules
  • Loading branch information
tomfinegan authored Jun 8, 2018
2 parents 96efe36 + 59f6d7a commit 28e68d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ include_directories("${draco_root}/src" "${draco_build_dir}")
if (EMSCRIPTEN AND ENABLE_JS_GLUE)
# Draco js decoder.
require_compiler_flag("-s ALLOW_MEMORY_GROWTH=1" YES)
if (IE_COMPATIBLE)
require_compiler_flag("-s LEGACY_VM_SUPPORT=1" YES)
endif ()
require_compiler_flag("-Wno-almost-asm" YES)
require_compiler_flag("--memory-init-file 0" YES)
require_compiler_flag("-fno-omit-frame-pointer" YES)
Expand All @@ -624,7 +627,11 @@ if (EMSCRIPTEN AND ENABLE_JS_GLUE)

if (CMAKE_BUILD_TYPE STREQUAL "")
# Force -O3 when no build type is specified.
add_compiler_flag_if_supported("-O3")
if (IE_COMPATIBLE)
add_compiler_flag_if_supported("-g")
else ()
add_compiler_flag_if_supported("-O3")
endif ()
endif ()

set(draco_js_dec_idl
Expand Down
11 changes: 10 additions & 1 deletion Makefile.decoder.emcc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ ALL_C_OPTS := -std=c++11
#ALL_C_OPTS += -s USE_SDL=0 -s USE_SDL_IMAGE=0 -s USE_SDL_TTF=0

# Options for speed.
ALL_C_OPTS += -O3
ifeq ($(IE_COMPATIBLE), true)
ALL_C_OPTS += -g
else
ALL_C_OPTS += -O3
endif
ALL_C_OPTS += -s NO_FILESYSTEM=1 -s ELIMINATE_DUPLICATE_FUNCTIONS=1
ALL_C_OPTS += -s EXPORTED_RUNTIME_METHODS=[]
ALL_C_OPTS += -s PRECISE_F32=1
Expand All @@ -78,6 +82,11 @@ endif
ALL_C_OPTS += -s ALLOW_MEMORY_GROWTH=1
#ALL_C_OPTS += -s TOTAL_MEMORY=67108864

# Allow legacy vm support for IE11
ifeq ($(IE_COMPATIBLE), true)
ALL_C_OPTS += -s LEGACY_VM_SUPPORT=1
endif

# Export the main module as "DracoDecoderModule".
ALL_C_OPTS += -s MODULARIZE=1 -s EXPORT_NAME="'DracoDecoderModule'"

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ $ cmake path/to/draco -DCMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake
$ make
~~~~~

To build a decoder module that is compatible with IE11 (at the cost of a slightly larger resulting module), set the `IE_COMPATIBLE` variable to `true` when generating the cmake file.

~~~~~ bash
$ cmake path/to/draco -DCMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake -DIE_COMPATIBLE=true
~~~~~

WebAssembly Decoder
-------------------

Expand Down

0 comments on commit 28e68d0

Please sign in to comment.