blob: 90ebd924ea4373236eca507438f93216a4f5edc4 [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 ...)
Jae Shine6b7c842017-10-20 17:46:46 +090030define paths-of-intermediates
Jae Shin4736dc12017-11-22 19:25:36 +090031$(strip \
Jae Shin77c07dd2017-12-22 11:24:00 +090032 $(foreach pair,$(1), \
Inseob Kim10e02dc2019-05-07 21:00:45 +090033 $(eval module := $(call word-colon,1,$(pair))) \
Dan Willemsen64931182018-06-17 21:47:18 -070034 $(eval built := $(ALL_MODULES.$(module).BUILT_INSTALLED)) \
35 $(eval filename := $(call word-colon,2,$(pair))) \
36 $(if $(wordlist 2,100,$(built)), \
37 $(error Unable to handle multiple built files ($(module)): $(built))) \
38 $(if $(built),$(call word-colon,1,$(built)):$(filename)) \
Jae Shin4736dc12017-11-22 19:25:36 +090039 ) \
40)
Jae Shine6b7c842017-10-20 17:46:46 +090041endef
42
Jae Shin4736dc12017-11-22 19:25:36 +090043vndk_prebuilt_txts := \
44 ld.config.txt \
45 vndksp.libraries.txt \
46 llndk.libraries.txt
47
48vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot)
49vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot
50vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs
51
52#######################################
Jae Shin4736dc12017-11-22 19:25:36 +090053# vndk_snapshot_zip
Jae Shin893fca62017-12-28 16:00:10 +090054vndk_snapshot_variant := $(vndk_snapshot_out)/$(TARGET_ARCH)
Jae Shinf20605c2018-05-30 21:01:29 +090055binder :=
Jae Shinf1e9d4f2018-07-24 16:12:42 +090056ifneq ($(TARGET_IS_64_BIT), true)
57 ifneq ($(TARGET_USES_64_BIT_BINDER), true)
58 binder := binder32
59 endif
Jae Shinf20605c2018-05-30 21:01:29 +090060endif
61vndk_lib_dir := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT)))
62vndk_lib_dir_2nd := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_2ND_ARCH)-$(TARGET_2ND_ARCH_VARIANT)))
63vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip
Jae Shin4736dc12017-11-22 19:25:36 +090064
Jae Shine6b7c842017-10-20 17:46:46 +090065$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
66
Inseob Kim10e02dc2019-05-07 21:00:45 +090067prebuilts := $(SOONG_VNDK_SNAPSHOT_CORE_LIBS)
Jae Shin893fca62017-12-28 16:00:10 +090068$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_lib_dir)/shared/vndk-core
Inseob Kim10e02dc2019-05-07 21:00:45 +090069$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_SOONG_PREBUILTS := $(prebuilts)
70$(vndk_snapshot_zip): $(prebuilts)
71prebuilts :=
Jae Shine6b7c842017-10-20 17:46:46 +090072
Inseob Kim10e02dc2019-05-07 21:00:45 +090073prebuilts := $(SOONG_VNDK_SNAPSHOT_SP_LIBS)
Jae Shin893fca62017-12-28 16:00:10 +090074$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_lib_dir)/shared/vndk-sp
Inseob Kim10e02dc2019-05-07 21:00:45 +090075$(vndk_snapshot_zip): PRIVATE_VNDK_SP_SOONG_PREBUILTS := $(prebuilts)
76$(vndk_snapshot_zip): $(prebuilts)
77prebuilts :=
Jae Shin4736dc12017-11-22 19:25:36 +090078
Dan Willemsen64931182018-06-17 21:47:18 -070079deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \
Inseob Kim10e02dc2019-05-07 21:00:45 +090080 $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))))
81prebuilts := $(SOONG_VNDK_SNAPSHOT_CONFIGS)
Jae Shin893fca62017-12-28 16:00:10 +090082$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs
Dan Willemsen64931182018-06-17 21:47:18 -070083$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps)
Inseob Kim10e02dc2019-05-07 21:00:45 +090084$(vndk_snapshot_zip): PRIVATE_CONFIGS_SOONG_PREBUILTS := $(prebuilts)
85$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) $(prebuilts)
Dan Willemsen64931182018-06-17 21:47:18 -070086deps :=
Inseob Kim10e02dc2019-05-07 21:00:45 +090087prebuilts :=
Jae Shin4736dc12017-11-22 19:25:36 +090088
Inseob Kim10e02dc2019-05-07 21:00:45 +090089prebuilts := $(SOONG_VNDK_SNAPSHOT_NOTICES)
Jae Shin893fca62017-12-28 16:00:10 +090090$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_OUT := $(vndk_snapshot_variant)/NOTICE_FILES
Inseob Kim10e02dc2019-05-07 21:00:45 +090091$(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_SOONG_PREBUILTS := $(prebuilts)
92$(vndk_snapshot_zip): $(prebuilts)
93prebuilts :=
Jae Shin410a1af2017-12-15 19:35:16 +090094
Jae Shin893fca62017-12-28 16:00:10 +090095ifdef TARGET_2ND_ARCH
Inseob Kim10e02dc2019-05-07 21:00:45 +090096prebuilts := $(SOONG_VNDK_SNAPSHOT_CORE_LIBS_2ND)
Jae Shin893fca62017-12-28 16:00:10 +090097$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-core
Inseob Kim10e02dc2019-05-07 21:00:45 +090098$(vndk_snapshot_zip): PRIVATE_VNDK_CORE_SOONG_PREBUILTS_2ND := $(prebuilts)
99$(vndk_snapshot_zip): $(prebuilts)
100prebuilts :=
Jae Shin893fca62017-12-28 16:00:10 +0900101
Inseob Kim10e02dc2019-05-07 21:00:45 +0900102prebuilts := $(SOONG_VNDK_SNAPSHOT_SP_LIBS_2ND)
Jae Shin893fca62017-12-28 16:00:10 +0900103$(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-sp
Inseob Kim10e02dc2019-05-07 21:00:45 +0900104$(vndk_snapshot_zip): PRIVATE_VNDK_SP_SOONG_PREBUILTS_2ND := $(prebuilts)
105$(vndk_snapshot_zip): $(prebuilts)
106prebuilts :=
Jae Shin893fca62017-12-28 16:00:10 +0900107endif
Jae Shine6b7c842017-10-20 17:46:46 +0900108
109# Args
110# $(1): destination directory
Dan Willemsen64931182018-06-17 21:47:18 -0700111# $(2): list of files (src:dest) to copy
112$(vndk_snapshot_zip): private-copy-intermediates = \
Jae Shin4736dc12017-11-22 19:25:36 +0900113 $(if $(2),$(strip \
Dan Willemsen64931182018-06-17 21:47:18 -0700114 @mkdir -p $(1) && \
Jae Shin4736dc12017-11-22 19:25:36 +0900115 $(foreach file,$(2), \
Dan Willemsen64931182018-06-17 21:47:18 -0700116 cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \
Jae Shin4736dc12017-11-22 19:25:36 +0900117 ) \
Dan Willemsen64931182018-06-17 21:47:18 -0700118 true \
Jae Shin4736dc12017-11-22 19:25:36 +0900119 ))
120
Inseob Kim10e02dc2019-05-07 21:00:45 +0900121# Args
122# $(1): destination directory
123# $(2): list of prebuilts to copy
124$(vndk_snapshot_zip): private-copy-prebuilts = \
125 $(if $(2),$(strip \
126 @mkdir -p $(1) && \
127 $(foreach file, $(2), cp $(file) $(1) && ) \
128 true \
129 ))
Jae Shine6b7c842017-10-20 17:46:46 +0900130
Dan Willemsen64931182018-06-17 21:47:18 -0700131$(vndk_snapshot_zip): $(SOONG_ZIP)
Jae Shine6b7c842017-10-20 17:46:46 +0900132 @echo 'Generating VNDK snapshot: $@'
133 @rm -f $@
134 @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
135 @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
Dan Willemsen64931182018-06-17 21:47:18 -0700136 $(call private-copy-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +0900137 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
Inseob Kim10e02dc2019-05-07 21:00:45 +0900138 $(call private-copy-prebuilts, \
139 $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_SOONG_PREBUILTS))
140 $(call private-copy-prebuilts, \
141 $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_SOONG_PREBUILTS))
142 $(call private-copy-prebuilts, \
143 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_SOONG_PREBUILTS))
144 $(call private-copy-prebuilts, \
145 $(PRIVATE_NOTICE_FILES_OUT),$(PRIVATE_NOTICE_FILES_SOONG_PREBUILTS))
Jae Shin893fca62017-12-28 16:00:10 +0900146ifdef TARGET_2ND_ARCH
Inseob Kim10e02dc2019-05-07 21:00:45 +0900147 $(call private-copy-prebuilts, \
148 $(PRIVATE_VNDK_CORE_OUT_2ND),$(PRIVATE_VNDK_CORE_SOONG_PREBUILTS_2ND))
149 $(call private-copy-prebuilts, \
150 $(PRIVATE_VNDK_SP_OUT_2ND),$(PRIVATE_VNDK_SP_SOONG_PREBUILTS_2ND))
Jae Shin893fca62017-12-28 16:00:10 +0900151endif
Jae Shinc13c0ea2017-12-04 13:16:21 +0900152 $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT)
Jae Shine6b7c842017-10-20 17:46:46 +0900153
154.PHONY: vndk
155vndk: $(vndk_snapshot_zip)
156
157$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
158
Jae Shin4736dc12017-11-22 19:25:36 +0900159# clear global vars
160clang-ubsan-vndk-core :=
161paths-of-intermediates :=
Jae Shin4736dc12017-11-22 19:25:36 +0900162vndk_prebuilt_txts :=
Jae Shin4736dc12017-11-22 19:25:36 +0900163vndk_snapshot_top :=
164vndk_snapshot_out :=
165vndk_snapshot_configs_out :=
Jae Shin893fca62017-12-28 16:00:10 +0900166vndk_snapshot_variant :=
Jae Shinf20605c2018-05-30 21:01:29 +0900167binder :=
Jae Shin893fca62017-12-28 16:00:10 +0900168vndk_lib_dir :=
169vndk_lib_dir_2nd :=
Jae Shin4736dc12017-11-22 19:25:36 +0900170
Justin Yun4dff0c62018-01-04 10:51:16 +0900171else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true'
172error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'."
173endif # BOARD_VNDK_RUNTIME_DISABLE
174
Jae Shin0b1792e2017-12-21 19:04:13 +0900175else # PLATFORM_VNDK_VERSION is NOT set
Justin Yun4dff0c62018-01-04 10:51:16 +0900176error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set."
Jae Shin0b1792e2017-12-21 19:04:13 +0900177endif # PLATFORM_VNDK_VERSION
178
Jae Shine6b7c842017-10-20 17:46:46 +0900179else # BOARD_VNDK_VERSION is NOT set to 'current'
Justin Yun4dff0c62018-01-04 10:51:16 +0900180error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'."
181endif # BOARD_VNDK_VERSION
182
183ifneq (,$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900184
185.PHONY: vndk
186vndk:
Justin Yun4dff0c62018-01-04 10:51:16 +0900187 $(call echo-error,$(current_makefile),$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900188 exit 1
189
Justin Yun4dff0c62018-01-04 10:51:16 +0900190endif