forked from cloudflare/workerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
66 lines (56 loc) · 2.09 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("@bazel_skylib//lib:selects.bzl", "selects")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@capnp-cpp//src/capnp:cc_capnp_library.bzl", "cc_capnp_library")
load("@npm//:capnpc-ts/package_json.bzl", capnpc_ts_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")
cc_capnp_library(
name = "icudata-embed",
srcs = ["icudata-embed.capnp"],
include_prefix = ".",
visibility = ["//visibility:public"],
data = ["@com_googlesource_chromium_icu//:icudata"],
defines = [ "WORKERD_ICU_DATA_EMBED" ],
)
npm_link_all_packages(name = "node_modules")
npm_link_package(
name = "node_modules/@workerd/jsg",
src = "//src/workerd/jsg:jsg_js",
package = "@workerd/jsg",
)
capnpc_ts_bin.capnpc_ts_binary(
name = "capnpc_ts",
visibility = ["//visibility:public"],
)
# bazel enables the --ffunction-sections, --gc-sections flags used to remove dead code by default
# on Linux opt builds. Enable the equivalent macOS flag -Wl,-dead_strip here to work around bazel
# idiosyncrasies.
# Note that the flag is defined for all non-debug builds of kj_test() and wd_cc_binary() on mac as
# it surprisingly appears to be faster, perhaps because the linker generates and writes binaries
# with much fewer symbols. This also helps reduce local and CI disk usage. If needed, dead code
# stripping can be limited to optimized builds.
config_setting(
name = "fast_build",
values = {"compilation_mode": "fastbuild"},
)
config_setting(
name = "opt_build",
values = {"compilation_mode": "opt"},
)
bool_flag(
name = "dead_strip",
build_setting_default = True,
)
config_setting(
name = "set_dead_strip",
flag_values = {"dead_strip": "True"},
)
# Workaround for bazel not supporting negated conditions (https://github.com/bazelbuild/bazel-skylib/issues/272)
selects.config_setting_group(
name = "not_dbg_build",
match_any = [":fast_build", ":opt_build"],
)
selects.config_setting_group(
name = "use_dead_strip",
match_all = ["@platforms//os:macos", ":set_dead_strip", ":not_dbg_build"],
)