OSDN Git Service

resolve merge conflicts of d38ce6ce to oc-dev-plus-aosp
[android-x86/system-extras.git] / simpleperf / Android.mk
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 #
16 LOCAL_PATH := $(call my-dir)
17
18 simpleperf_version :=  $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
19
20 simpleperf_common_cppflags := -Wextra -Wunused -Wno-unknown-pragmas \
21                               -DSIMPLEPERF_REVISION='"$(simpleperf_version)"'
22
23 simpleperf_cppflags_target := $(simpleperf_common_cppflags)
24
25 simpleperf_cppflags_host := $(simpleperf_common_cppflags) \
26                             -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \
27                             -fvisibility=hidden \
28
29 simpleperf_cppflags_host_darwin := -I $(LOCAL_PATH)/nonlinux_support/include
30 simpleperf_cppflags_host_windows := -I $(LOCAL_PATH)/nonlinux_support/include
31
32
33 LLVM_ROOT_PATH := external/llvm
34 include $(LLVM_ROOT_PATH)/llvm.mk
35
36 simpleperf_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
58 simpleperf_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
73 simpleperf_static_libraries_host_linux := \
74   libprocinfo \
75   libbacktrace_offline \
76   libbacktrace \
77   libunwind \
78   libcutils \
79   libevent \
80
81 simpleperf_ldlibs_host_linux := -lrt
82
83 # libsimpleperf
84 # =========================================================
85 libsimpleperf_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
105 libsimpleperf_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
120 libsimpleperf_src_files_darwin := \
121   nonlinux_support/nonlinux_support.cpp \
122
123 libsimpleperf_src_files_windows := \
124   nonlinux_support/nonlinux_support.cpp \
125
126 # libsimpleperf target
127 include $(CLEAR_VARS)
128 LOCAL_CLANG := true
129 LOCAL_MODULE := libsimpleperf
130 LOCAL_MODULE_TAGS := debug
131 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
132 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
133 LOCAL_SRC_FILES := \
134   $(libsimpleperf_src_files) \
135   $(libsimpleperf_src_files_linux) \
136
137 LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
138 LOCAL_MULTILIB := both
139 LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static
140 include $(LLVM_DEVICE_BUILD_MK)
141 include $(BUILD_STATIC_LIBRARY)
142
143 # libsimpleperf host
144 include $(CLEAR_VARS)
145 #LOCAL_CLANG := true  # Comment it to build on windows.
146 LOCAL_MODULE := libsimpleperf
147 LOCAL_MODULE_HOST_OS := darwin linux windows
148 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
149 LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
150 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
151 LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
152 LOCAL_SRC_FILES := $(libsimpleperf_src_files)
153 LOCAL_SRC_FILES_darwin := $(libsimpleperf_src_files_darwin)
154 LOCAL_SRC_FILES_linux := $(libsimpleperf_src_files_linux)
155 LOCAL_SRC_FILES_windows := $(libsimpleperf_src_files_windows)
156 LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
157 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
158 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
159 LOCAL_MULTILIB := both
160 LOCAL_PROTOC_OPTIMIZE_TYPE := lite-static
161 LOCAL_CXX_STL := libc++_static
162 include $(LLVM_HOST_BUILD_MK)
163 include $(BUILD_HOST_STATIC_LIBRARY)
164
165
166 # simpleperf
167 # =========================================================
168
169 # simpleperf target
170 include $(CLEAR_VARS)
171 LOCAL_CLANG := true
172 LOCAL_MODULE := simpleperf
173 LOCAL_MODULE_TAGS := debug
174 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
175 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
176 LOCAL_SRC_FILES := main.cpp
177 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
178 ifdef TARGET_2ND_ARCH
179 LOCAL_MULTILIB := both
180 LOCAL_MODULE_STEM_32 := simpleperf32
181 LOCAL_MODULE_STEM_64 := simpleperf
182 endif
183 LOCAL_FORCE_STATIC_EXECUTABLE := true
184 include $(LLVM_DEVICE_BUILD_MK)
185 include $(BUILD_EXECUTABLE)
186
187 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf.BUILT))
188 ifdef TARGET_2ND_ARCH
189 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT))
190 endif
191
192 # simpleperf host
193 include $(CLEAR_VARS)
194 LOCAL_MODULE := simpleperf_host
195 LOCAL_MODULE_HOST_OS := darwin linux windows
196 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
197 LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
198 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
199 LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
200 LOCAL_SRC_FILES := main.cpp
201 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
202 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
203 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
204 LOCAL_MULTILIB := both
205 LOCAL_MODULE_STEM_32 := simpleperf32
206 LOCAL_MODULE_STEM_64 := simpleperf
207 LOCAL_CXX_STL := libc++_static
208 include $(LLVM_HOST_BUILD_MK)
209 include $(BUILD_HOST_EXECUTABLE)
210
211 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host.BUILT):simpleperf_host)
212 ifdef HOST_2ND_ARCH
213 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):simpleperf_host32)
214 endif
215 $(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_simpleperf_host.BUILT))
216 ifdef HOST_CROSS_2ND_ARCH
217 $(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_simpleperf_host$(HOST_CROSS_2ND_ARCH_MODULE_SUFFIX).BUILT))
218 endif
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 # =========================================================
225 include $(CLEAR_VARS)
226 LOCAL_MODULE := libsimpleperf_report
227 LOCAL_MODULE_HOST_OS := darwin linux windows
228 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
229 LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
230 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
231 LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
232 LOCAL_SRC_FILES := report_lib_interface.cpp
233 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
234 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
235 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) -Wl,--exclude-libs,ALL
236 LOCAL_MULTILIB := both
237 LOCAL_CXX_STL := libc++_static
238 include $(LLVM_HOST_BUILD_MK)
239 include $(BUILD_HOST_SHARED_LIBRARY)
240
241 $(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report.BUILT))
242 ifdef HOST_2ND_ARCH
243 $(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):libsimpleperf_report32.so)
244 endif
245 $(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_libsimpleperf_report.BUILT):libsimpleperf_report32.dll)
246 ifdef HOST_CROSS_2ND_ARCH
247 $(call dist-for-goals,win_sdk,$(ALL_MODULES.host_cross_libsimpleperf_report$(HOST_CROSS_2ND_ARCH_MODULE_SUFFIX).BUILT))
248 endif
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
256 libsimpleperf_inplace_sampler_static_libraries_target := \
257         $(filter-out libc,$(simpleperf_static_libraries_target)) \
258
259 # libsimpleperf_inplace_sampler.so on target
260 include $(CLEAR_VARS)
261 LOCAL_CLANG := true
262 LOCAL_MODULE := libsimpleperf_inplace_sampler
263 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
264 LOCAL_SRC_FILES := inplace_sampler_lib.cpp
265 LOCAL_STATIC_LIBRARIES := libsimpleperf $(libsimpleperf_inplace_sampler_static_libraries_target)
266 LOCAL_MULTILIB := both
267 LOCAL_CXX_STL := libc++_static
268 LOCAL_LDLIBS := -Wl,--exclude-libs,ALL
269 include $(LLVM_DEVICE_BUILD_MK)
270 include $(BUILD_SHARED_LIBRARY)
271
272 # libsimpleperf_inplace_sampler.so on host
273 include $(CLEAR_VARS)
274 LOCAL_CLANG := true
275 LOCAL_MODULE := libsimpleperf_inplace_sampler
276 LOCAL_MODULE_HOST_OS := linux
277 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
278 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
279 LOCAL_SRC_FILES := inplace_sampler_lib.cpp
280 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
281 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
282 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux) -Wl,--exclude-libs,ALL
283 LOCAL_MULTILIB := both
284 LOCAL_CXX_STL := libc++_static
285 include $(LLVM_HOST_BUILD_MK)
286 include $(BUILD_HOST_SHARED_LIBRARY)
287
288
289 # simpleperf_unit_test
290 # =========================================================
291 simpleperf_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
303 simpleperf_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
315 include $(CLEAR_VARS)
316 LOCAL_CLANG := true
317 LOCAL_MODULE := simpleperf_unit_test
318 LOCAL_COMPATIBILITY_SUITE := device-tests
319 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
320 LOCAL_SRC_FILES := \
321   $(simpleperf_unit_test_src_files) \
322   $(simpleperf_unit_test_src_files_linux) \
323
324 LOCAL_STATIC_LIBRARIES += libsimpleperf $(simpleperf_static_libraries_target)
325 LOCAL_TEST_DATA := $(call find-test-data-in-subdirs,$(LOCAL_PATH),"*",testdata)
326 LOCAL_MULTILIB := both
327 LOCAL_FORCE_STATIC_EXECUTABLE := true
328 include $(LLVM_DEVICE_BUILD_MK)
329 include $(BUILD_NATIVE_TEST)
330
331 # simpleperf_unit_test host
332 include $(CLEAR_VARS)
333 LOCAL_MODULE := simpleperf_unit_test
334 LOCAL_MODULE_HOST_OS := darwin linux windows
335 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
336 LOCAL_CPPFLAGS_darwin := $(simpleperf_cppflags_host_darwin)
337 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
338 LOCAL_CPPFLAGS_windows := $(simpleperf_cppflags_host_windows)
339 LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
340 LOCAL_SRC_FILES_linux := $(simpleperf_unit_test_src_files_linux)
341 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
342 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
343 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
344 LOCAL_MULTILIB := both
345 include $(LLVM_HOST_BUILD_MK)
346 include $(BUILD_HOST_NATIVE_TEST)
347
348
349 # simpleperf_cpu_hotplug_test
350 # =========================================================
351 simpleperf_cpu_hotplug_test_src_files := \
352   cpu_hotplug_test.cpp \
353
354 # simpleperf_cpu_hotplug_test target
355 include $(CLEAR_VARS)
356 LOCAL_CLANG := true
357 LOCAL_MODULE := simpleperf_cpu_hotplug_test
358 LOCAL_COMPATIBILITY_SUITE := device-tests
359 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
360 LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
361 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_target)
362 LOCAL_MULTILIB := both
363 LOCAL_FORCE_STATIC_EXECUTABLE := true
364 include $(LLVM_DEVICE_BUILD_MK)
365 include $(BUILD_NATIVE_TEST)
366
367 # simpleperf_cpu_hotplug_test linux host
368 include $(CLEAR_VARS)
369 LOCAL_CLANG := true
370 LOCAL_MODULE := simpleperf_cpu_hotplug_test
371 LOCAL_MODULE_HOST_OS := linux
372 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
373 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
374 LOCAL_SRC_FILES := $(simpleperf_cpu_hotplug_test_src_files)
375 LOCAL_STATIC_LIBRARIES := libsimpleperf $(simpleperf_static_libraries_host)
376 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
377 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
378 LOCAL_MULTILIB := first
379 include $(LLVM_HOST_BUILD_MK)
380 include $(BUILD_HOST_NATIVE_TEST)
381
382
383 # libsimpleperf_cts_test
384 # =========================================================
385 libsimpleperf_cts_test_src_files := \
386   $(libsimpleperf_src_files) \
387   $(libsimpleperf_src_files_linux) \
388   $(simpleperf_unit_test_src_files) \
389   $(simpleperf_unit_test_src_files_linux) \
390
391 # libsimpleperf_cts_test target
392 include $(CLEAR_VARS)
393 LOCAL_CLANG := true
394 LOCAL_MODULE := libsimpleperf_cts_test
395 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target) -DRUN_IN_APP_CONTEXT
396 LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files)
397 LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_target)
398 LOCAL_MULTILIB := both
399 LOCAL_FORCE_STATIC_EXECUTABLE := true
400 include $(LLVM_DEVICE_BUILD_MK)
401 include $(BUILD_STATIC_TEST_LIBRARY)
402
403 # libsimpleperf_cts_test linux host
404 include $(CLEAR_VARS)
405 LOCAL_CLANG := true
406 LOCAL_MODULE := libsimpleperf_cts_test
407 LOCAL_MODULE_HOST_OS := linux
408 LOCAL_CPPFLAGS := $(simpleperf_cppflags_host)
409 LOCAL_CPPFLAGS_linux := $(simpleperf_cppflags_host_linux)
410 LOCAL_SRC_FILES := $(libsimpleperf_cts_test_src_files)
411 LOCAL_STATIC_LIBRARIES := $(simpleperf_static_libraries_host)
412 LOCAL_STATIC_LIBRARIES_linux := $(simpleperf_static_libraries_host_linux)
413 LOCAL_LDLIBS_linux := $(simpleperf_ldlibs_host_linux)
414 LOCAL_MULTILIB := both
415 include $(LLVM_HOST_BUILD_MK)
416 include $(BUILD_HOST_STATIC_TEST_LIBRARY)
417
418 include $(call first-makefiles-under,$(LOCAL_PATH))