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
17# -----------------------------------------------------------------------------
18# Library used by dlext tests - zipped and aligned
19# -----------------------------------------------------------------------------
20
21BIONIC_TESTS_ZIPALIGN := $(HOST_OUT_EXECUTABLES)/bionic_tests_zipalign
22
23include $(CLEAR_VARS)
24
25LOCAL_MODULE_CLASS := NATIVE_TESTS
26LOCAL_MODULE := libdlext_test_zip_zipaligned
27LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
28LOCAL_LICENSE_CONDITIONS := notice
29LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
30LOCAL_MODULE_SUFFIX := .zip
31LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_zip
32LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
33
34include $(BUILD_SYSTEM)/base_rules.mk
35
36my_shared_libs := \
37  $(call intermediates-dir-for,SHARED_LIBRARIES,libdlext_test_zip,,,$(bionic_2nd_arch_prefix))/libdlext_test_zip.so \
38  $(call intermediates-dir-for,SHARED_LIBRARIES,libatest_simple_zip,,,$(bionic_2nd_arch_prefix))/libatest_simple_zip.so \
39  $(call intermediates-dir-for,NATIVE_TESTS,exec_linker_helper,,,$(bionic_2nd_arch_prefix))/exec_linker_helper \
40  $(call intermediates-dir-for,SHARED_LIBRARIES,exec_linker_helper_lib,,,$(bionic_2nd_arch_prefix))/exec_linker_helper_lib.so
41
42$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBS := $(my_shared_libs)
43$(LOCAL_BUILT_MODULE): $(my_shared_libs) $(BIONIC_TESTS_ZIPALIGN)
44	@echo "Aligning zip: $@"
45	$(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir
46	$(hide) cp $(PRIVATE_SHARED_LIBS) $(dir $@)/zipdir/libdir
47	$(hide) touch $(dir $@)/zipdir/empty_file.txt
48	$(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
49	$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
50
51include $(CLEAR_VARS)
52
53LOCAL_MODULE_CLASS := NATIVE_TESTS
54LOCAL_MODULE := libdlext_test_runpath_zip_zipaligned
55LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
56LOCAL_LICENSE_CONDITIONS := notice
57LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
58LOCAL_MODULE_SUFFIX := .zip
59LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_runpath_zip
60LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
61
62include $(BUILD_SYSTEM)/base_rules.mk
63lib_d := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_d_zip,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_d_zip.so
64lib_a := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_a,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_a.so
65lib_b := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_b,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_b.so
66lib_c := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_c,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_c.so
67lib_x := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_x,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_x.so
68lib_y := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_y,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_y.so
69
70$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_D := $(lib_d)
71$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_A := $(lib_a)
72$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_B := $(lib_b)
73$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_C := $(lib_c)
74$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_X := $(lib_x)
75$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_Y := $(lib_y)
76ifeq ($(TARGET_IS_64_BIT),true)
77  ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
78    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib/$(TARGET_2ND_ARCH),lib64)
79  else
80    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib,lib64)
81  endif
82else
83  ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
84    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib/$(TARGET_2ND_ARCH),lib)
85  else
86    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := lib
87  endif
88endif
89$(LOCAL_BUILT_MODULE) : $(lib_d) $(lib_a) $(lib_b) $(lib_c) $(lib_x) $(lib_y) $(BIONIC_TESTS_ZIPALIGN)
90	@echo "Aligning zip: $@"
91	$(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir && \
92    mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_a && mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_b_c_x && \
93    mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_y/$(PRIVATE_LIB_OR_LIB64)
94	$(hide) cp $(PRIVATE_LIB_D) $(dir $@)/zipdir/libdir
95	$(hide) cp $(PRIVATE_LIB_A) $(dir $@)/zipdir/libdir/dt_runpath_a
96	$(hide) cp $(PRIVATE_LIB_B) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
97	$(hide) cp $(PRIVATE_LIB_C) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
98	$(hide) cp $(PRIVATE_LIB_X) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
99	$(hide) cp $(PRIVATE_LIB_Y) $(dir $@)/zipdir/libdir/dt_runpath_y/$(PRIVATE_LIB_OR_LIB64)
100	$(hide) touch $(dir $@)/zipdir/empty_file.txt
101	$(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
102	$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
103