summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2019-01-17 15:10:51 -0800
committerYabin Cui <yabinc@google.com>2019-01-17 15:48:37 -0800
commit4192f469a115a5852b07300db793ebb78f2bf8ae (patch)
tree65d495ae0f8dcc5a23c8e69df1fe14005a3e8db0
parenta70a1872eb01a3ed91286c906d8c466283d3e306 (diff)
downloadextras-4192f469a115a5852b07300db793ebb78f2bf8ae.tar.gz
simpleperf: split simpleperf build on target.
Currently simpleperf on target builds static binary, shipped on userdebug devices and in ndk release. Now split it into two builds. Simpleperf shipped on device uses shared libs and version lib. Simpleperf shipped in ndk release is renamed to simpleperf_static. This is to ship simpleperf on Q user device. Also change the directory of simpleperf from /system/xbin to /system/bin. Bug: 118835348 Bug: 72403367 Test: build and run simpleperf manually. Change-Id: I25b861fc24fdf2edfeb432050303aaec293a005f
-rw-r--r--perfprofd/config.h2
-rw-r--r--simpleperf/Android.bp59
-rw-r--r--simpleperf/Android.mk12
-rw-r--r--simpleperf/doc/README.md4
-rw-r--r--simpleperf/utils.cpp8
5 files changed, 75 insertions, 10 deletions
diff --git a/perfprofd/config.h b/perfprofd/config.h
index 8f33ce4a..b5e5d5d4 100644
--- a/perfprofd/config.h
+++ b/perfprofd/config.h
@@ -46,7 +46,7 @@ struct Config {
// Config directory (where to read configs).
std::string config_directory = "/data/data/com.google.android.gms/files";
// Full path to 'perf' executable.
- std::string perf_path = "/system/xbin/simpleperf";
+ std::string perf_path = "/system/bin/simpleperf";
// Desired sampling period (passed to perf -c option). Small
// sampling periods can perturb the collected profiles, so enforce
diff --git a/simpleperf/Android.bp b/simpleperf/Android.bp
index c97ba099..77d93df2 100644
--- a/simpleperf/Android.bp
+++ b/simpleperf/Android.bp
@@ -131,3 +131,62 @@ cc_library_static {
group_static_libs: true,
}
+
+cc_binary {
+ name: "simpleperf",
+ host_supported: false,
+ srcs : [
+ "CallChainJoiner.cpp",
+ "cmd_debug_unwind.cpp",
+ "cmd_dumprecord.cpp",
+ "cmd_help.cpp",
+ "cmd_list.cpp",
+ "cmd_kmem.cpp",
+ "cmd_record.cpp",
+ "cmd_report.cpp",
+ "cmd_report_sample.cpp",
+ "cmd_stat.cpp",
+ "cmd_trace_sched.cpp",
+ "command.cpp",
+ "dso.cpp",
+ "environment.cpp",
+ "event_attr.cpp",
+ "event_fd.cpp",
+ "event_selection_set.cpp",
+ "event_type.cpp",
+ "InplaceSamplerClient.cpp",
+ "IOEventLoop.cpp",
+ "JITDebugReader.cpp",
+ "main.cpp",
+ "OfflineUnwinder.cpp",
+ "perf_regs.cpp",
+ "read_apk.cpp",
+ "read_dex_file.cpp",
+ "read_elf.cpp",
+ "record.cpp",
+ "record_file_reader.cpp",
+ "record_file_writer.cpp",
+ "RecordReadThread.cpp",
+ "report_sample.proto",
+ "thread_tree.cpp",
+ "tracing.cpp",
+ "UnixSocket.cpp",
+ "utils.cpp",
+ "workload.cpp",
+ ],
+ shared_libs: [
+ "libbase",
+ "libcutils",
+ "libdexfile",
+ "libdexfile_external",
+ "libdexfile_support",
+ "libevent",
+ "libLLVM_android",
+ "liblzma",
+ "libprocinfo",
+ "libprotobuf-cpp-lite",
+ "libunwindstack",
+ "libziparchive",
+ ],
+ use_version_lib: true,
+} \ No newline at end of file
diff --git a/simpleperf/Android.mk b/simpleperf/Android.mk
index 8afb4d48..f18835d3 100644
--- a/simpleperf/Android.mk
+++ b/simpleperf/Android.mk
@@ -182,26 +182,24 @@ include $(BUILD_HOST_STATIC_LIBRARY)
# simpleperf target
include $(CLEAR_VARS)
-LOCAL_MODULE := simpleperf
-LOCAL_MODULE_TAGS := debug
-LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
+LOCAL_MODULE := simpleperf_static
LOCAL_CFLAGS := $(simpleperf_cflags_target)
LOCAL_SRC_FILES := main.cpp
LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_with_libc_target)
ifdef TARGET_2ND_ARCH
ifneq ($(TARGET_TRANSLATE_2ND_ARCH),true)
LOCAL_MULTILIB := both
-LOCAL_MODULE_STEM_32 := simpleperf32
-LOCAL_MODULE_STEM_64 := simpleperf
+LOCAL_MODULE_STEM_32 := simpleperf_static32
+LOCAL_MODULE_STEM_64 := simpleperf_static
endif
endif
LOCAL_FORCE_STATIC_EXECUTABLE := true
include $(LLVM_DEVICE_BUILD_MK)
include $(BUILD_EXECUTABLE)
-$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf.BUILT))
+$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_static.BUILT))
ifdef TARGET_2ND_ARCH
-$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT))
+$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_static$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT))
endif
# simpleperf host
diff --git a/simpleperf/doc/README.md b/simpleperf/doc/README.md
index 372db1a4..244d1045 100644
--- a/simpleperf/doc/README.md
+++ b/simpleperf/doc/README.md
@@ -1323,5 +1323,5 @@ $ lunch aosp_arm64-userdebug
$ mmma system/extras/simpleperf -j30
```
-If built successfully, out/target/product/generic_arm64/system/xbin/simpleperf is for ARM64, and
-out/target/product/generic_arm64/system/xbin/simpleperf32 is for ARM.
+If built successfully, out/target/product/generic_arm64/system/bin/simpleperf is for ARM64, and
+out/target/product/generic_arm64/system/bin/simpleperf32 is for ARM.
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp
index 6de88116..645e6dce 100644
--- a/simpleperf/utils.cpp
+++ b/simpleperf/utils.cpp
@@ -32,6 +32,9 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/stringprintf.h>
+#if !defined(SIMPLEPERF_REVISION)
+#include <build/version.h>
+#endif
#include <7zCrc.h>
#include <Xz.h>
@@ -407,5 +410,10 @@ timeval SecondToTimeval(double time_in_sec) {
constexpr int SIMPLEPERF_VERSION = 1;
std::string GetSimpleperfVersion() {
+#if defined(SIMPLEPERF_REVISION)
return android::base::StringPrintf("%d.%s", SIMPLEPERF_VERSION, SIMPLEPERF_REVISION);
+#else
+ return android::base::StringPrintf("%d.build.%s", SIMPLEPERF_VERSION,
+ android::build::GetBuildNumber().c_str());
+#endif
}