GN: Add enable_perfetto_traced_probes variable
The build variable enable_perfetto_platform_services
has become too broadly scoped. On Windows we want
to build traced, perfetto_cmd but not traced_probes.
traced_probes, in fact, is extremely Linux specific
(ftrace, /proc) and it doesn't make any sense to
make it build on Windows.
This CL introduces a enable_perfetto_traced_probes
GN variables and masks out all //src/traced/probes
targets behind it.
Bug: 174454879
Change-Id: I2252741495cf4612e542a68edb76a317b895d9f0
diff --git a/BUILD.gn b/BUILD.gn
index b5fbddd..92f81ce 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -35,8 +35,10 @@
"src/perfetto_cmd:perfetto",
"src/perfetto_cmd:trigger_perfetto",
"src/traced/service:traced",
- "src/traced/probes:traced_probes",
]
+ if (enable_perfetto_traced_probes) {
+ all_targets += [ "src/traced/probes:traced_probes" ]
+ }
}
if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
@@ -208,10 +210,16 @@
}
deps = [
"gn:default_deps",
- "src/traced/probes",
"src/traced/service",
- "src/tracing/consumer_api_deprecated",
]
+ if (enable_perfetto_traced_probes) {
+ deps += [ "src/traced/probes" ]
+ }
+ if (is_linux || is_android || is_mac) {
+ # TODO(primiano): this is here only for Android's iorapd. At some point
+ # we need to migrate iorapd to the Perfetto SDK.
+ deps += [ "src/tracing/consumer_api_deprecated" ]
+ }
}
}
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 5b4ad49..9f8d04e 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -131,9 +131,14 @@
}
declare_args() {
- # Platform-wide tracing executables (traced, traced_probes, perfetto_cmd).
+ # Enables build of platform-wide tracing services (traced, traced_probes)
+ # and executables (perfetto_cmd, trigger_perfetto).
+ # When disabled, only the client library and other auxiliary tools can be
+ # built (for Chromium and other GN embedders).
+ # Note that traced_probes is further conditioned by the GN variable
+ # enable_perfetto_traced_probes, in the declare_args() section below.
enable_perfetto_platform_services =
- (perfetto_build_standalone && !is_win) || perfetto_build_with_android
+ perfetto_build_standalone || perfetto_build_with_android
# Allow the embedder to use the IPC layer. In turn this allows to use the
# system backend in the client library.
@@ -213,6 +218,15 @@
}
declare_args() {
+ # The traced_probes daemon is very Linux-specific, as it depends on ftrace and
+ # various /proc interfaces. There is no point making its code platform-neutral
+ # as it won't do anything useful on Windows.
+ # The only reason why we still build it on Mac OS is to be able to run the
+ # unittests there and making dev on mac less cumbersome. The traced_probes
+ # code happens to build cleanly and for now the mainteinance cost on Mac is
+ # extremely low.
+ enable_perfetto_traced_probes = enable_perfetto_platform_services && !is_win
+
# Whether info-level logging is enabled.
perfetto_verbose_logs_enabled =
!build_with_chromium || perfetto_force_dlog == "on"
@@ -307,3 +321,8 @@
assert(perfetto_force_dlog == "" || perfetto_force_dlog == "on" ||
perfetto_force_dlog == "off")
+
+# If enable_perfetto_traced_probes is set, enable_perfetto_platform_services
+# must be set as well. Doesn't make sense to build traced_probes without the
+# rest. traced_probes integration tests depend on traced.
+assert(!enable_perfetto_traced_probes || enable_perfetto_platform_services)
diff --git a/gn/perfetto_integrationtests.gni b/gn/perfetto_integrationtests.gni
index d2b0181..d1005fd 100644
--- a/gn/perfetto_integrationtests.gni
+++ b/gn/perfetto_integrationtests.gni
@@ -20,7 +20,8 @@
"src/tracing/test:client_api_integrationtests",
]
-if (enable_perfetto_platform_services) {
+if (enable_perfetto_traced_probes) {
+ # enable_perfetto_traced_probes implies enable_perfetto_platform_services.
perfetto_integrationtests_targets += [
"src/traced/probes/ftrace:integrationtests",
"test:end_to_end_integrationtests",
diff --git a/gn/perfetto_unittests.gni b/gn/perfetto_unittests.gni
index 9b6a95d..44721ce 100644
--- a/gn/perfetto_unittests.gni
+++ b/gn/perfetto_unittests.gni
@@ -50,12 +50,16 @@
if (enable_perfetto_platform_services) {
perfetto_unittests_targets += [
"src/perfetto_cmd:unittests",
- "src/traced/probes:unittests",
- "src/traced/probes/filesystem:unittests",
- "src/traced/probes/ftrace:unittests",
- "src/kallsyms:unittests",
"src/traced/service:unittests",
]
+ if (enable_perfetto_traced_probes) {
+ perfetto_unittests_targets += [
+ "src/traced/probes:unittests",
+ "src/traced/probes/filesystem:unittests",
+ "src/traced/probes/ftrace:unittests",
+ "src/kallsyms:unittests",
+ ]
+ }
}
if (enable_perfetto_heapprofd || enable_perfetto_traced_perf) {
diff --git a/src/traced/probes/BUILD.gn b/src/traced/probes/BUILD.gn
index d54e965..9e09790 100644
--- a/src/traced/probes/BUILD.gn
+++ b/src/traced/probes/BUILD.gn
@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import("../../../gn/perfetto.gni")
import("../../../gn/test.gni")
-assert(target_os != "win")
+assert(enable_perfetto_traced_probes)
# The unprivileged daemon that is allowed to access tracefs (for ftrace).
# Registers as a Producer on the traced daemon.
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 76bb8ce..923eb31 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -36,8 +36,10 @@
"../protos/perfetto/trace/power:cpp",
"../src/base:base",
"../src/base:test_support",
- "../src/traced/probes/ftrace",
]
+ if (enable_perfetto_traced_probes) {
+ deps += [ "../src/traced/probes/ftrace" ]
+ }
# These binaries are requires by the cmdline tests, which invoke perfetto
# and trigger_perfetto via Subprocess.
@@ -133,7 +135,7 @@
if (start_daemons_for_testing) {
cflags = [ "-DPERFETTO_START_DAEMONS_FOR_TESTING" ]
}
- if (!build_with_chromium) {
+ if (!build_with_chromium && enable_perfetto_traced_probes) {
deps += [
"../include/perfetto/ext/traced",
"../src/traced/probes:probes_src",