blob: c2dadbd2c961a47017183ab21cb46b3cf9416925 [file] [log] [blame]
Jae Shine6b7c842017-10-20 17:46:46 +09001# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15current_makefile := $(lastword $(MAKEFILE_LIST))
16
17# BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot.
18ifeq ($(BOARD_VNDK_VERSION),current)
19
Jae Shin0b1792e2017-12-21 19:04:13 +090020# PLATFORM_VNDK_VERSION must be set.
21ifneq (,$(PLATFORM_VNDK_VERSION))
22
Justin Yun4dff0c62018-01-04 10:51:16 +090023# BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'.
24ifneq ($(BOARD_VNDK_RUNTIME_DISABLE),true)
25
Jae Shine6b7c842017-10-20 17:46:46 +090026# Returns arch-specific libclang_rt.ubsan* library name.
27# Because VNDK_CORE_LIBRARIES includes all arch variants for libclang_rt.ubsan*
28# libs, the arch-specific libs are selected separately.
29#
30# Args:
31# $(1): if not empty, evaluates for TARGET_2ND_ARCH
32define clang-ubsan-vndk-core
Jae Shin4736dc12017-11-22 19:25:36 +090033$(strip \
34 $(eval prefix := $(if $(1),2ND_,)) \
35 $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY))) \
36)
Jae Shine6b7c842017-10-20 17:46:46 +090037endef
38
Jae Shin4736dc12017-11-22 19:25:36 +090039# Returns list of file paths of the intermediate objs
40#
Jae Shine6b7c842017-10-20 17:46:46 +090041# Args:
Jae Shin77c07dd2017-12-22 11:24:00 +090042# $(1): list of module and filename pairs (e.g., ld.config.txt:ld.config.27.txt ...)
Jae Shin4736dc12017-11-22 19:25:36 +090043# $(2): target class (e.g., SHARED_LIBRARIES, STATIC_LIBRARIES, ETC)
44# $(3): if not empty, evaluates for TARGET_2ND_ARCH
Jae Shine6b7c842017-10-20 17:46:46 +090045define paths-of-intermediates
Jae Shin4736dc12017-11-22 19:25:36 +090046$(strip \
Jae Shin77c07dd2017-12-22 11:24:00 +090047 $(foreach pair,$(1), \
48 $(eval split_pair := $(subst :,$(space),$(pair))) \
49 $(eval module := $(word 1,$(split_pair))) \
50 $(eval filename := $(word 2,$(split_pair))) \
51 $(eval dir := $(call intermediates-dir-for,$(2),$(module),,,$(3))) \
52 $(call append-path,$(dir),$(filename)) \
Jae Shin4736dc12017-11-22 19:25:36 +090053 ) \
54)
Jae Shine6b7c842017-10-20 17:46:46 +090055endef
56
Jae Shin410a1af2017-12-15 19:35:16 +090057# Returns paths of notice files under $(TARGET_OUT_NOTICE_FILES)
58#
59# Args:
60# $(1): list of lib names (e.g., libfoo.vendor)
61# $(2): vndk lib type, one of 'vndk' or 'vndk-sp'
62define paths-of-notice-files
63$(strip \
64 $(eval lib_dir := lib$(if $(TARGET_IS_64BIT),64,)) \
65 $(eval vndk_dir := $(2)-$(PLATFORM_VNDK_VERSION)) \
66 $(foreach lib,$(1), \
67 $(eval notice_file_name := $(patsubst %.vendor,%.so.txt,$(lib))) \
68 $(TARGET_OUT_NOTICE_FILES)/src/system/$(lib_dir)/$(vndk_dir)/$(notice_file_name) \
69 ) \
70)
71endef
72
Jae Shine6b7c842017-10-20 17:46:46 +090073# If in the future libclang_rt.ubsan* is removed from the VNDK-core list,
74# need to update the related logic in this file.
75ifeq (,$(filter libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
Jae Shin4736dc12017-11-22 19:25:36 +090076 $(warning libclang_rt.ubsan* is no longer a VNDK-core library. Please update this file.)
77 vndk_core_libs := $(addsuffix .vendor,$(VNDK_CORE_LIBRARIES))
78else
79 vndk_core_libs := $(addsuffix .vendor,$(filter-out libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES)))
80
81 # for TARGET_ARCH
82 vndk_core_libs += $(call clang-ubsan-vndk-core)
83
84 # TODO(b/69834489): Package additional arch variants
85 # ifdef TARGET_2ND_ARCH
86 # vndk_core_libs += $(call clang-ubsan-vndk-core,true)
87 # endif
Jae Shine6b7c842017-10-20 17:46:46 +090088endif
89
Jae Shin4736dc12017-11-22 19:25:36 +090090vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
91vndk_private_libs := $(addsuffix .vendor,$(VNDK_PRIVATE_LIBRARIES))
Jae Shine6b7c842017-10-20 17:46:46 +090092
Jae Shin4736dc12017-11-22 19:25:36 +090093vndk_snapshot_libs := \
94 $(vndk_core_libs) \
95 $(vndk_sp_libs)
Jae Shine6b7c842017-10-20 17:46:46 +090096
Jae Shin4736dc12017-11-22 19:25:36 +090097vndk_prebuilt_txts := \
98 ld.config.txt \
99 vndksp.libraries.txt \
100 llndk.libraries.txt
101
102vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
103vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot
104vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs
105
106#######################################
107# vndkcore.libraries.txt
108vndkcore.libraries.txt := $(vndk_snapshot_configs_out)/vndkcore.libraries.txt
109$(vndkcore.libraries.txt): $(vndk_core_libs)
110 @echo 'Generating: $@'
111 @rm -f $@
112 @mkdir -p $(dir $@)
113 $(hide) echo -n > $@
114 $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
115
116
117#######################################
118# vndkprivate.libraries.txt
119vndkprivate.libraries.txt := $(vndk_snapshot_configs_out)/vndkprivate.libraries.txt
120$(vndkprivate.libraries.txt): $(vndk_private_libs)
121 @echo 'Generating: $@'
122 @rm -f $@
123 @mkdir -p $(dir $@)
124 $(hide) echo -n > $@
125 $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
126
127
Jae Shin410a1af2017-12-15 19:35:16 +0900128#######################################
129# module_paths.txt
130module_paths.txt := $(vndk_snapshot_configs_out)/module_paths.txt
131$(module_paths.txt): $(vndk_snapshot_libs)
132 @echo 'Generating: $@'
133 @rm -f $@
134 @mkdir -p $(dir $@)
135 $(hide) echo -n > $@
136 $(hide) $(foreach lib,$^,echo $(patsubst %.vendor,%,$(lib)).so $(ALL_MODULES.$(lib).PATH) >> $@;)
137
138
Jae Shin4736dc12017-11-22 19:25:36 +0900139vndk_snapshot_configs := \
140 $(vndkcore.libraries.txt) \
Jae Shin410a1af2017-12-15 19:35:16 +0900141 $(vndkprivate.libraries.txt) \
142 $(module_paths.txt)
Jae Shin4736dc12017-11-22 19:25:36 +0900143
144#######################################
145# vndk_snapshot_zip
146vndk_snapshot_arch := $(vndk_snapshot_out)/arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT)
Jae Shine6b7c842017-10-20 17:46:46 +0900147vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_ARCH).zip
Jae Shin4736dc12017-11-22 19:25:36 +0900148
Jae Shine6b7c842017-10-20 17:46:46 +0900149$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
150
Jae Shin4736dc12017-11-22 19:25:36 +0900151$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_snapshot_arch)/shared/vndk-core
152$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := \
Jae Shin77c07dd2017-12-22 11:24:00 +0900153 $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES)
Jae Shine6b7c842017-10-20 17:46:46 +0900154
Jae Shin4736dc12017-11-22 19:25:36 +0900155$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_snapshot_arch)/shared/vndk-sp
156$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := \
Jae Shin77c07dd2017-12-22 11:24:00 +0900157 $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES)
Jae Shin4736dc12017-11-22 19:25:36 +0900158
159$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_arch)/configs
160$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := \
Jae Shin77c07dd2017-12-22 11:24:00 +0900161 $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \
162 $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))),ETC) \
Jae Shin4736dc12017-11-22 19:25:36 +0900163 $(vndk_snapshot_configs)
164
Jae Shin410a1af2017-12-15 19:35:16 +0900165$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_OUT := $(vndk_snapshot_arch)/NOTICE_FILES
166$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_INTERMEDIATES := \
167 $(call paths-of-notice-files,$(vndk_core_libs),vndk) \
168 $(call paths-of-notice-files,$(vndk_sp_libs),vndk-sp)
169
Jae Shin4736dc12017-11-22 19:25:36 +0900170# TODO(b/69834489): Package additional arch variants
171# ifdef TARGET_2ND_ARCH
172# vndk_snapshot_arch_2ND := $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)-$(TARGET_2ND_ARCH_VARIANT)
173# $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_snapshot_arch_2ND)/shared/vndk-core
174# $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_2ND := \
Jae Shin77c07dd2017-12-22 11:24:00 +0900175# $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true)
Jae Shin4736dc12017-11-22 19:25:36 +0900176# $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_snapshot_arch_2ND)/shared/vndk-sp
177# $(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_2ND := \
Jae Shin77c07dd2017-12-22 11:24:00 +0900178# $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true)
Jae Shin4736dc12017-11-22 19:25:36 +0900179# endif
Jae Shine6b7c842017-10-20 17:46:46 +0900180
181# Args
182# $(1): destination directory
Jae Shin4736dc12017-11-22 19:25:36 +0900183# $(2): list of files to copy
Jae Shine6b7c842017-10-20 17:46:46 +0900184$(vndk_snapshot_zip): private-copy-vndk-intermediates = \
Jae Shin4736dc12017-11-22 19:25:36 +0900185 $(if $(2),$(strip \
186 @mkdir -p $(1); \
187 $(foreach file,$(2), \
188 if [ -e $(file) ]; then \
189 cp -p $(file) $(call append-path,$(1),$(subst .vendor,,$(notdir $(file)))); \
190 fi; \
191 ) \
192 ))
193
194vndk_snapshot_dependencies := \
195 $(vndk_snapshot_libs) \
196 $(vndk_prebuilt_txts) \
197 $(vndk_snapshot_configs)
Jae Shine6b7c842017-10-20 17:46:46 +0900198
199$(vndk_snapshot_zip): $(vndk_snapshot_dependencies) $(SOONG_ZIP)
200 @echo 'Generating VNDK snapshot: $@'
201 @rm -f $@
202 @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
203 @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
204 $(call private-copy-vndk-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +0900205 $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_INTERMEDIATES))
Jae Shine6b7c842017-10-20 17:46:46 +0900206 $(call private-copy-vndk-intermediates, \
Jae Shinc13c0ea2017-12-04 13:16:21 +0900207 $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_INTERMEDIATES))
Jae Shine6b7c842017-10-20 17:46:46 +0900208 $(call private-copy-vndk-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +0900209 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
Jae Shin410a1af2017-12-15 19:35:16 +0900210 $(call private-copy-vndk-intermediates, \
211 $(PRIVATE_NOTICE_FILES_OUT),$(PRIVATE_NOTICE_FILES_INTERMEDIATES))
Jae Shin4736dc12017-11-22 19:25:36 +0900212# TODO(b/69834489): Package additional arch variants
213# ifdef TARGET_2ND_ARCH
214# $(call private-copy-vndk-intermediates, \
215# $(PRIVATE_VNDK_CORE_OUT_2ND),$(PRIVATE_VNDK_CORE_INTERMEDIATES_2ND))
216# $(call private-copy-vndk-intermediates, \
217# $(PRIVATE_VNDK_SP_OUT_2ND),$(PRIVATE_VNDK_SP_INTERMEDIATES_2ND))
218# endif
Jae Shinc13c0ea2017-12-04 13:16:21 +0900219 $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT)
Jae Shine6b7c842017-10-20 17:46:46 +0900220
221.PHONY: vndk
222vndk: $(vndk_snapshot_zip)
223
224$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
225
Jae Shin4736dc12017-11-22 19:25:36 +0900226# clear global vars
227clang-ubsan-vndk-core :=
228paths-of-intermediates :=
Jae Shin410a1af2017-12-15 19:35:16 +0900229paths-of-notice-files :=
Jae Shin4736dc12017-11-22 19:25:36 +0900230vndk_core_libs :=
231vndk_sp_libs :=
232vndk_snapshot_libs :=
233vndk_prebuilt_txts :=
234vndk_snapshot_configs :=
235vndk_snapshot_top :=
236vndk_snapshot_out :=
237vndk_snapshot_configs_out :=
238vndk_snapshot_arch :=
239vndk_snapshot_dependencies :=
240# TODO(b/69834489): Package additional arch variants
241# ifdef TARGET_2ND_ARCH
242# vndk_snapshot_arch_2ND :=
243# endif
244
Justin Yun4dff0c62018-01-04 10:51:16 +0900245else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true'
246error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'."
247endif # BOARD_VNDK_RUNTIME_DISABLE
248
Jae Shin0b1792e2017-12-21 19:04:13 +0900249else # PLATFORM_VNDK_VERSION is NOT set
Justin Yun4dff0c62018-01-04 10:51:16 +0900250error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set."
Jae Shin0b1792e2017-12-21 19:04:13 +0900251endif # PLATFORM_VNDK_VERSION
252
Jae Shine6b7c842017-10-20 17:46:46 +0900253else # BOARD_VNDK_VERSION is NOT set to 'current'
Justin Yun4dff0c62018-01-04 10:51:16 +0900254error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'."
255endif # BOARD_VNDK_VERSION
256
257ifneq (,$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900258
259.PHONY: vndk
260vndk:
Justin Yun4dff0c62018-01-04 10:51:16 +0900261 $(call echo-error,$(current_makefile),$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900262 exit 1
263
Justin Yun4dff0c62018-01-04 10:51:16 +0900264endif