1#
2# Copyright (C) 2013 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
17LOCAL_PATH := $(call my-dir)
18
19benchmark_cflags := \
20    -O2 \
21    -fno-builtin \
22    -Wall \
23    -Wextra \
24    -Werror \
25    -Wunused \
26
27benchmark_cppflags := \
28
29benchmark_src_files := \
30    math_benchmark.cpp \
31    property_benchmark.cpp \
32    pthread_benchmark.cpp \
33    semaphore_benchmark.cpp \
34    stdio_benchmark.cpp \
35    string_benchmark.cpp \
36    time_benchmark.cpp \
37    unistd_benchmark.cpp \
38
39# Build benchmarks for the device (with bionic's .so). Run with:
40#   adb shell bionic-benchmarks32
41#   adb shell bionic-benchmarks64
42include $(CLEAR_VARS)
43LOCAL_MODULE := bionic-benchmarks
44LOCAL_MODULE_STEM_32 := bionic-benchmarks32
45LOCAL_MODULE_STEM_64 := bionic-benchmarks64
46LOCAL_MULTILIB := both
47LOCAL_CFLAGS := $(benchmark_cflags)
48LOCAL_CPPFLAGS := $(benchmark_cppflags)
49LOCAL_SRC_FILES := $(benchmark_src_files)
50include $(BUILD_NATIVE_BENCHMARK)
51
52# We don't build a static benchmark executable because it's not usually
53# useful. If you're trying to run the current benchmarks on an older
54# release, it's (so far at least) always because you want to measure the
55# performance of the old release's libc, and a static benchmark isn't
56# going to let you do that.
57
58# Only supported on linux systems.
59ifeq ($(HOST_OS),linux)
60
61# Build benchmarks for the host (against glibc!). Run with:
62include $(CLEAR_VARS)
63LOCAL_MODULE := bionic-benchmarks-glibc
64LOCAL_MODULE_STEM_32 := bionic-benchmarks-glibc32
65LOCAL_MODULE_STEM_64 := bionic-benchmarks-glibc64
66LOCAL_MULTILIB := both
67LOCAL_CFLAGS := $(benchmark_cflags)
68LOCAL_CPPFLAGS := $(benchmark_cppflags)
69LOCAL_LDFLAGS := -lrt
70LOCAL_SRC_FILES := $(benchmark_src_files)
71LOCAL_STATIC_LIBRARIES := libgoogle-benchmark
72# TODO: BUILD_HOST_NATIVE_BENCHMARK
73include $(BUILD_HOST_EXECUTABLE)
74
75endif
76
77ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
78include $(LOCAL_PATH)/../build/run-on-host.mk
79
80ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86 x86_64))
81bionic-benchmarks-run-on-host32: bionic-benchmarks bionic-prepare-run-on-host
82	ANDROID_DATA=$(TARGET_OUT_DATA) \
83	ANDROID_ROOT=$(TARGET_OUT) \
84		$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks32 $(BIONIC_BENCHMARKS_FLAGS)
85endif
86
87ifeq ($(TARGET_IS_64_BIT),true)
88bionic-benchmarks-run-on-host64: bionic-benchmarks bionic-prepare-run-on-host
89	ANDROID_DATA=$(TARGET_OUT_DATA) \
90	ANDROID_ROOT=$(TARGET_OUT) \
91		$(TARGET_OUT_EXECUTABLES)/bionic-benchmarks64 $(BIONIC_BENCHMARKS_FLAGS)
92endif
93
94endif
95