Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 1 | # 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 | |
| 15 | current_makefile := $(lastword $(MAKEFILE_LIST)) |
| 16 | |
| 17 | # BOARD_VNDK_VERSION must be set to 'current' in order to generate a VNDK snapshot. |
| 18 | ifeq ($(BOARD_VNDK_VERSION),current) |
| 19 | |
Jae Shin | 0b1792e | 2017-12-21 19:04:13 +0900 | [diff] [blame] | 20 | # PLATFORM_VNDK_VERSION must be set. |
| 21 | ifneq (,$(PLATFORM_VNDK_VERSION)) |
| 22 | |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 23 | # BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'. |
| 24 | ifneq ($(BOARD_VNDK_RUNTIME_DISABLE),true) |
| 25 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 26 | # 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 |
| 32 | define clang-ubsan-vndk-core |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 33 | $(strip \ |
| 34 | $(eval prefix := $(if $(1),2ND_,)) \ |
| 35 | $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY))) \ |
| 36 | ) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 37 | endef |
| 38 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 39 | # Returns list of file paths of the intermediate objs |
| 40 | # |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 41 | # Args: |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 42 | # $(1): list of module and filename pairs (e.g., ld.config.txt:ld.config.27.txt ...) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 43 | # $(2): target class (e.g., SHARED_LIBRARIES, STATIC_LIBRARIES, ETC) |
| 44 | # $(3): if not empty, evaluates for TARGET_2ND_ARCH |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 45 | define paths-of-intermediates |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 46 | $(strip \ |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 47 | $(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 Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 53 | ) \ |
| 54 | ) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 55 | endef |
| 56 | |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 57 | # 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' |
| 62 | define 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 | ) |
| 71 | endef |
| 72 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 73 | # If in the future libclang_rt.ubsan* is removed from the VNDK-core list, |
| 74 | # need to update the related logic in this file. |
| 75 | ifeq (,$(filter libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES))) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 76 | $(warning libclang_rt.ubsan* is no longer a VNDK-core library. Please update this file.) |
| 77 | vndk_core_libs := $(addsuffix .vendor,$(VNDK_CORE_LIBRARIES)) |
| 78 | else |
| 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 Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 88 | endif |
| 89 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 90 | vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES)) |
| 91 | vndk_private_libs := $(addsuffix .vendor,$(VNDK_PRIVATE_LIBRARIES)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 92 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 93 | vndk_snapshot_libs := \ |
| 94 | $(vndk_core_libs) \ |
| 95 | $(vndk_sp_libs) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 96 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 97 | vndk_prebuilt_txts := \ |
| 98 | ld.config.txt \ |
| 99 | vndksp.libraries.txt \ |
| 100 | llndk.libraries.txt |
| 101 | |
| 102 | vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot) |
| 103 | vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot |
| 104 | vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs |
| 105 | |
| 106 | ####################################### |
| 107 | # vndkcore.libraries.txt |
| 108 | vndkcore.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 |
| 119 | vndkprivate.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 Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 128 | ####################################### |
| 129 | # module_paths.txt |
| 130 | module_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 Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 139 | vndk_snapshot_configs := \ |
| 140 | $(vndkcore.libraries.txt) \ |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 141 | $(vndkprivate.libraries.txt) \ |
| 142 | $(module_paths.txt) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 143 | |
| 144 | ####################################### |
| 145 | # vndk_snapshot_zip |
| 146 | vndk_snapshot_arch := $(vndk_snapshot_out)/arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 147 | vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_ARCH).zip |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 148 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 149 | $(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out) |
| 150 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 151 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_snapshot_arch)/shared/vndk-core |
| 152 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES := \ |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 153 | $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 154 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 155 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_snapshot_arch)/shared/vndk-sp |
| 156 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES := \ |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 157 | $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 158 | |
| 159 | $(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_arch)/configs |
| 160 | $(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := \ |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 161 | $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \ |
| 162 | $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))),ETC) \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 163 | $(vndk_snapshot_configs) |
| 164 | |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 165 | $(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 Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 170 | # 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 Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 175 | # $(call paths-of-intermediates,$(foreach lib,$(vndk_core_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 176 | # $(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 Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 178 | # $(call paths-of-intermediates,$(foreach lib,$(vndk_sp_libs),$(lib):$(lib).so),SHARED_LIBRARIES,true) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 179 | # endif |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 180 | |
| 181 | # Args |
| 182 | # $(1): destination directory |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 183 | # $(2): list of files to copy |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 184 | $(vndk_snapshot_zip): private-copy-vndk-intermediates = \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 185 | $(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 | |
| 194 | vndk_snapshot_dependencies := \ |
| 195 | $(vndk_snapshot_libs) \ |
| 196 | $(vndk_prebuilt_txts) \ |
| 197 | $(vndk_snapshot_configs) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 198 | |
| 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 Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 205 | $(PRIVATE_VNDK_CORE_OUT),$(PRIVATE_VNDK_CORE_INTERMEDIATES)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 206 | $(call private-copy-vndk-intermediates, \ |
Jae Shin | c13c0ea | 2017-12-04 13:16:21 +0900 | [diff] [blame] | 207 | $(PRIVATE_VNDK_SP_OUT),$(PRIVATE_VNDK_SP_INTERMEDIATES)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 208 | $(call private-copy-vndk-intermediates, \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 209 | $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES)) |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 210 | $(call private-copy-vndk-intermediates, \ |
| 211 | $(PRIVATE_NOTICE_FILES_OUT),$(PRIVATE_NOTICE_FILES_INTERMEDIATES)) |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 212 | # 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 Shin | c13c0ea | 2017-12-04 13:16:21 +0900 | [diff] [blame] | 219 | $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 220 | |
| 221 | .PHONY: vndk |
| 222 | vndk: $(vndk_snapshot_zip) |
| 223 | |
| 224 | $(call dist-for-goals, vndk, $(vndk_snapshot_zip)) |
| 225 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 226 | # clear global vars |
| 227 | clang-ubsan-vndk-core := |
| 228 | paths-of-intermediates := |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 229 | paths-of-notice-files := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 230 | vndk_core_libs := |
| 231 | vndk_sp_libs := |
| 232 | vndk_snapshot_libs := |
| 233 | vndk_prebuilt_txts := |
| 234 | vndk_snapshot_configs := |
| 235 | vndk_snapshot_top := |
| 236 | vndk_snapshot_out := |
| 237 | vndk_snapshot_configs_out := |
| 238 | vndk_snapshot_arch := |
| 239 | vndk_snapshot_dependencies := |
| 240 | # TODO(b/69834489): Package additional arch variants |
| 241 | # ifdef TARGET_2ND_ARCH |
| 242 | # vndk_snapshot_arch_2ND := |
| 243 | # endif |
| 244 | |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 245 | else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true' |
| 246 | error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'." |
| 247 | endif # BOARD_VNDK_RUNTIME_DISABLE |
| 248 | |
Jae Shin | 0b1792e | 2017-12-21 19:04:13 +0900 | [diff] [blame] | 249 | else # PLATFORM_VNDK_VERSION is NOT set |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 250 | error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set." |
Jae Shin | 0b1792e | 2017-12-21 19:04:13 +0900 | [diff] [blame] | 251 | endif # PLATFORM_VNDK_VERSION |
| 252 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 253 | else # BOARD_VNDK_VERSION is NOT set to 'current' |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 254 | error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'." |
| 255 | endif # BOARD_VNDK_VERSION |
| 256 | |
| 257 | ifneq (,$(error_msg)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 258 | |
| 259 | .PHONY: vndk |
| 260 | vndk: |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 261 | $(call echo-error,$(current_makefile),$(error_msg)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 262 | exit 1 |
| 263 | |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame^] | 264 | endif |