• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2015 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16LOCAL_PATH := $(call my-dir)
17
18simpleperf_version :=  $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
19
20simpleperf_common_cppflags := -Wextra -Wunused -Wno-unknown-pragmas \
21                              -DSIMPLEPERF_REVISION='"$(simpleperf_version)"'
22
23simpleperf_cppflags_target := $(simpleperf_common_cppflags)
24
25simpleperf_cppflags_host := $(simpleperf_common_cppflags) \
26                            -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \
27                            -fvisibility=hidden \
28
29simpleperf_cppflags_host_darwin := -I $(LOCAL_PATH)/nonlinux_support/include
30simpleperf_cppflags_host_windows := -I $(LOCAL_PATH)/nonlinux_support/include
31
32
33LLVM_ROOT_PATH := external/llvm
34include $(LLVM_ROOT_PATH)/llvm.mk
35
36simpleperf_static_libraries_target := \
37  libbacktrace_offline \
38  libbacktrace \
39  libunwind \
40  libziparchive \
41  libz \
42  libbase \
43  libcutils \
44  liblog \
45  libprocinfo \
46  libutils \
47  liblzma \
48  libLLVMObject \
49  libLLVMBitReader \
50  libLLVMMC \
51  libLLVMMCParser \
52  libLLVMCore \
53  libLLVMSupport \
54  libprotobuf-cpp-lite \
55  libevent \
56  libc \
57
58simpleperf_static_libraries_host := \
59  libziparchive \
60  libbase \
61  liblog \
62  liblzma \
63  libz \
64  libutils \
65  libLLVMObject \
66  libLLVMBitReader \
67  libLLVMMC \
68  libLLVMMCParser \
69  libLLVMCore \
70  libLLVMSupport \
71  libprotobuf-cpp-lite \
72
73simpleperf_static_libraries_host_linux := \
74  libprocinfo \
75  libbacktrace_offline \
76  libbacktrace \
77  libunwind \
78  libcutils \
79  libevent \
80
81simpleperf_ldlibs_host_linux := -lrt
82
83# libsimpleperf
84# =========================================================
85libsimpleperf_src_files := \
86  cmd_dumprecord.cpp \
87  cmd_help.cpp \
88  cmd_kmem.cpp \
89  cmd_report.cpp \
90  cmd_report_sample.cpp \
91  command.cpp \
92  dso.cpp \
93  event_attr.cpp \
94  event_type.cpp \
95  perf_regs.cpp \
96  read_apk.cpp \
97  read_elf.cpp \
98  record.cpp \
99  record_file_reader.cpp \
100  report_sample.proto \
101  thread_tree.cpp \
102  tracing.cpp \
103  utils.cpp \
104
105libsimpleperf_src_files_linux := \
106  cmd_list.cpp \
107  cmd_record.cpp \
108  cmd_stat.cpp \
109  dwarf_unwind.cpp \
110  environment.cpp \
111  event_fd.cpp \
112  event_selection_set.cpp \
113  InplaceSamplerClient.cpp \
114  IOEventLoop.cpp \
115  perf_clock.cpp \
116  record_file_writer.cpp \
117  UnixSocket.cpp \
118  workload.cpp \
119
120libsimpleperf_src_files_darwin := \
121  nonlinux_support/nonlinux_support.cpp \
122
123libsimpleperf_src_files_windows := \
124  nonlinux_support/nonlinux_support.cpp \
125
126# libsimpleperf target
127include $(CLEAR_VARS)
128LOCAL_CLANG := true
129LOCAL_MODULE := libsimpleperf
130LOCAL_MODULE_TAGS := debug
131LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
132LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
133LOCAL_SRC_FILES := \
134  $(libsimpleperf_src_files) \
135  $(libsimpleperf_src_files_linux) \
136
137LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
138LOCAL_MULTILIB := both
139LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static
140include $(LLVM_DEVICE_BUILD_MK)
141include $(BUILD_STATIC_LIBRARY)
142
143# libsimpleperf host
144include $(CLEAR_VARS)
145#LOCAL_CLANG := true  # Comment it to build on windows.
146LOCAL_MODULE := libsimpleperf
147LOCAL_MODULE_HOST_OS := darwin linux windows
148LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
149LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
150LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
151LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
152LOCAL_SRC_FILES := $(libsimpleperf_src_files)
153LOCAL_SRC_FILES_darwin := $(libsimpleperf_src_files_darwin)
154LOCAL_SRC_FILES_linux := $(libsimpleperf_src_files_linux)
155LOCAL_SRC_FILES_windows := $(libsimpleperf_src_files_windows)
156LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
157LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
158LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
159LOCAL_MULTILIB := both
160LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static
161LOCAL_CXX_STL := libc++_static
162include $(LLVM_HOST_BUILD_MK)
163include $(BUILD_HOST_STATIC_LIBRARY)
164
165
166# simpleperf
167# =========================================================
168
169# simpleperf target
170include $(CLEAR_VARS)
171LOCAL_CLANG := true
172LOCAL_MODULE := simpleperf
173LOCAL_MODULE_TAGS := debug
174LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
175LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
176LOCAL_SRC_FILES := main.cpp
177LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
178ifdef TARGET_2ND_ARCH
179LOCAL_MULTILIB := both
180LOCAL_MODULE_STEM_32 := simpleperf32
181LOCAL_MODULE_STEM_64 := simpleperf
182endif
183LOCAL_FORCE_STATIC_EXECUTABLE := true
184include $(LLVM_DEVICE_BUILD_MK)
185include $(BUILD_EXECUTABLE)
186
187$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf.BUILT))
188ifdef TARGET_2ND_ARCH
189$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT))
190endif
191
192# simpleperf host
193include $(CLEAR_VARS)
194LOCAL_MODULE := simpleperf_host
195LOCAL_MODULE_HOST_OS := darwin linux windows
196LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
197LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
198LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
199LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
200LOCAL_SRC_FILES := main.cpp
201LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
202LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
203LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
204LOCAL_MULTILIB := both
205LOCAL_MODULE_STEM_32 := simpleperf32
206LOCAL_MODULE_STEM_64 := simpleperf
207LOCAL_CXX_STL := libc++_static
208include $(LLVM_HOST_BUILD_MK)
209include $(BUILD_HOST_EXECUTABLE)
210
211$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host.BUILT):simpleperf_host)
212ifdef HOST_2ND_ARCH
213$(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):simpleperf_host32)
214endif
215$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_simpleperf_host.BUILT))
216ifdef HOST_CROSS_2ND_ARCH
217$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_simpleperf_host$(HOST_CROSS_2ND_ARCH_MODULE_SUFFIX).BUILT))
218endif
219
220
221# libsimpleperf_report.so
222# It is the shared library used on host by python scripts
223# to report samples in different ways.
224# =========================================================
225include $(CLEAR_VARS)
226LOCAL_MODULE := libsimpleperf_report
227LOCAL_MODULE_HOST_OS := darwin linux windows
228LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
229LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
230LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
231LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
232LOCAL_SRC_FILES := report_lib_interface.cpp
233LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
234LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
235LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) -Wl,--exclude-libs,ALL
236LOCAL_MULTILIB := both
237LOCAL_CXX_STL := libc++_static
238include $(LLVM_HOST_BUILD_MK)
239include $(BUILD_HOST_SHARED_LIBRARY)
240
241$(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report.BUILT))
242ifdef HOST_2ND_ARCH
243$(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):libsimpleperf_report32.so)
244endif
245$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_libsimpleperf_report.BUILT):libsimpleperf_report32.dll)
246ifdef HOST_CROSS_2ND_ARCH
247$(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_libsimpleperf_report$(HOST_CROSS_2ND_ARCH_MODULE_SUFFIX).BUILT))
248endif
249
250
251# libsimpleperf_inplace_sampler.so
252# It is the shared library linked with user's app and get samples from
253# signal handlers in each thread.
254# =========================================================
255
256libsimpleperf_inplace_sampler_static_libraries_target := \
257	$(filter-out libc,$(simpleperf_static_libraries_target)) \
258
259# libsimpleperf_inplace_sampler.so on target
260include $(CLEAR_VARS)
261LOCAL_CLANG := true
262LOCAL_MODULE := libsimpleperf_inplace_sampler
263LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
264LOCAL_SRC_FILES := inplace_sampler_lib.cpp
265LOCAL_STATIC_LIBRARIES := libsimpleperf $(libsimpleperf_inplace_sampler_static_libraries_target)
266LOCAL_MULTILIB := both
267LOCAL_CXX_STL := libc++_static
268LOCAL_LDLIBS := -Wl,--exclude-libs,ALL
269include $(LLVM_DEVICE_BUILD_MK)
270include $(BUILD_SHARED_LIBRARY)
271
272# libsimpleperf_inplace_sampler.so on host
273include $(CLEAR_VARS)
274LOCAL_CLANG := true
275LOCAL_MODULE := libsimpleperf_inplace_sampler
276LOCAL_MODULE_HOST_OS := linux
277LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
278LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
279LOCAL_SRC_FILES := inplace_sampler_lib.cpp
280LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
281LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
282LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) -Wl,--exclude-libs,ALL
283LOCAL_MULTILIB := both
284LOCAL_CXX_STL := libc++_static
285include $(LLVM_HOST_BUILD_MK)
286include $(BUILD_HOST_SHARED_LIBRARY)
287
288
289# simpleperf_unit_test
290# =========================================================
291simpleperf_unit_test_src_files := \
292  cmd_kmem_test.cpp \
293  cmd_report_test.cpp \
294  cmd_report_sample_test.cpp \
295  command_test.cpp \
296  gtest_main.cpp \
297  read_apk_test.cpp \
298  read_elf_test.cpp \
299  record_test.cpp \
300  sample_tree_test.cpp \
301  utils_test.cpp \
302
303simpleperf_unit_test_src_files_linux := \
304  cmd_dumprecord_test.cpp \
305  cmd_list_test.cpp \
306  cmd_record_test.cpp \
307  cmd_stat_test.cpp \
308  environment_test.cpp \
309  IOEventLoop_test.cpp \
310  record_file_test.cpp \
311  UnixSocket_test.cpp \
312  workload_test.cpp \
313
314# simpleperf_unit_test target
315include $(CLEAR_VARS)
316LOCAL_CLANG := true
317LOCAL_MODULE := simpleperf_unit_test
318LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
319LOCAL_SRC_FILES := \
320  $(simpleperf_unit_test_src_files) \
321  $(simpleperf_unit_test_src_files_linux) \
322
323LOCAL_STATIC_LIBRARIES += libsimpleperf $(simpleperf_static_libraries_target)
324LOCAL_TEST_DATA := $(call find-test-data-in-subdirs,$(LOCAL_PATH),"*",testdata)
325LOCAL_MULTILIB := both
326LOCAL_FORCE_STATIC_EXECUTABLE := true
327include $(LLVM_DEVICE_BUILD_MK)
328include $(BUILD_NATIVE_TEST)
329
330# simpleperf_unit_test host
331include $(CLEAR_VARS)
332LOCAL_MODULE := simpleperf_unit_test
333LOCAL_MODULE_HOST_OS := darwin linux windows
334LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
335LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
336LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
337LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
338LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
339LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux)
340LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
341LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
342LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
343LOCAL_MULTILIB := both
344include $(LLVM_HOST_BUILD_MK)
345include $(BUILD_HOST_NATIVE_TEST)
346
347
348# simpleperf_cpu_hotplug_test
349# =========================================================
350simpleperf_cpu_hotplug_test_src_files := \
351  cpu_hotplug_test.cpp \
352
353# simpleperf_cpu_hotplug_test target
354include $(CLEAR_VARS)
355LOCAL_CLANG := true
356LOCAL_MODULE := simpleperf_cpu_hotplug_test
357LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
358LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
359LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
360LOCAL_MULTILIB := both
361LOCAL_FORCE_STATIC_EXECUTABLE := true
362include $(LLVM_DEVICE_BUILD_MK)
363include $(BUILD_NATIVE_TEST)
364
365# simpleperf_cpu_hotplug_test linux host
366include $(CLEAR_VARS)
367LOCAL_CLANG := true
368LOCAL_MODULE := simpleperf_cpu_hotplug_test
369LOCAL_MODULE_HOST_OS := linux
370LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
371LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
372LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
373LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
374LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
375LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
376LOCAL_MULTILIB := first
377include $(LLVM_HOST_BUILD_MK)
378include $(BUILD_HOST_NATIVE_TEST)
379
380
381# libsimpleperf_cts_test
382# =========================================================
383libsimpleperf_cts_test_src_files := \
384  $(libsimpleperf_src_files) \
385  $(libsimpleperf_src_files_linux) \
386  $(simpleperf_unit_test_src_files) \
387  $(simpleperf_unit_test_src_files_linux) \
388
389# libsimpleperf_cts_test target
390include $(CLEAR_VARS)
391LOCAL_CLANG := true
392LOCAL_MODULE := libsimpleperf_cts_test
393LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) -DRUN_IN_APP_CONTEXT
394LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files)
395LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
396LOCAL_MULTILIB := both
397LOCAL_FORCE_STATIC_EXECUTABLE := true
398include $(LLVM_DEVICE_BUILD_MK)
399include $(BUILD_STATIC_TEST_LIBRARY)
400
401# libsimpleperf_cts_test linux host
402include $(CLEAR_VARS)
403LOCAL_CLANG := true
404LOCAL_MODULE := libsimpleperf_cts_test
405LOCAL_MODULE_HOST_OS := linux
406LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
407LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
408LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files)
409LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
410LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
411LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
412LOCAL_MULTILIB := both
413include $(LLVM_HOST_BUILD_MK)
414include $(BUILD_HOST_STATIC_TEST_LIBRARY)
415
416include $(call first-makefiles-under,$(LOCAL_PATH))
417