1load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary") 2load("//bazel:cc_binary_with_flags.bzl", "cc_binary_with_flags") 3 4LINKOPTS = [ 5 "-sALLOW_MEMORY_GROWTH", 6 "-sUSE_PTHREADS=0", # Disable pthreads 7 "-sMODULARIZE", 8 "-sDISABLE_EXCEPTION_CATCHING", # Disable all exception catching 9 "-sWASM", 10 "-sMAX_WEBGL_VERSION=2", 11 "-sFORCE_FILESYSTEM=0", 12 "-sFILESYSTEM=0", 13 "-sASSERTIONS", # Turn on assertions 14 "-sGL_ASSERTIONS", 15 "-sEXPORT_NAME=HelloWorld", 16] 17 18cc_binary_with_flags( 19 name = "hello_world.webgl", 20 srcs = [ 21 "//example:HelloWorld_src", 22 "//tools/sk_app/wasm:main_wasm_src", 23 ], 24 linkopts = LINKOPTS, 25 set_flags = { 26 "gpu_backend": [ 27 "gl_backend", 28 ], 29 "with_gl_standard": [ 30 "webgl_standard", 31 ], 32 }, 33 # This target won't build successfully on its own because of missing emscripten 34 # headers etc. Therefore, we hide it from wildcards. 35 tags = ["manual"], 36 deps = [ 37 "//:skia_core", 38 ], 39) 40 41wasm_cc_binary( 42 name = "hello_world_wasm", 43 cc_target = ":hello_world.webgl", 44) 45