Skip to content

Commit 14f2017

Browse files
authored
Add executorch-et-log-disabled constraint honored by log.bzl (#20187)
Differential Revision: D108152661 Pull Request resolved: #20187
1 parent c4b9b26 commit 14f2017

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

runtime/platform/log.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2+
13
def et_logging_enabled():
24
return native.read_config("executorch", "enable_et_log", "true") == "true"
35

@@ -16,7 +18,14 @@ def et_log_level():
1618

1719
def get_et_logging_flags():
1820
if et_logging_enabled():
19-
# On by default.
20-
return ["-DET_MIN_LOG_LEVEL=" + et_log_level()]
21+
if runtime.is_oss:
22+
return ["-DET_MIN_LOG_LEVEL=" + et_log_level()]
23+
24+
# On by default; allow opt-out via constraint (the executorch.enable_et_log
25+
# buckconfig above remains an independent way to disable logging).
26+
return select({
27+
"DEFAULT": ["-DET_MIN_LOG_LEVEL=" + et_log_level()],
28+
"fbsource//xplat/executorch/tools/buck/constraints:executorch-et-log-disabled": ["-DET_LOG_ENABLED=0"],
29+
})
2130
else:
2231
return ["-DET_LOG_ENABLED=0"]

tools/buck/constraints/BUCK

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,22 @@ fb_native.constraint_value(
9999
constraint_setting = ":executorch-builtin-function-name",
100100
visibility = ["PUBLIC"],
101101
)
102+
103+
fb_native.config_setting(
104+
name = "executorch-et-log-disabled",
105+
constraint_values = [
106+
":et-log-disabled",
107+
],
108+
visibility = ["PUBLIC"],
109+
)
110+
111+
fb_native.constraint_setting(
112+
name = "executorch-et-log",
113+
visibility = ["PUBLIC"],
114+
)
115+
116+
fb_native.constraint_value(
117+
name = "et-log-disabled",
118+
constraint_setting = ":executorch-et-log",
119+
visibility = ["PUBLIC"],
120+
)

0 commit comments

Comments
 (0)