ANDROID: Android.bp: Build for /vendor
This often fits better as a vendor customization than a system tool.
When doing so, Soong complains:
module trace-cmd missing dependencies: libdl{...} libm{...}, libc{...}
As a static executable, we'd need to statically link these libraries to
resolve the complaint, which seems excessive.
Instead, split out a "_static" variant as has been done in some other
packages, and make the main "trace-cmd" a dynamic ELF like most
binaries.
Bug: 393387208
Test: PRODUCT_PACKAGES_DEBUG += trace-cmd, build
Change-Id: Ifaaccfb1428c0f1532df2e6cbe4e72856cd51d31
diff --git a/Android.bp b/Android.bp
index 79f7f6a..e012185 100644
--- a/Android.bp
+++ b/Android.bp
@@ -129,38 +129,50 @@
c_std: "gnu99",
}
+tracecmd_cflags = [
+ "-D_GNU_SOURCE",
+ "-DNO_AUDIT",
+ "-DVSOCK",
+ // strstrip() is defined in libtracefs too; change our name to avoid
+ // duplicate symbols when statically linking.
+ "-Dstrstrip=strstrip_trace",
+ "-Wno-unused-parameter",
+ "-Wno-macro-redefined",
+ "-Wno-visibility",
+ "-Wno-pointer-arith",
+]
+
+tracecmd_includes = [
+ "lib/trace-cmd/include/private",
+ "include/trace-cmd",
+ "tracecmd/include",
+ "include",
+]
+
+tracecmd_libs = [
+ "libtraceevent",
+ "libtracecmd",
+ "libtracefs",
+]
+
cc_binary {
name: "trace-cmd",
+ vendor: true,
- local_include_dirs: [
- "lib/trace-cmd/include/private",
- "include/trace-cmd",
- "tracecmd/include",
- "include",
- ],
-
+ local_include_dirs: tracecmd_includes,
srcs: ["tracecmd/*.c"],
+ static_libs: tracecmd_libs,
+ cflags: tracecmd_cflags,
+ c_std: "gnu99",
+}
- static_libs: [
- "libtraceevent",
- "libtracecmd",
- "libtracefs",
- ],
+cc_binary {
+ name: "trace-cmd_static",
+ local_include_dirs: tracecmd_includes,
+ srcs: ["tracecmd/*.c"],
+ static_libs: tracecmd_libs,
static_executable: true,
-
- cflags: [
- "-D_GNU_SOURCE",
- "-DNO_AUDIT",
- "-DVSOCK",
- // strstrip() is defined in libtracefs too; change our name to avoid
- // duplicate symbols when statically linking.
- "-Dstrstrip=strstrip_trace",
- "-Wno-unused-parameter",
- "-Wno-macro-redefined",
- "-Wno-visibility",
- "-Wno-pointer-arith",
- ],
-
+ cflags: tracecmd_cflags,
c_std: "gnu99",
}