File tree Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Expand file tree Collapse file tree 4 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,14 @@ wasm_cc_binary(
13
13
BASE_LINKOPTS = [
14
14
"--bind" , # Enable embind
15
15
"-sMODULARIZE" ,
16
+ "--pre-js" ,
17
+ "hello-embind-interface.js" ,
16
18
]
17
19
18
20
RELEASE_OPTS = [
19
21
"--closure=1" , # Run the closure compiler
22
+ # Tell closure about the externs file, so as not to minify our JS public API.
23
+ "--closure-args=--externs=$(location hello-embind-externs.js)"
20
24
]
21
25
22
26
DEBUG_OPTS = [
@@ -36,6 +40,11 @@ config_setting(
36
40
cc_binary (
37
41
name = "hello-embind" ,
38
42
srcs = ["hello-embind.cc" ],
43
+ features = ["emcc_debug_link" ],
44
+ additional_linker_inputs = [
45
+ "hello-embind-externs.js" ,
46
+ "hello-embind-interface.js" ,
47
+ ],
39
48
linkopts = select ({
40
49
":debug_opts" : BASE_LINKOPTS + DEBUG_OPTS ,
41
50
":release_opts" : BASE_LINKOPTS + RELEASE_OPTS ,
@@ -50,3 +59,4 @@ wasm_cc_binary(
50
59
name = "hello-embind-wasm" ,
51
60
cc_target = ":hello-embind" ,
52
61
)
62
+
Original file line number Diff line number Diff line change
1
+ // This file prevents customJSFunctionToTestClosure from being minified by the Closure compiler.
2
+ Module . customJSFunctionToTestClosure = function ( ) { }
Original file line number Diff line number Diff line change
1
+ Module . customJSFunctionToTestClosure = function ( firstParam , secondParam ) {
2
+ console . log ( "This function adds two numbers to get" , firstParam + secondParam ) ;
3
+ }
Original file line number Diff line number Diff line change @@ -27,5 +27,8 @@ bazel build //hello-world:hello-world-wasm-simd
27
27
cd test_external
28
28
bazel build //:hello-world-wasm
29
29
bazel build //:hello-embind-wasm --compilation_mode dbg # debug
30
+
30
31
# Test use of the closure compiler
31
32
bazel build //:hello-embind-wasm --compilation_mode opt # release
33
+ # This function should not be minified if the externs file is loaded correctly.
34
+ grep " customJSFunctionToTestClosure" bazel-bin/hello-embind-wasm/hello-embind.js
You can’t perform that action at this time.
0 commit comments