blob: b487f5347ce87aeab01f3429fb883f3352e6d249 [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
Inseob Kim316f77b2019-05-23 08:59:55 +090050vndk_snapshot_soong_dir := $(call intermediates-dir-for,PACKAGING,vndk-snapshot-soong)
Jae Shin4736dc12017-11-22 19:25:36 +090051vndk_snapshot_configs_out := $(vndk_snapshot_top)/configs
52
53#######################################
Jae Shin4736dc12017-11-22 19:25:36 +090054# vndk_snapshot_zip
Jae Shin893fca62017-12-28 16:00:10 +090055vndk_snapshot_variant := $(vndk_snapshot_out)/$(TARGET_ARCH)
Jae Shinf20605c2018-05-30 21:01:29 +090056vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip
Jae Shin4736dc12017-11-22 19:25:36 +090057
Jae Shine6b7c842017-10-20 17:46:46 +090058$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
59
Dan Willemsen64931182018-06-17 21:47:18 -070060deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \
Inseob Kim10e02dc2019-05-07 21:00:45 +090061 $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))))
Jae Shin893fca62017-12-28 16:00:10 +090062$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs
Dan Willemsen64931182018-06-17 21:47:18 -070063$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps)
Inseob Kim316f77b2019-05-23 08:59:55 +090064$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
Dan Willemsen64931182018-06-17 21:47:18 -070065deps :=
Jae Shin4736dc12017-11-22 19:25:36 +090066
Inseob Kim316f77b2019-05-23 08:59:55 +090067vndk_snapshot_soong_files := $(call copy-many-files, $(SOONG_VNDK_SNAPSHOT_FILES), $(vndk_snapshot_soong_dir))
Jae Shin410a1af2017-12-15 19:35:16 +090068
Inseob Kim316f77b2019-05-23 08:59:55 +090069$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_SOONG_DIR := $(vndk_snapshot_soong_dir)
70$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_SOONG_FILES := $(sort $(vndk_snapshot_soong_files))
71$(vndk_snapshot_zip): $(vndk_snapshot_soong_files)
Jae Shine6b7c842017-10-20 17:46:46 +090072
73# Args
74# $(1): destination directory
Dan Willemsen64931182018-06-17 21:47:18 -070075# $(2): list of files (src:dest) to copy
76$(vndk_snapshot_zip): private-copy-intermediates = \
Jae Shin4736dc12017-11-22 19:25:36 +090077 $(if $(2),$(strip \
Dan Willemsen64931182018-06-17 21:47:18 -070078 @mkdir -p $(1) && \
Jae Shin4736dc12017-11-22 19:25:36 +090079 $(foreach file,$(2), \
Dan Willemsen64931182018-06-17 21:47:18 -070080 cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \
Jae Shin4736dc12017-11-22 19:25:36 +090081 ) \
Dan Willemsen64931182018-06-17 21:47:18 -070082 true \
Jae Shin4736dc12017-11-22 19:25:36 +090083 ))
84
Dan Willemsen64931182018-06-17 21:47:18 -070085$(vndk_snapshot_zip): $(SOONG_ZIP)
Jae Shine6b7c842017-10-20 17:46:46 +090086 @echo 'Generating VNDK snapshot: $@'
87 @rm -f $@
88 @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
89 @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
Dan Willemsen64931182018-06-17 21:47:18 -070090 $(call private-copy-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +090091 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
Inseob Kim316f77b2019-05-23 08:59:55 +090092 $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT) \
93 -C $(PRIVATE_VNDK_SNAPSHOT_SOONG_DIR) $(foreach f,$(PRIVATE_VNDK_SNAPSHOT_SOONG_FILES),-f $(f))
Jae Shine6b7c842017-10-20 17:46:46 +090094
95.PHONY: vndk
96vndk: $(vndk_snapshot_zip)
97
98$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
99
Jae Shin4736dc12017-11-22 19:25:36 +0900100# clear global vars
101clang-ubsan-vndk-core :=
102paths-of-intermediates :=
Jae Shin4736dc12017-11-22 19:25:36 +0900103vndk_prebuilt_txts :=
Jae Shin4736dc12017-11-22 19:25:36 +0900104vndk_snapshot_top :=
105vndk_snapshot_out :=
Inseob Kim316f77b2019-05-23 08:59:55 +0900106vndk_snapshot_soong_dir :=
107vndk_snapshot_soong_files :=
Jae Shin4736dc12017-11-22 19:25:36 +0900108vndk_snapshot_configs_out :=
Jae Shin893fca62017-12-28 16:00:10 +0900109vndk_snapshot_variant :=
Jae Shin4736dc12017-11-22 19:25:36 +0900110
Justin Yun4dff0c62018-01-04 10:51:16 +0900111else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true'
112error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'."
113endif # BOARD_VNDK_RUNTIME_DISABLE
114
Jae Shin0b1792e2017-12-21 19:04:13 +0900115else # PLATFORM_VNDK_VERSION is NOT set
Justin Yun4dff0c62018-01-04 10:51:16 +0900116error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set."
Jae Shin0b1792e2017-12-21 19:04:13 +0900117endif # PLATFORM_VNDK_VERSION
118
Jae Shine6b7c842017-10-20 17:46:46 +0900119else # BOARD_VNDK_VERSION is NOT set to 'current'
Justin Yun4dff0c62018-01-04 10:51:16 +0900120error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'."
121endif # BOARD_VNDK_VERSION
122
123ifneq (,$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900124
125.PHONY: vndk
126vndk:
Justin Yun4dff0c62018-01-04 10:51:16 +0900127 $(call echo-error,$(current_makefile),$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900128 exit 1
129
Justin Yun4dff0c62018-01-04 10:51:16 +0900130endif