blob: 6a67e4fd44b68db1c75fcf56b5ca1f675358dfae [file] [log] [blame]
James Kuszmaul27da8142019-07-21 16:13:55 -07001package(default_visibility = ["//visibility:public"])
2
James Kuszmaul9a05bfd2019-08-03 17:03:38 -07003_minimum_fileset = [
4 "emar.sh",
5 "emcc.sh",
6 "@emscripten_clang//:all",
7 "@emscripten_toolchain//:all",
8 "@nodejs//:bin/node",
9]
10
11filegroup(
12 name = "minimum_files",
13 srcs = _minimum_fileset,
14)
15
James Kuszmaul27da8142019-07-21 16:13:55 -070016filegroup(
17 name = "all",
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070018 srcs = _minimum_fileset + [
James Kuszmaul27da8142019-07-21 16:13:55 -070019 ":emscripten_cache_content",
James Kuszmaul27da8142019-07-21 16:13:55 -070020 ],
21)
22
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070023# A list of all the cached libraries generad and used by emscripten.
24_libs = \
25 ["emscripten_cache/asmjs/" + lib for lib in [
26 "generated_struct_info.json",
27 "libc.bc",
28 "libcompiler_rt.a",
29 "libc-wasm.bc",
30 "libpthreads_stub.bc",
31 "libhtml5.bc",
32 "libdlmalloc.bc",
33 "libal.bc",
34 "libc++_noexcept.a",
35 "libc++abi.bc",
36 "libgl-webgl2.bc",
37 "libgl.bc",
38 "libc-extras.bc",
39 ]]
40
James Kuszmaul27da8142019-07-21 16:13:55 -070041filegroup(
42 name = "emscripten_cache_content",
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070043 srcs = glob(["emscripten_cache/**/*"]) + _libs,
James Kuszmaul27da8142019-07-21 16:13:55 -070044)
45
46cc_toolchain(
47 name = "cc_emscripten",
48 all_files = ":all",
49 compiler_files = ":all",
50 cpu = "web",
51 dwp_files = ":empty",
52 dynamic_runtime_libs = [":empty"],
53 linker_files = ":all",
54 objcopy_files = ":empty",
55 static_runtime_libs = [":empty"],
56 strip_files = ":empty",
57 supports_param_files = 0,
58)
James Kuszmaul9a05bfd2019-08-03 17:03:38 -070059
60# TODO(james): Currently, this gets built with the host configuration.
61# Currently, that doesn't actually impact the build since there's nothing that
62# affects how the genrule is run. However, that also means that changing
63# the configuration (and thus the flags that may be passed to the C++
64# compiler) will not change how these cache files are generated.
65genrule(
66 name = "gencache",
67 # Note that foo.o is just some arbitrary .o file. I had trouble getting
68 # emscripten to work properly when pointed at a literally empty file, but
69 # the exact contents of the .o aren't particularly important.
70 srcs = [":foo.o"],
71 outs = _libs,
72 cmd = "$(location gencache.sh) $(OUTS)",
73 tools = [
74 ":gencache.sh",
75 ":minimum_files",
76 ],
77)