blob: 942063897f5090d2843d9d40f689d771aa7946e0 [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
Dan Willemsen64931182018-06-17 21:47:18 -070026# Returns list of src:dest paths of the intermediate objs
Jae Shin4736dc12017-11-22 19:25:36 +090027#
Jae Shine6b7c842017-10-20 17:46:46 +090028# Args:
Jae Shin77c07dd2017-12-22 11:24:00 +090029# $(1): list of module and filename pairs (e.g., ld.config.txt:ld.config.27.txt ...)
Dan Willemsen64931182018-06-17 21:47:18 -070030# $(2): if not empty, evaluates for TARGET_2ND_ARCH
Jae Shine6b7c842017-10-20 17:46:46 +090031define paths-of-intermediates
Jae Shin4736dc12017-11-22 19:25:36 +090032$(strip \
Jae Shin77c07dd2017-12-22 11:24:00 +090033 $(foreach pair,$(1), \
Dan Willemsen64931182018-06-17 21:47:18 -070034 $(eval module := $(call word-colon,1,$(pair))$(if $(2),$(TARGET_2ND_ARCH_MODULE_SUFFIX))) \
35 $(eval built := $(ALL_MODULES.$(module).BUILT_INSTALLED)) \
36 $(eval filename := $(call word-colon,2,$(pair))) \
37 $(if $(wordlist 2,100,$(built)), \
38 $(error Unable to handle multiple built files ($(module)): $(built))) \
39 $(if $(built),$(call word-colon,1,$(built)):$(filename)) \
Jae Shin4736dc12017-11-22 19:25:36 +090040 ) \
41)
Jae Shine6b7c842017-10-20 17:46:46 +090042endef
43
Dan Willemsen64931182018-06-17 21:47:18 -070044# Returns src:dest list of notice files
Jae Shin410a1af2017-12-15 19:35:16 +090045#
46# Args:
47# $(1): list of lib names (e.g., libfoo.vendor)
Jae Shin410a1af2017-12-15 19:35:16 +090048define paths-of-notice-files
49$(strip \
Jae Shin410a1af2017-12-15 19:35:16 +090050 $(foreach lib,$(1), \
Dan Willemsen64931182018-06-17 21:47:18 -070051 $(eval notice := $(sort \
52 $(ALL_MODULES.$(lib).NOTICES) \
53 $(if $(TARGET_2ND_ARCH),
54 $(ALL_MODULES.$(lib)$(TARGET_2ND_ARCH_MODULE_SUFFIX).NOTICES)))) \
55 $(if $(wordlist 2,100,$(notice)), \
56 $(error Unable to handle multiple notice files ($(lib)): $(notice))) \
57 $(if $(notice),$(notice):$(subst .vendor,,$(lib)).so.txt)))
Jae Shin410a1af2017-12-15 19:35:16 +090058endef
59
Jae Shin4b6ba7e2018-07-26 12:04:31 +090060vndk_core_libs := $(addsuffix .vendor,$(VNDK_CORE_LIBRARIES))
Jae Shin4736dc12017-11-22 19:25:36 +090061vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
62vndk_private_libs := $(addsuffix .vendor,$(VNDK_PRIVATE_LIBRARIES))
Jae Shine6b7c842017-10-20 17:46:46 +090063
Jae Shin4736dc12017-11-22 19:25:36 +090064vndk_snapshot_libs := \
65 $(vndk_core_libs) \
66 $(vndk_sp_libs)
Jae Shine6b7c842017-10-20 17:46:46 +090067
Jae Shin4736dc12017-11-22 19:25:36 +090068vndk_prebuilt_txts := \
69 ld.config.txt \
70 vndksp.libraries.txt \
71 llndk.libraries.txt
72
73vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
74vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot
75vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs
76
77#######################################
78# vndkcore.libraries.txt
79vndkcore.libraries.txt := $(vndk_snapshot_configs_out)/vndkcore.libraries.txt
Dan Willemsen64931182018-06-17 21:47:18 -070080$(vndkcore.libraries.txt): PRIVATE_LIBS := $(vndk_core_libs)
81$(vndkcore.libraries.txt):
Jae Shin4736dc12017-11-22 19:25:36 +090082 @echo 'Generating: $@'
83 @rm -f $@
84 @mkdir -p $(dir $@)
85 $(hide) echo -n > $@
Dan Willemsen64931182018-06-17 21:47:18 -070086 $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
Jae Shin4736dc12017-11-22 19:25:36 +090087
88
89#######################################
90# vndkprivate.libraries.txt
91vndkprivate.libraries.txt := $(vndk_snapshot_configs_out)/vndkprivate.libraries.txt
Dan Willemsen64931182018-06-17 21:47:18 -070092$(vndkprivate.libraries.txt): PRIVATE_LIBS := $(vndk_private_libs)
93$(vndkprivate.libraries.txt):
Jae Shin4736dc12017-11-22 19:25:36 +090094 @echo 'Generating: $@'
95 @rm -f $@
96 @mkdir -p $(dir $@)
97 $(hide) echo -n > $@
Dan Willemsen64931182018-06-17 21:47:18 -070098 $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so >> $@;)
Jae Shin4736dc12017-11-22 19:25:36 +090099
100
Jae Shin410a1af2017-12-15 19:35:16 +0900101#######################################
102# module_paths.txt
103module_paths.txt := $(vndk_snapshot_configs_out)/module_paths.txt
Dan Willemsen64931182018-06-17 21:47:18 -0700104$(module_paths.txt): PRIVATE_LIBS := $(vndk_snapshot_libs)
105$(module_paths.txt):
Jae Shin410a1af2017-12-15 19:35:16 +0900106 @echo 'Generating: $@'
107 @rm -f $@
108 @mkdir -p $(dir $@)
109 $(hide) echo -n > $@
Dan Willemsen64931182018-06-17 21:47:18 -0700110 $(hide) $(foreach lib,$(PRIVATE_LIBS),echo $(patsubst %.vendor,%,$(lib)).so $(ALL_MODULES.$(lib).PATH) >> $@;)
Jae Shin410a1af2017-12-15 19:35:16 +0900111
112
Jae Shin4736dc12017-11-22 19:25:36 +0900113vndk_snapshot_configs := \
114 $(vndkcore.libraries.txt) \
Jae Shin410a1af2017-12-15 19:35:16 +0900115 $(vndkprivate.libraries.txt) \
116 $(module_paths.txt)
Jae Shin4736dc12017-11-22 19:25:36 +0900117
118#######################################
119# vndk_snapshot_zip
Jae Shin893fca62017-12-28 16:00:10 +0900120vndk_snapshot_variant := $(vndk_snapshot_out)/$(TARGET_ARCH)
Jae Shinf20605c2018-05-30 21:01:29 +0900121binder :=
Jae Shinf1e9d4f2018-07-24 16:12:42 +0900122ifneq ($(TARGET_IS_64_BIT), true)
123 ifneq ($(TARGET_USES_64_BIT_BINDER), true)
124 binder := binder32
125 endif
Jae Shinf20605c2018-05-30 21:01:29 +0900126endif
127vndk_lib_dir := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT)))
128vndk_lib_dir_2nd := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_2ND_ARCH)-$(TARGET_2ND_ARCH_VARIANT)))
129vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip
Jae Shin4736dc12017-11-22 19:25:36 +0900130
Jae Shine6b7c842017-10-20 17:46:46 +0900131$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
132
Dan Willemsen64931182018-06-17 21:47:18 -0700133deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(subst .vendor,,$(lib)).so))
Jae Shin893fca62017-12-28 16:00:10 +0900134$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_lib_dir)/shared/vndk-core
Dan Willemsen64931182018-06-17 21:47:18 -0700135$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := $(deps)
136$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
137deps :=
Jae Shine6b7c842017-10-20 17:46:46 +0900138
Dan Willemsen64931182018-06-17 21:47:18 -0700139deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(subst .vendor,,$(lib)).so))
Jae Shin893fca62017-12-28 16:00:10 +0900140$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_lib_dir)/shared/vndk-sp
Dan Willemsen64931182018-06-17 21:47:18 -0700141$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := $(deps)
142$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
143deps :=
Jae Shin4736dc12017-11-22 19:25:36 +0900144
Dan Willemsen64931182018-06-17 21:47:18 -0700145deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \
146 $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt)))) \
147 $(foreach config,$(vndk_snapshot_configs),$(config):$(notdir $(config)))
Jae Shin893fca62017-12-28 16:00:10 +0900148$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs
Dan Willemsen64931182018-06-17 21:47:18 -0700149$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps)
150$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
151deps :=
Jae Shin4736dc12017-11-22 19:25:36 +0900152
Dan Willemsen64931182018-06-17 21:47:18 -0700153notices := $(call paths-of-notice-files,$(vndk_core_libs) $(vndk_sp_libs))
Jae Shin893fca62017-12-28 16:00:10 +0900154$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_OUT := $(vndk_snapshot_variant)/NOTICE_FILES
Dan Willemsen64931182018-06-17 21:47:18 -0700155$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_INTERMEDIATES := $(notices)
156$(vndk_snapshot_zip): $(foreach n,$(notices),$(call word-colon,1,$(n)))
157notices :=
Jae Shin410a1af2017-12-15 19:35:16 +0900158
Jae Shin893fca62017-12-28 16:00:10 +0900159ifdef TARGET_2ND_ARCH
Dan Willemsen64931182018-06-17 21:47:18 -0700160deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(subst .vendor,,$(lib)).so),true)
Jae Shin893fca62017-12-28 16:00:10 +0900161$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-core
Dan Willemsen64931182018-06-17 21:47:18 -0700162$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_2ND := $(deps)
163$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
164deps :=
Jae Shin893fca62017-12-28 16:00:10 +0900165
Dan Willemsen64931182018-06-17 21:47:18 -0700166deps := $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(subst .vendor,,$(lib)).so),true)
Jae Shin893fca62017-12-28 16:00:10 +0900167$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-sp
Dan Willemsen64931182018-06-17 21:47:18 -0700168$(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_2ND := $(deps)
169$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
170deps :=
Jae Shin893fca62017-12-28 16:00:10 +0900171endif
Jae Shine6b7c842017-10-20 17:46:46 +0900172
173# Args
174# $(1): destination directory
Dan Willemsen64931182018-06-17 21:47:18 -0700175# $(2): list of files (src:dest) to copy
176$(vndk_snapshot_zip): private-copy-intermediates = \
Jae Shin4736dc12017-11-22 19:25:36 +0900177 $(if $(2),$(strip \
Dan Willemsen64931182018-06-17 21:47:18 -0700178 @mkdir -p $(1) && \
Jae Shin4736dc12017-11-22 19:25:36 +0900179 $(foreach file,$(2), \
Dan Willemsen64931182018-06-17 21:47:18 -0700180 cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \
Jae Shin4736dc12017-11-22 19:25:36 +0900181 ) \
Dan Willemsen64931182018-06-17 21:47:18 -0700182 true \
Jae Shin4736dc12017-11-22 19:25:36 +0900183 ))
184
Jae Shine6b7c842017-10-20 17:46:46 +0900185
Dan Willemsen64931182018-06-17 21:47:18 -0700186$(vndk_snapshot_zip): $(SOONG_ZIP)
Jae Shine6b7c842017-10-20 17:46:46 +0900187 @echo 'Generating VNDK snapshot: $@'
188 @rm -f $@
189 @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
190 @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
Dan Willemsen64931182018-06-17 21:47:18 -0700191 $(call private-copy-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +0900192 $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_INTERMEDIATES))
Dan Willemsen64931182018-06-17 21:47:18 -0700193 $(call private-copy-intermediates, \
Jae Shinc13c0ea2017-12-04 13:16:21 +0900194 $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_INTERMEDIATES))
Dan Willemsen64931182018-06-17 21:47:18 -0700195 $(call private-copy-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +0900196 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
Dan Willemsen64931182018-06-17 21:47:18 -0700197 $(call private-copy-intermediates, \
Jae Shin410a1af2017-12-15 19:35:16 +0900198 $(PRIVATE_NOTICE_FILES_OUT),$(PRIVATE_NOTICE_FILES_INTERMEDIATES))
Jae Shin893fca62017-12-28 16:00:10 +0900199ifdef TARGET_2ND_ARCH
Dan Willemsen64931182018-06-17 21:47:18 -0700200 $(call private-copy-intermediates, \
Jae Shin893fca62017-12-28 16:00:10 +0900201 $(PRIVATE_VNDK_CORE_OUT_2ND),$(PRIVATE_VNDK_CORE_INTERMEDIATES_2ND))
Dan Willemsen64931182018-06-17 21:47:18 -0700202 $(call private-copy-intermediates, \
Jae Shin893fca62017-12-28 16:00:10 +0900203 $(PRIVATE_VNDK_SP_OUT_2ND),$(PRIVATE_VNDK_SP_INTERMEDIATES_2ND))
204endif
Jae Shinc13c0ea2017-12-04 13:16:21 +0900205 $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT)
Jae Shine6b7c842017-10-20 17:46:46 +0900206
207.PHONY: vndk
208vndk: $(vndk_snapshot_zip)
209
210$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
211
Jae Shin4736dc12017-11-22 19:25:36 +0900212# clear global vars
213clang-ubsan-vndk-core :=
214paths-of-intermediates :=
Jae Shin410a1af2017-12-15 19:35:16 +0900215paths-of-notice-files :=
Jae Shin4736dc12017-11-22 19:25:36 +0900216vndk_core_libs :=
217vndk_sp_libs :=
218vndk_snapshot_libs :=
219vndk_prebuilt_txts :=
220vndk_snapshot_configs :=
221vndk_snapshot_top :=
222vndk_snapshot_out :=
223vndk_snapshot_configs_out :=
Jae Shin893fca62017-12-28 16:00:10 +0900224vndk_snapshot_variant :=
Jae Shinf20605c2018-05-30 21:01:29 +0900225binder :=
Jae Shin893fca62017-12-28 16:00:10 +0900226vndk_lib_dir :=
227vndk_lib_dir_2nd :=
Jae Shin4736dc12017-11-22 19:25:36 +0900228
Justin Yun4dff0c62018-01-04 10:51:16 +0900229else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true'
230error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'."
231endif # BOARD_VNDK_RUNTIME_DISABLE
232
Jae Shin0b1792e2017-12-21 19:04:13 +0900233else # PLATFORM_VNDK_VERSION is NOT set
Justin Yun4dff0c62018-01-04 10:51:16 +0900234error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set."
Jae Shin0b1792e2017-12-21 19:04:13 +0900235endif # PLATFORM_VNDK_VERSION
236
Jae Shine6b7c842017-10-20 17:46:46 +0900237else # BOARD_VNDK_VERSION is NOT set to 'current'
Justin Yun4dff0c62018-01-04 10:51:16 +0900238error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'."
239endif # BOARD_VNDK_VERSION
240
241ifneq (,$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900242
243.PHONY: vndk
244vndk:
Justin Yun4dff0c62018-01-04 10:51:16 +0900245 $(call echo-error,$(current_makefile),$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900246 exit 1
247
Justin Yun4dff0c62018-01-04 10:51:16 +0900248endif