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 | |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 26 | # Returns list of src:dest paths of the intermediate objs |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 27 | # |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 28 | # Args: |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 29 | # $(1): list of module and filename pairs (e.g., ld.config.txt:ld.config.27.txt ...) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 30 | define paths-of-intermediates |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 31 | $(strip \ |
Jae Shin | 77c07dd | 2017-12-22 11:24:00 +0900 | [diff] [blame] | 32 | $(foreach pair,$(1), \ |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 33 | $(eval module := $(call word-colon,1,$(pair))) \ |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 34 | $(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 Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 39 | ) \ |
| 40 | ) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 41 | endef |
| 42 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 43 | vndk_prebuilt_txts := \ |
| 44 | ld.config.txt \ |
| 45 | vndksp.libraries.txt \ |
| 46 | llndk.libraries.txt |
| 47 | |
| 48 | vndk_snapshot_top := $(call intermediates-dir-for,PACKAGING,vndk-snapshot) |
| 49 | vndk_snapshot_out := $(vndk_snapshot_top)/vndk-snapshot |
| 50 | vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs |
| 51 | |
| 52 | ####################################### |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 53 | # vndk_snapshot_zip |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 54 | vndk_snapshot_variant := $(vndk_snapshot_out)/$(TARGET_ARCH) |
Jae Shin | f20605c | 2018-05-30 21:01:29 +0900 | [diff] [blame] | 55 | binder := |
Jae Shin | f1e9d4f | 2018-07-24 16:12:42 +0900 | [diff] [blame] | 56 | ifneq ($(TARGET_IS_64_BIT), true) |
| 57 | ifneq ($(TARGET_USES_64_BIT_BINDER), true) |
| 58 | binder := binder32 |
| 59 | endif |
Jae Shin | f20605c | 2018-05-30 21:01:29 +0900 | [diff] [blame] | 60 | endif |
| 61 | vndk_lib_dir := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_ARCH)-$(TARGET_ARCH_VARIANT))) |
| 62 | vndk_lib_dir_2nd := $(subst $(space),/,$(strip $(vndk_snapshot_variant) $(binder) arch-$(TARGET_2ND_ARCH)-$(TARGET_2ND_ARCH_VARIANT))) |
| 63 | vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 64 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 65 | $(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out) |
| 66 | |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 67 | prebuilts := $(SOONG_VNDK_SNAPSHOT_CORE_LIBS) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 68 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT := $(vndk_lib_dir)/shared/vndk-core |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 69 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_SOONG_PREBUILTS := $(prebuilts) |
| 70 | $(vndk_snapshot_zip): $(prebuilts) |
| 71 | prebuilts := |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 72 | |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 73 | prebuilts := $(SOONG_VNDK_SNAPSHOT_SP_LIBS) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 74 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT := $(vndk_lib_dir)/shared/vndk-sp |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 75 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_SOONG_PREBUILTS := $(prebuilts) |
| 76 | $(vndk_snapshot_zip): $(prebuilts) |
| 77 | prebuilts := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 78 | |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 79 | deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \ |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 80 | $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt)))) |
| 81 | prebuilts := $(SOONG_VNDK_SNAPSHOT_CONFIGS) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 82 | $(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 83 | $(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps) |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 84 | $(vndk_snapshot_zip): PRIVATE_CONFIGS_SOONG_PREBUILTS := $(prebuilts) |
| 85 | $(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d))) $(prebuilts) |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 86 | deps := |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 87 | prebuilts := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 88 | |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 89 | prebuilts := $(SOONG_VNDK_SNAPSHOT_NOTICES) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 90 | $(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_OUT := $(vndk_snapshot_variant)/NOTICE_FILES |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 91 | $(vndk_snapshot_zip): PRIVATE_NOTICE_FILES_SOONG_PREBUILTS := $(prebuilts) |
| 92 | $(vndk_snapshot_zip): $(prebuilts) |
| 93 | prebuilts := |
Jae Shin | 410a1af | 2017-12-15 19:35:16 +0900 | [diff] [blame] | 94 | |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 95 | ifdef TARGET_2ND_ARCH |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 96 | prebuilts := $(SOONG_VNDK_SNAPSHOT_CORE_LIBS_2ND) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 97 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-core |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 98 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_SOONG_PREBUILTS_2ND := $(prebuilts) |
| 99 | $(vndk_snapshot_zip): $(prebuilts) |
| 100 | prebuilts := |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 101 | |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 102 | prebuilts := $(SOONG_VNDK_SNAPSHOT_SP_LIBS_2ND) |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 103 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_2ND := $(vndk_lib_dir_2nd)/shared/vndk-sp |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 104 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_SOONG_PREBUILTS_2ND := $(prebuilts) |
| 105 | $(vndk_snapshot_zip): $(prebuilts) |
| 106 | prebuilts := |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 107 | endif |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 108 | |
| 109 | # Args |
| 110 | # $(1): destination directory |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 111 | # $(2): list of files (src:dest) to copy |
| 112 | $(vndk_snapshot_zip): private-copy-intermediates = \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 113 | $(if $(2),$(strip \ |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 114 | @mkdir -p $(1) && \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 115 | $(foreach file,$(2), \ |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 116 | cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 117 | ) \ |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 118 | true \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 119 | )) |
| 120 | |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 121 | # 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 Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 130 | |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 131 | $(vndk_snapshot_zip): $(SOONG_ZIP) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 132 | @echo 'Generating VNDK snapshot: $@' |
| 133 | @rm -f $@ |
| 134 | @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT) |
| 135 | @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT) |
Dan Willemsen | 6493118 | 2018-06-17 21:47:18 -0700 | [diff] [blame] | 136 | $(call private-copy-intermediates, \ |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 137 | $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES)) |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 138 | $(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 Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 146 | ifdef TARGET_2ND_ARCH |
Inseob Kim | 10e02dc | 2019-05-07 21:00:45 +0900 | [diff] [blame] | 147 | $(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 Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 151 | endif |
Jae Shin | c13c0ea | 2017-12-04 13:16:21 +0900 | [diff] [blame] | 152 | $(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] | 153 | |
| 154 | .PHONY: vndk |
| 155 | vndk: $(vndk_snapshot_zip) |
| 156 | |
| 157 | $(call dist-for-goals, vndk, $(vndk_snapshot_zip)) |
| 158 | |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 159 | # clear global vars |
| 160 | clang-ubsan-vndk-core := |
| 161 | paths-of-intermediates := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 162 | vndk_prebuilt_txts := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 163 | vndk_snapshot_top := |
| 164 | vndk_snapshot_out := |
| 165 | vndk_snapshot_configs_out := |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 166 | vndk_snapshot_variant := |
Jae Shin | f20605c | 2018-05-30 21:01:29 +0900 | [diff] [blame] | 167 | binder := |
Jae Shin | 893fca6 | 2017-12-28 16:00:10 +0900 | [diff] [blame] | 168 | vndk_lib_dir := |
| 169 | vndk_lib_dir_2nd := |
Jae Shin | 4736dc1 | 2017-11-22 19:25:36 +0900 | [diff] [blame] | 170 | |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame] | 171 | else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true' |
| 172 | error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'." |
| 173 | endif # BOARD_VNDK_RUNTIME_DISABLE |
| 174 | |
Jae Shin | 0b1792e | 2017-12-21 19:04:13 +0900 | [diff] [blame] | 175 | else # PLATFORM_VNDK_VERSION is NOT set |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame] | 176 | error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set." |
Jae Shin | 0b1792e | 2017-12-21 19:04:13 +0900 | [diff] [blame] | 177 | endif # PLATFORM_VNDK_VERSION |
| 178 | |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 179 | else # BOARD_VNDK_VERSION is NOT set to 'current' |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame] | 180 | error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'." |
| 181 | endif # BOARD_VNDK_VERSION |
| 182 | |
| 183 | ifneq (,$(error_msg)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 184 | |
| 185 | .PHONY: vndk |
| 186 | vndk: |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame] | 187 | $(call echo-error,$(current_makefile),$(error_msg)) |
Jae Shin | e6b7c84 | 2017-10-20 17:46:46 +0900 | [diff] [blame] | 188 | exit 1 |
| 189 | |
Justin Yun | 4dff0c6 | 2018-01-04 10:51:16 +0900 | [diff] [blame] | 190 | endif |