2 # Copyright (C) 2015 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 LOCAL_PATH := $(call my-dir)
18 simpleperf_version := $(shell git -C $(LOCAL_PATH) rev-parse --short=12 HEAD 2>/dev/null)
20 simpleperf_common_cppflags := -Wextra -Wunused -Wno-unknown-pragmas \
21 -DSIMPLEPERF_REVISION='"$(simpleperf_version)"'
23 simpleperf_cppflags_target := $(simpleperf_common_cppflags)
25 simpleperf_cppflags_host := $(simpleperf_common_cppflags) \
26 -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \
29 simpleperf_cppflags_host_darwin := -I $(LOCAL_PATH)/nonlinux_support/include
30 simpleperf_cppflags_host_windows := -I $(LOCAL_PATH)/nonlinux_support/include
33 LLVM_ROOT_PATH := external/llvm
34 include $(LLVM_ROOT_PATH)/llvm.mk
36 simpleperf_static_libraries_target := \
37 libbacktrace_offline \
54 libprotobuf-cpp-lite \
58 simpleperf_static_libraries_host := \
71 libprotobuf-cpp-lite \
73 simpleperf_static_libraries_host_linux := \
75 libbacktrace_offline \
81 simpleperf_ldlibs_host_linux := -lrt
84 # =========================================================
85 libsimpleperf_src_files := \
90 cmd_report_sample.cpp \
99 record_file_reader.cpp \
100 report_sample.proto \
105 libsimpleperf_src_files_linux := \
112 event_selection_set.cpp \
113 InplaceSamplerClient.cpp \
116 record_file_writer.cpp \
120 libsimpleperf_src_files_darwin := \
121 nonlinux_support/nonlinux_support.cpp \
123 libsimpleperf_src_files_windows := \
124 nonlinux_support/nonlinux_support.cpp \
126 # libsimpleperf target
127 include $(CLEAR_VARS)
129 LOCAL_MODULE := libsimpleperf
130 LOCAL_MODULE_TAGS := debug
131 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
132 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
134 $(libsimpleperf_src_files) \
135 $(libsimpleperf_src_files_linux) \
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)
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)
167 # =========================================================
170 include $(CLEAR_VARS)
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
183 LOCAL_FORCE_STATIC_EXECUTABLE := true
184 include $(LLVM_DEVICE_BUILD_MK)
185 include $(BUILD_EXECUTABLE)
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))
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)
211 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host.BUILT):simpleperf_host)
213 $(call dist-for-goals,sdk,$(ALL_MODULES.simpleperf_host$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):simpleperf_host32)
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))
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)
241 $(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report.BUILT))
243 $(call dist-for-goals,sdk,$(ALL_MODULES.libsimpleperf_report$(HOST_2ND_ARCH_MODULE_SUFFIX).BUILT):libsimpleperf_report32.so)
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))
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 # =========================================================
256 libsimpleperf_inplace_sampler_static_libraries_target := \
257 $(filter-out libc,$(simpleperf_static_libraries_target)) \
259 # libsimpleperf_inplace_sampler.so on target
260 include $(CLEAR_VARS)
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)
272 # libsimpleperf_inplace_sampler.so on host
273 include $(CLEAR_VARS)
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)
289 # simpleperf_unit_test
290 # =========================================================
291 simpleperf_unit_test_src_files := \
293 cmd_report_test.cpp \
294 cmd_report_sample_test.cpp \
300 sample_tree_test.cpp \
303 simpleperf_unit_test_src_files_linux := \
304 cmd_dumprecord_test.cpp \
306 cmd_record_test.cpp \
308 environment_test.cpp \
309 IOEventLoop_test.cpp \
310 record_file_test.cpp \
311 UnixSocket_test.cpp \
314 # simpleperf_unit_test target
315 include $(CLEAR_VARS)
317 LOCAL_MODULE := simpleperf_unit_test
318 LOCAL_COMPATIBILITY_SUITE := device-tests
319 LOCAL_CPPFLAGS := $(simpleperf_cppflags_target)
321 $(simpleperf_unit_test_src_files) \
322 $(simpleperf_unit_test_src_files_linux) \
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)
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)
349 # simpleperf_cpu_hotplug_test
350 # =========================================================
351 simpleperf_cpu_hotplug_test_src_files := \
352 cpu_hotplug_test.cpp \
354 # simpleperf_cpu_hotplug_test target
355 include $(CLEAR_VARS)
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)
367 # simpleperf_cpu_hotplug_test linux host
368 include $(CLEAR_VARS)
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)
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) \
391 # libsimpleperf_cts_test target
392 include $(CLEAR_VARS)
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)
403 # libsimpleperf_cts_test linux host
404 include $(CLEAR_VARS)
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)
418 include $(call first-makefiles-under,$(LOCAL_PATH))