gn: Make it more convenient for embedders to enable DLOG
Change-Id: I20a5482a9f2c21597cb9f29933725c24696f3ec2
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 7d4bf5e..7cc7423 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -121,9 +121,10 @@
}
}
- # Disable debug log spam if we're embedded in a third-party project.
- if (!perfetto_build_with_embedder) {
- defines += [ "PERFETTO_ENABLE_DLOG" ]
+ if (perfetto_force_dlog == "on") {
+ defines += [ "PERFETTO_FORCE_DLOG=1" ]
+ } else if (perfetto_force_dlog == "off") {
+ defines += [ "PERFETTO_FORCE_DLOG=0" ]
}
include_dirs = [
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 3e06d60..5b43d1b 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -47,15 +47,29 @@
# The Android blueprint file generator overrides this to true.
perfetto_build_with_android = false
+ # Embedders can override this to true.
+ perfetto_build_with_embedder = build_with_chromium
+
# Whether the ftrace producer and the service should be started
# by the integration test or assumed to be running.
start_daemons_for_testing = true
}
-if (!defined(perfetto_build_with_embedder)) {
- perfetto_build_with_embedder = build_with_chromium
+perfetto_force_dlog_default = ""
+if (perfetto_build_with_embedder) {
+ perfetto_force_dlog_default = "off"
}
+declare_args() {
+ # Whether DLOG should be enabled on debug builds (""), all builds ("on"), or
+ # none ("off"). We disable it by default for embedders to avoid spamming their
+ # console.
+ perfetto_force_dlog = perfetto_force_dlog_default
+}
+
+assert(perfetto_force_dlog == "" || perfetto_force_dlog == "on" ||
+ perfetto_force_dlog == "off")
+
perfetto_build_standalone =
!perfetto_build_with_android && !build_with_chromium &&
!perfetto_build_with_embedder
diff --git a/include/perfetto/base/logging.h b/include/perfetto/base/logging.h
index 58767e5..d707e37 100644
--- a/include/perfetto/base/logging.h
+++ b/include/perfetto/base/logging.h
@@ -28,10 +28,10 @@
#define PERFETTO_DCHECK_IS_ON() 1
#endif
-#if defined(PERFETTO_ENABLE_DLOG)
+#if !defined(PERFETTO_FORCE_DLOG)
#define PERFETTO_DLOG_IS_ON() PERFETTO_DCHECK_IS_ON()
#else
-#define PERFETTO_DLOG_IS_ON() 0
+#define PERFETTO_DLOG_IS_ON() PERFETTO_FORCE_DLOG
#endif
#include "perfetto/base/build_config.h"
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index 66e2583..b9e1c39 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -605,8 +605,7 @@
'-Oz',
]
if force_debug:
- defaults.cflags.extend(['-UNDEBUG',
- '-DPERFETTO_ENABLE_DLOG'])
+ defaults.cflags.extend(['-UNDEBUG'])
defaults.user_debug_flag = True
blueprint.add_module(defaults)