1#
2# Copyright (C) 2014 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
19include art/build/Android.common_build.mk
20
21LIBNATIVEBRIDGETEST_COMMON_SRC_FILES := \
22  115-native-bridge/nativebridge.cc
23
24ART_TARGET_LIBNATIVEBRIDGETEST_$(ART_PHONY_TEST_TARGET_SUFFIX) += $(ART_TARGET_TEST_OUT)/$(TARGET_ARCH)/libnativebridgetest.so
25ifdef TARGET_2ND_ARCH
26  ART_TARGET_LIBNATIVEBRIDGETEST_$(2ND_ART_PHONY_TEST_TARGET_SUFFIX) += $(ART_TARGET_TEST_OUT)/$(TARGET_2ND_ARCH)/libnativebridgetest.so
27endif
28
29# $(1): target or host
30define build-libnativebridgetest
31  ifneq ($(1),target)
32    ifneq ($(1),host)
33      $$(error expected target or host for argument 1, received $(1))
34    endif
35  endif
36
37  art_target_or_host := $(1)
38
39  include $(CLEAR_VARS)
40  LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
41  LOCAL_MODULE := libnativebridgetest
42  ifeq ($$(art_target_or_host),target)
43    LOCAL_MODULE_TAGS := tests
44  endif
45  LOCAL_SRC_FILES := $(LIBNATIVEBRIDGETEST_COMMON_SRC_FILES)
46  LOCAL_SHARED_LIBRARIES += libartd
47  LOCAL_C_INCLUDES += $(ART_C_INCLUDES) art/runtime
48  LOCAL_ADDITIONAL_DEPENDENCIES := art/build/Android.common_build.mk
49  LOCAL_ADDITIONAL_DEPENDENCIES += $(LOCAL_PATH)/Android.libnativebridgetest.mk
50  ifeq ($$(art_target_or_host),target)
51    $(call set-target-local-clang-vars)
52    $(call set-target-local-cflags-vars,debug)
53    LOCAL_SHARED_LIBRARIES += libdl
54    LOCAL_STATIC_LIBRARIES := libgtest
55    LOCAL_MULTILIB := both
56    LOCAL_MODULE_PATH_32 := $(ART_TARGET_TEST_OUT)/$(ART_TARGET_ARCH_32)
57    LOCAL_MODULE_PATH_64 := $(ART_TARGET_TEST_OUT)/$(ART_TARGET_ARCH_64)
58    LOCAL_MODULE_TARGET_ARCH := $(ART_SUPPORTED_ARCH)
59    include $(BUILD_SHARED_LIBRARY)
60  else # host
61    LOCAL_CLANG := $(ART_HOST_CLANG)
62    LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
63    LOCAL_SHARED_LIBRARIES := libcutils
64    LOCAL_LDLIBS := $(ART_HOST_LDLIBS) -ldl -lpthread
65    ifeq ($(HOST_OS),linux)
66      LOCAL_LDLIBS += -lrt
67    endif
68    LOCAL_IS_HOST_MODULE := true
69    LOCAL_MULTILIB := both
70    include $(BUILD_HOST_SHARED_LIBRARY)
71  endif
72
73  # Clear locally used variables.
74  art_target_or_host :=
75endef
76
77ifeq ($(ART_BUILD_TARGET),true)
78  $(eval $(call build-libnativebridgetest,target))
79endif
80ifeq ($(ART_BUILD_HOST),true)
81  $(eval $(call build-libnativebridgetest,host))
82endif
83
84# Clear locally used variables.
85LOCAL_PATH :=
86LIBNATIVEBRIDGETEST_COMMON_SRC_FILES :=
87