From ee2952e84ff991ff7adcf55fb604fa100a379ef7 Mon Sep 17 00:00:00 2001 From: Kevin Brodsky Date: Fri, 9 Dec 2016 09:54:42 +0000 Subject: [PATCH] bionic-unit-tests: Build host testlibs in bionic-loader-test-libs The target test libs are now all built in nativetest/bionic-loader-test-libs. However, libs built using libs/Android.build.testlib.mk are still put in lib/ on the host. This commit refactors libs/Android.build.testlib*.mk so that all test libs go into nativetest/bionic-loader-test-libs on the host; nothing changes on the target. Android.build.mk now understands *_install_to_native_tests_dir both for host and target builds. Change-Id: I1022e9bab38bf53036c95fd39b3b240bcb31f23a --- tests/Android.build.mk | 30 +++++++++++-------- tests/libs/Android.build.dt_runpath.mk | 2 +- ...stlib.mk => Android.build.testlib.host.mk} | 7 ++--- tests/libs/Android.build.testlib.internal.mk | 27 +++++++++++++++++ tests/libs/Android.build.testlib.mk | 5 +--- tests/libs/Android.build.testlib.target.mk | 12 ++------ 6 files changed, 52 insertions(+), 31 deletions(-) rename tests/libs/{Android.build.target.testlib.mk => Android.build.testlib.host.mk} (81%) create mode 100644 tests/libs/Android.build.testlib.internal.mk diff --git a/tests/Android.build.mk b/tests/Android.build.mk index cce434479..923655852 100644 --- a/tests/Android.build.mk +++ b/tests/Android.build.mk @@ -20,24 +20,30 @@ LOCAL_ADDITIONAL_DEPENDENCIES := $(common_additional_dependencies) LOCAL_MODULE := $(module) LOCAL_MODULE_TAGS := $(module_tag) ifeq ($(build_type),host) -# Always make host multilib -LOCAL_MULTILIB := both + # Always make host multilib + LOCAL_MULTILIB := both endif ifneq ($(findstring LIBRARY, $(build_target)),LIBRARY) - LOCAL_MODULE_STEM_32 := $(module)32 - LOCAL_MODULE_STEM_64 := $(module)64 + LOCAL_MODULE_STEM_32 := $(module)32 + LOCAL_MODULE_STEM_64 := $(module)64 else -ifneq ($($(module)_install_to_out_data_dir),) - LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$($(module)_install_to_out_data_dir) - LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$($(module)_install_to_out_data_dir) +ifneq ($($(module)_install_to_native_tests_dir),) + ifeq ($(build_type),host) + native_tests_var := HOST_OUT_NATIVE_TESTS + else + native_tests_var := TARGET_OUT_DATA_NATIVE_TESTS + endif + + LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)$(native_tests_var))/$($(module)_install_to_native_tests_dir) + LOCAL_MODULE_PATH_64 := $($(native_tests_var))/$($(module)_install_to_native_tests_dir) endif endif LOCAL_CLANG := $($(module)_clang_$(build_type)) ifneq ($($(module)_allow_asan),true) -LOCAL_SANITIZE := never + LOCAL_SANITIZE := never endif LOCAL_FORCE_STATIC_EXECUTABLE := $($(module)_force_static_executable) @@ -45,11 +51,11 @@ LOCAL_FORCE_STATIC_EXECUTABLE := $($(module)_force_static_executable) LOCAL_ALLOW_UNDEFINED_SYMBOLS := $($(module)_allow_undefined_symbols) ifneq ($($(module)_multilib),) - LOCAL_MULTILIB := $($(module)_multilib) + LOCAL_MULTILIB := $($(module)_multilib) endif ifneq ($($(module)_relative_path),) - LOCAL_MODULE_RELATIVE_PATH := $($(module)_relative_path) + LOCAL_MODULE_RELATIVE_PATH := $($(module)_relative_path) endif LOCAL_CFLAGS := \ @@ -97,9 +103,9 @@ LOCAL_LDLIBS := \ $($(module)_ldlibs_$(build_type)) \ ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true) -LOCAL_CXX_STL := libc++_static + LOCAL_CXX_STL := libc++_static else -LOCAL_CXX_STL := libc++ + LOCAL_CXX_STL := libc++ endif ifeq ($(build_type),target) diff --git a/tests/libs/Android.build.dt_runpath.mk b/tests/libs/Android.build.dt_runpath.mk index 60844e5a7..a3fcac56e 100644 --- a/tests/libs/Android.build.dt_runpath.mk +++ b/tests/libs/Android.build.dt_runpath.mk @@ -80,7 +80,7 @@ libtest_dt_runpath_d_zip_src_files := \ libtest_dt_runpath_d_zip_shared_libraries := libtest_dt_runpath_b libtest_dt_runpath_c libtest_dt_runpath_d_zip_ldflags := -Wl,--rpath,\$${ORIGIN}/dt_runpath_b_c_x -Wl,--enable-new-dtags libtest_dt_runpath_d_zip_ldlibs := -ldl -libtest_dt_runpath_d_zip_install_to_out_data_dir := $(module) +libtest_dt_runpath_d_zip_install_to_native_tests_dir := $(module) module_tag := optional build_type := target diff --git a/tests/libs/Android.build.target.testlib.mk b/tests/libs/Android.build.testlib.host.mk similarity index 81% rename from tests/libs/Android.build.target.testlib.mk rename to tests/libs/Android.build.testlib.host.mk index 1e767c2c1..38970dcec 100644 --- a/tests/libs/Android.build.target.testlib.mk +++ b/tests/libs/Android.build.testlib.host.mk @@ -1,5 +1,5 @@ # -# Copyright (C) 2015 The Android Open Source Project +# Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,6 +15,5 @@ # build_target := SHARED_LIBRARY -build_type := target -include $(TEST_PATH)/Android.build.mk - +build_type := host +include $(LOCAL_PATH)/Android.build.testlib.internal.mk diff --git a/tests/libs/Android.build.testlib.internal.mk b/tests/libs/Android.build.testlib.internal.mk new file mode 100644 index 000000000..e1fec2b31 --- /dev/null +++ b/tests/libs/Android.build.testlib.internal.mk @@ -0,0 +1,27 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# 1. Install test libraries to $ANDROID_DATA/nativetests../bionic-loader-test-libs/ +# by default. +ifeq ($($(module)_relative_install_path),) + $(module)_install_to_native_tests_dir := bionic-loader-test-libs +else + $(module)_install_to_native_tests_dir := bionic-loader-test-libs/$($(module)_relative_install_path) +endif +# 2. Set dt_runpath to origin to resolve dependencies +$(module)_ldflags += -Wl,--rpath,\$${ORIGIN} -Wl,--enable-new-dtags + +include $(TEST_PATH)/Android.build.mk diff --git a/tests/libs/Android.build.testlib.mk b/tests/libs/Android.build.testlib.mk index 833caf606..a46c45750 100644 --- a/tests/libs/Android.build.testlib.mk +++ b/tests/libs/Android.build.testlib.mk @@ -14,9 +14,6 @@ # limitations under the License. # -build_target := SHARED_LIBRARY -build_type := host -include $(TEST_PATH)/Android.build.mk +include $(LOCAL_PATH)/Android.build.testlib.host.mk include $(LOCAL_PATH)/Android.build.testlib.target.mk - diff --git a/tests/libs/Android.build.testlib.target.mk b/tests/libs/Android.build.testlib.target.mk index b79dbfc28..5ec0d715c 100644 --- a/tests/libs/Android.build.testlib.target.mk +++ b/tests/libs/Android.build.testlib.target.mk @@ -14,14 +14,6 @@ # limitations under the License. # +build_target := SHARED_LIBRARY build_type := target -# 1. Install test libraries to /data/nativetests../bionic-loader-test-libs/ -# by default. -ifeq ($($(module)_relative_install_path),) - $(module)_install_to_out_data_dir := bionic-loader-test-libs -else - $(module)_install_to_out_data_dir := bionic-loader-test-libs/$($(module)_relative_install_path) -endif -# 2. Set dt_runpath to origin to resolve dependencies -$(module)_ldflags += -Wl,--rpath,\$${ORIGIN} -Wl,--enable-new-dtags -include $(TEST_PATH)/Android.build.mk +include $(LOCAL_PATH)/Android.build.testlib.internal.mk