Skip to content

Commit a4cbf07

Browse files
JakeStevensfacebook-github-bot
authored andcommitted
Add additional buck constraints and targets
Summary: Add additional constraints to disable verification and logging. Gives priority to the constraints, otherwise falls back to the buck config pathway. Differential Revision: D83624675
1 parent 943e34a commit a4cbf07

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

runtime/executor/targets.bzl

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
load("@fbsource//xplat/executorch/build:build_variables.bzl", "PROGRAM_NO_PRIM_OPS_SRCS")
22
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime")
33

4+
def program_verification_enabled():
5+
return native.read_config("executorch", "enable_program_verification", "true") == "true"
6+
7+
def logging_enabled():
8+
return native.read_config("executorch", "enable_logging", "true") == "true"
9+
410
def _program_preprocessor_flags():
511
"""Returns the preprocessor_flags to use when building Program.cpp"""
612

713
# The code for flatbuffer verification can add ~30k of .text to the binary.
814
# It's a valuable feature, but make it optional for space-constrained
915
# systems.
10-
enable_verification = native.read_config(
11-
"executorch",
12-
"enable_program_verification",
13-
# Default value
14-
"true",
15-
)
16-
if enable_verification == "false":
17-
return ["-DET_ENABLE_PROGRAM_VERIFICATION=0"]
18-
elif enable_verification == "true":
19-
# Enabled by default.
20-
return []
16+
flags = []
17+
18+
if runtime.is_oss:
19+
# OSS builds only check the native.read_config
20+
if not program_verification_enabled():
21+
flags.append("-DET_ENABLE_PROGRAM_VERIFICATION=0")
22+
if not logging_enabled():
23+
flags.append("-DET_LOG_ENABLED=0")
24+
return flags
2125
else:
22-
fail("executorch.enable_program_verification must be one of 'true' or 'false'; saw '" +
23-
enable_verification + "'")
26+
# Non-OSS builds: constraint takes priority, then check config in DEFAULT case
27+
flags += select({
28+
"DEFAULT": ["-DET_ENABLE_PROGRAM_VERIFICATION=0"] if not program_verification_enabled() else [],
29+
"fbsource//xplat/executorch/tools/buck/constraints:executorch-program-verification-disabled": ["-DET_ENABLE_PROGRAM_VERIFICATION=0"]
30+
})
31+
flags += select({
32+
"DEFAULT": ["-DET_LOG_ENABLED=0"] if not logging_enabled() else [],
33+
"fbsource//xplat/executorch/tools/buck/constraints:executorch-logs-disabled": ["-DET_LOG_ENABLED=0"]
34+
})
35+
return flags
2436

2537
def define_common_targets():
2638
"""Defines targets that should be shared between fbcode and xplat.

0 commit comments

Comments
 (0)