// // Copyright (C) 2018 The Android Open Source Project // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // cc_defaults { name: "simpleperf_defaults", cflags: [ "-Wall", "-Wextra", "-Werror", "-Wimplicit-fallthrough", // Try some more extreme warnings. "-Wpedantic", "-Wunreachable-code-aggressive", "-Wno-zero-length-array", "-Wno-c99-extensions", "-Wno-language-extension-token", "-Wno-gnu-zero-variadic-macro-arguments", "-Wno-nested-anon-types", "-Wno-gnu-statement-expression", "-Wno-vla-extension", ], cppflags: [ "-Wno-sign-compare", "-Wno-unused-parameter", ], } cc_defaults { name: "libsimpleperf_elf_read_static_reqs_defaults", static_libs: [ "libLLVMObject", "libLLVMBitReader", "libLLVMMC", "libLLVMMCParser", "libLLVMCore", "libLLVMSupport", "liblzma", "libz", "libziparchive", ], } cc_library_static { name: "libsimpleperf_elf_read", defaults: [ "simpleperf_defaults", "libsimpleperf_elf_read_static_reqs_defaults", ], host_supported: true, export_include_dirs: [ ".", ], static_libs: [ "libbase", ], srcs: [ "read_apk.cpp", "read_elf.cpp", "utils.cpp", ], group_static_libs: true, use_version_lib: true, } cc_defaults { name: "simpleperf_cflags", target: { host: { cflags: [ "-DUSE_BIONIC_UAPI_HEADERS", "-fvisibility=hidden" ], include_dirs: ["bionic/libc/kernel"], }, darwin: { cflags: ["-DNO_LIBDEXFILE_SUPPORT"], local_include_dirs: ["nonlinux_support/include"], }, windows: { cflags: ["-DNO_LIBDEXFILE_SUPPORT"], local_include_dirs: ["nonlinux_support/include"], } }, } // linked as a separate library because using OpenCSD headers needs to enable exception cc_library_static { name: "libsimpleperf_etm_decoder", defaults: [ "simpleperf_cflags", "libsimpleperf_elf_read_static_reqs_defaults", ], host_supported: true, srcs: ["ETMDecoder.cpp"], cppflags: [ // flags needed to include libopencsd_decoder headers "-Wno-ignored-qualifiers", "-Wno-unused-parameter", "-Wno-switch", "-Wno-unused-private-field", "-Wno-implicit-fallthrough", "-fexceptions", ], rtti: true, static_libs: [ "libopencsd_decoder", "libbase", "liblog", ], target: { windows: { enabled: true, } } } cc_defaults { name: "simpleperf_static_libs", defaults: [ "libsimpleperf_elf_read_static_reqs_defaults", "simpleperf_cflags", ], host_supported: true, static_libs: [ "libsimpleperf_etm_decoder", "libbase", "liblog", "libutils", "libprotobuf-cpp-lite", "libopencsd_decoder", ], target: { linux: { static_libs: [ "libunwindstack", "libcutils", "libprocinfo", "libevent", "libc++fs", ], }, android: { static_libs: [ "libc", ], }, host: { stl: "libc++_static", }, windows: { enabled: true, }, }, use_version_lib: true, } cc_defaults { name: "simpleperf_shared_libs", defaults: [ "simpleperf_cflags", ], host_supported: true, shared_libs: [ "libbase", "liblzma", "libprotobuf-cpp-lite", "libziparchive", ], static_libs: [ "libsimpleperf_etm_decoder", "libopencsd_decoder", ], target: { linux: { shared_libs: [ "libcutils", "libdexfile_support", "libevent", "libprocinfo", "libunwindstack", ], static_libs: [ "libc++fs", ], }, host: { static_libs: [ "libLLVMObject", "libLLVMBitReader", "libLLVMMC", "libLLVMMCParser", "libLLVMCore", "libLLVMSupport", ], }, windows: { enabled: true, }, }, use_version_lib: true, } cc_defaults { name: "simpleperf_libs_for_tests", defaults: ["simpleperf_shared_libs"], target: { android: { // 32-bit libLLVM_android isn't shipped on device. So use static llvm libs in tests. static_libs: [ "libLLVMObject", "libLLVMBitReader", "libLLVMMC", "libLLVMMCParser", "libLLVMCore", "libLLVMSupport", ], }, }, } cc_defaults { name: "libsimpleperf_srcs", srcs: [ "cmd_dumprecord.cpp", "cmd_help.cpp", "cmd_inject.cpp", "cmd_kmem.cpp", "cmd_report.cpp", "cmd_report_sample.cpp", "command.cpp", "dso.cpp", "etm_branch_list.proto", "event_attr.cpp", "event_type.cpp", "perf_regs.cpp", "read_apk.cpp", "read_elf.cpp", "record.cpp", "record_file_reader.cpp", "report_sample.proto", "thread_tree.cpp", "tracing.cpp", "utils.cpp", ], target: { linux: { srcs: [ "CallChainJoiner.cpp", "cmd_api.cpp", "cmd_debug_unwind.cpp", "cmd_list.cpp", "cmd_record.cpp", "cmd_stat.cpp", "cmd_trace_sched.cpp", "environment.cpp", "ETMRecorder.cpp", "event_fd.cpp", "event_selection_set.cpp", "IOEventLoop.cpp", "JITDebugReader.cpp", "OfflineUnwinder.cpp", "read_dex_file.cpp", "record_file_writer.cpp", "RecordReadThread.cpp", "workload.cpp", ], }, darwin: { srcs: ["nonlinux_support/nonlinux_support.cpp"], }, windows: { srcs: ["nonlinux_support/nonlinux_support.cpp"], }, }, } cc_library_static { name: "libsimpleperf", defaults: [ "libsimpleperf_srcs", "simpleperf_static_libs", ], compile_multilib: "both", proto: { type: "lite", }, static_libs: [ "libbuildversion", ], use_version_lib: false, target: { linux: { // See note for libdexfile_support_static in simpleperf_ndk. static_libs: ["libdexfile_support"], }, }, } // simpleperf shipped in system image cc_binary { name: "simpleperf", defaults: [ "simpleperf_shared_libs", ], host_supported: false, srcs: [ "main.cpp", ], static_libs: ["libsimpleperf"], target: { android: { shared_libs: [ "libLLVM_android", ], }, }, } cc_library { name: "libsimpleperf_profcollect", defaults: [ "simpleperf_shared_libs", ], host_supported: false, srcs: ["profcollect.cpp"], export_include_dirs: ["include"], static_libs: ["libsimpleperf",], shared_libs: ["libLLVM_android",], visibility: ["//system/extras/profcollectd:__subpackages__"], } // simpleperf released in ndk cc_binary { name: "simpleperf_ndk", defaults: [ "simpleperf_static_libs", ], dist: { targets: ["simpleperf"], }, srcs: [ "main.cpp", ], static_libs: [ "libsimpleperf", ], compile_multilib: "both", multilib: { lib64: { suffix: "64", }, }, target: { android: { static_executable: true, }, android_arm: { dist: { dir: "simpleperf/android/arm", }, }, android_arm64: { dist: { dir: "simpleperf/android/arm64", }, }, android_x86: { dist: { dir: "simpleperf/android/x86", }, }, android_x86_64: { dist: { dir: "simpleperf/android/x86_64", }, }, darwin: { dist: { dir: "simpleperf/darwin/x86", }, }, darwin_x86_64: { dist: { dir: "simpleperf/darwin/x86_64", }, }, linux: { // In the NDK we need libdexfile_support_static which links // libdexfile_external and its ART dependencies statically. However // in other libraries we must use libdexfile_support, which dlopen's // libdexfile_external.so from the ART APEX, to avoid getting ART // internals in the system image. static_libs: ["libdexfile_support_static"], }, linux_glibc_x86: { dist: { dir: "simpleperf/linux/x86", }, }, linux_glibc_x86_64: { dist: { dir: "simpleperf/linux/x86_64", }, }, windows_x86: { dist: { dir: "simpleperf/windows/x86", }, }, windows_x86_64: { dist: { dir: "simpleperf/windows/x86_64", }, }, }, } // It's linked to user's program, to get profile counters and samples for specific code ranges. cc_library { name: "libsimpleperf_record", defaults: [ "simpleperf_static_libs", ], export_include_dirs: ["include"], ldflags: ["-Wl,--exclude-libs,ALL"], srcs: [ "record_lib_interface.cpp", ], static_libs: [ "libsimpleperf" ], target: { darwin: { enabled: false, }, windows: { enabled: false, }, linux: { // See note for libdexfile_support_static in simpleperf_ndk. static_libs: ["libdexfile_support"], }, }, } // It's the shared library used on host by python scripts to report samples in different ways. cc_library_shared { name: "libsimpleperf_report", defaults: [ "simpleperf_static_libs", ], dist: { targets: ["simpleperf"], }, srcs: [ "report_lib_interface.cpp", ], static_libs: ["libsimpleperf"], target: { android: { enabled: false, }, linux: { ldflags: ["-Wl,--exclude-libs,ALL"], // See note for libdexfile_support_static in simpleperf_ndk. This is // part of the NDK, so use libdexfile_support_static. static_libs: ["libdexfile_support_static"], }, darwin: { dist: { dir: "simpleperf/darwin/x86", }, }, darwin_x86_64: { dist: { dir: "simpleperf/darwin/x86_64", }, }, linux_glibc_x86: { dist: { dir: "simpleperf/linux/x86", }, }, linux_glibc_x86_64: { dist: { dir: "simpleperf/linux/x86_64", }, }, windows_x86: { dist: { dir: "simpleperf/windows/x86", }, }, windows_x86_64: { dist: { dir: "simpleperf/windows/x86_64", }, }, }, } cc_defaults { name: "simpleperf_test_srcs", srcs: [ "cmd_inject_test.cpp", "cmd_kmem_test.cpp", "cmd_report_test.cpp", "cmd_report_sample_test.cpp", "command_test.cpp", "dso_test.cpp", "gtest_main.cpp", "read_apk_test.cpp", "read_elf_test.cpp", "record_test.cpp", "sample_tree_test.cpp", "thread_tree_test.cpp", "tracing_test.cpp", "utils_test.cpp", ], target: { linux: { srcs: [ "CallChainJoiner_test.cpp", "cmd_api_test.cpp", "cmd_debug_unwind_test.cpp", "cmd_dumprecord_test.cpp", "cmd_list_test.cpp", "cmd_record_test.cpp", "cmd_stat_test.cpp", "cmd_trace_sched_test.cpp", "environment_test.cpp", "IOEventLoop_test.cpp", "OfflineUnwinder_test.cpp", "read_dex_file_test.cpp", "record_file_test.cpp", "RecordReadThread_test.cpp", "workload_test.cpp", ], }, }, } cc_test { name: "simpleperf_unit_test", defaults: [ "simpleperf_test_srcs", "simpleperf_libs_for_tests", ], static_libs: [ "libgmock", "libsimpleperf" ], target: { android: { test_suites: ["device-tests"], }, }, data: [ "testdata/**/*", ], } cc_test { name: "simpleperf_cpu_hotplug_test", defaults: [ "simpleperf_libs_for_tests", ], srcs: [ "cpu_hotplug_test.cpp", ], static_libs: ["libsimpleperf"], target: { android: { test_suites: ["device-tests"], }, darwin: { enabled: false, }, windows: { enabled: false, }, }, } cc_library_static { name: "libsimpleperf_cts_test", defaults: [ "simpleperf_test_srcs", "simpleperf_libs_for_tests", ], host_supported: false, cflags: [ "-DIN_CTS_TEST", ], static_libs: [ "libgtest", ], whole_static_libs: [ "libgmock", "libsimpleperf", ], } cc_test { name: "simpleperf_record_test", defaults: [ "simpleperf_libs_for_tests", ], srcs: [ "record_lib_test.cpp", ], shared_libs: ["libsimpleperf_record"], target: { android: { test_suites: ["device-tests"], }, darwin: { enabled: false, }, windows: { enabled: false, }, }, }