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