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.
17 LOCAL_PATH := $(call my-dir)
19 simpleperf_common_cppflags := -std=c++11 -Wall -Wextra -Werror -Wunused
21 simpleperf_host_common_cppflags := $(simpleperf_common_cppflags) \
22 -DUSE_BIONIC_UAPI_HEADERS -I bionic/libc/kernel \
24 simpleperf_host_darwin_cppflags := $(simpleperf_host_common_cppflags) \
25 -I $(LOCAL_PATH)/darwin_support \
27 simpleperf_common_shared_libraries := \
31 LLVM_ROOT_PATH := external/llvm
34 # =========================================================
35 libsimpleperf_common_src_files := \
47 record_file_reader.cpp \
52 libsimpleperf_src_files := \
53 $(libsimpleperf_common_src_files) \
59 event_selection_set.cpp \
60 record_file_writer.cpp \
63 libsimpleperf_darwin_src_files := \
64 $(libsimpleperf_common_src_files) \
65 environment_fake.cpp \
69 LOCAL_CPPFLAGS := $(simpleperf_common_cppflags)
70 LOCAL_SRC_FILES := $(libsimpleperf_src_files)
71 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
72 LOCAL_MODULE := libsimpleperf
73 LOCAL_MODULE_TAGS := debug
74 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
75 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
76 include $(LLVM_ROOT_PATH)/llvm.mk
77 include $(LLVM_DEVICE_BUILD_MK)
78 include $(BUILD_STATIC_LIBRARY)
80 ifeq ($(HOST_OS),linux)
83 LOCAL_CPPFLAGS := $(simpleperf_host_common_cppflags)
84 LOCAL_SRC_FILES := $(libsimpleperf_src_files)
85 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
87 LOCAL_MODULE := libsimpleperf
88 LOCAL_MODULE_TAGS := optional
89 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
90 include $(LLVM_ROOT_PATH)/llvm.mk
91 include $(LLVM_HOST_BUILD_MK)
92 include $(BUILD_HOST_STATIC_LIBRARY)
95 ifeq ($(HOST_OS),darwin)
98 LOCAL_CPPFLAGS := $(simpleperf_host_darwin_cppflags)
99 LOCAL_SRC_FILES := $(libsimpleperf_darwin_src_files)
100 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
101 LOCAL_MODULE := libsimpleperf
102 LOCAL_MODULE_TAGS := optional
103 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
104 include $(LLVM_ROOT_PATH)/llvm.mk
105 include $(LLVM_HOST_BUILD_MK)
106 include $(BUILD_HOST_SHARED_LIBRARY)
110 # =========================================================
111 include $(CLEAR_VARS)
113 LOCAL_CPPFLAGS := $(simpleperf_common_cppflags)
114 LOCAL_SRC_FILES := main.cpp
115 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
116 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
117 LOCAL_MODULE := simpleperf
118 LOCAL_MODULE_TAGS := debug
119 LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
120 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
121 include $(BUILD_EXECUTABLE)
123 ifeq ($(HOST_OS),linux)
124 include $(CLEAR_VARS)
126 LOCAL_CPPFLAGS := $(simpleperf_host_common_cppflags)
127 LOCAL_SRC_FILES := main.cpp
128 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
129 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
131 LOCAL_MODULE := simpleperf
132 LOCAL_MODULE_TAGS := optional
133 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
134 include $(BUILD_HOST_EXECUTABLE)
137 ifeq ($(HOST_OS),darwin)
138 include $(CLEAR_VARS)
140 LOCAL_CPPFLAGS := $(simpleperf_host_darwin_cppflags)
141 LOCAL_SRC_FILES := main.cpp
142 LOCAL_SHARED_LIBRARIES := libsimpleperf $(simpleperf_common_shared_libraries)
143 LOCAL_MODULE := simpleperf
144 LOCAL_MODULE_TAGS := optional
145 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
146 include $(BUILD_HOST_EXECUTABLE)
149 # simpleperf_unit_test
150 # =========================================================
151 simpleperf_unit_test_common_src_files := \
155 sample_tree_test.cpp \
157 simpleperf_unit_test_src_files := \
158 $(simpleperf_unit_test_common_src_files) \
159 cmd_dumprecord_test.cpp \
161 cmd_record_test.cpp \
162 cmd_report_test.cpp \
164 cpu_offline_test.cpp \
165 environment_test.cpp \
167 record_file_test.cpp \
170 include $(CLEAR_VARS)
172 LOCAL_CPPFLAGS := $(simpleperf_common_cppflags)
173 LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
174 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
175 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
176 LOCAL_MODULE := simpleperf_unit_test
177 LOCAL_MODULE_TAGS := optional
178 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
179 include $(BUILD_NATIVE_TEST)
181 ifeq ($(HOST_OS),linux)
182 include $(CLEAR_VARS)
184 LOCAL_CPPFLAGS := $(simpleperf_host_common_cppflags)
185 LOCAL_SRC_FILES := $(simpleperf_unit_test_src_files)
186 LOCAL_WHOLE_STATIC_LIBRARIES := libsimpleperf
187 LOCAL_SHARED_LIBRARIES := $(simpleperf_common_shared_libraries)
188 LOCAL_MODULE := simpleperf_unit_test
189 LOCAL_MODULE_TAGS := optional
190 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
191 include $(BUILD_HOST_NATIVE_TEST)
194 ifeq ($(HOST_OS),darwin)
195 include $(CLEAR_VARS)
197 LOCAL_CPPFLAGS := $(simpleperf_host_darwin_cppflags)
198 LOCAL_SRC_FILES := $(simpleperf_unit_test_common_src_files)
199 LOCAL_SHARED_LIBRARIES := libsimpleperf $(simpleperf_common_shared_libraries)
200 LOCAL_MODULE := simpleperf_unit_test
201 LOCAL_MODULE_TAGS := optional
202 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
203 include $(BUILD_HOST_NATIVE_TEST)