blob: 3c4d942eed80dc4275ed770d0f808724a67a0f40 [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 +090051
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 +090055vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_PRODUCT).zip
Jae Shin4736dc12017-11-22 19:25:36 +090056
Jae Shine6b7c842017-10-20 17:46:46 +090057$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out)
58
Dan Willemsen64931182018-06-17 21:47:18 -070059deps := $(call paths-of-intermediates,$(foreach txt,$(vndk_prebuilt_txts), \
Inseob Kim10e02dc2019-05-07 21:00:45 +090060 $(txt):$(patsubst %.txt,%.$(PLATFORM_VNDK_VERSION).txt,$(txt))))
Jae Shin893fca62017-12-28 16:00:10 +090061$(vndk_snapshot_zip): PRIVATE_CONFIGS_OUT := $(vndk_snapshot_variant)/configs
Dan Willemsen64931182018-06-17 21:47:18 -070062$(vndk_snapshot_zip): PRIVATE_CONFIGS_INTERMEDIATES := $(deps)
Inseob Kim316f77b2019-05-23 08:59:55 +090063$(vndk_snapshot_zip): $(foreach d,$(deps),$(call word-colon,1,$(d)))
Dan Willemsen64931182018-06-17 21:47:18 -070064deps :=
Jae Shin4736dc12017-11-22 19:25:36 +090065
Inseob Kim316f77b2019-05-23 08:59:55 +090066vndk_snapshot_soong_files := $(call copy-many-files, $(SOONG_VNDK_SNAPSHOT_FILES), $(vndk_snapshot_soong_dir))
Jae Shin410a1af2017-12-15 19:35:16 +090067
Inseob Kim316f77b2019-05-23 08:59:55 +090068$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_SOONG_DIR := $(vndk_snapshot_soong_dir)
69$(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_SOONG_FILES := $(sort $(vndk_snapshot_soong_files))
70$(vndk_snapshot_zip): $(vndk_snapshot_soong_files)
Jae Shine6b7c842017-10-20 17:46:46 +090071
72# Args
73# $(1): destination directory
Dan Willemsen64931182018-06-17 21:47:18 -070074# $(2): list of files (src:dest) to copy
75$(vndk_snapshot_zip): private-copy-intermediates = \
Jae Shin4736dc12017-11-22 19:25:36 +090076 $(if $(2),$(strip \
Dan Willemsen64931182018-06-17 21:47:18 -070077 @mkdir -p $(1) && \
Jae Shin4736dc12017-11-22 19:25:36 +090078 $(foreach file,$(2), \
Dan Willemsen64931182018-06-17 21:47:18 -070079 cp $(call word-colon,1,$(file)) $(call append-path,$(1),$(call word-colon,2,$(file))) && \
Jae Shin4736dc12017-11-22 19:25:36 +090080 ) \
Dan Willemsen64931182018-06-17 21:47:18 -070081 true \
Jae Shin4736dc12017-11-22 19:25:36 +090082 ))
83
Dan Willemsen64931182018-06-17 21:47:18 -070084$(vndk_snapshot_zip): $(SOONG_ZIP)
Jae Shine6b7c842017-10-20 17:46:46 +090085 @echo 'Generating VNDK snapshot: $@'
86 @rm -f $@
87 @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT)
88 @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT)
Dan Willemsen64931182018-06-17 21:47:18 -070089 $(call private-copy-intermediates, \
Jae Shin4736dc12017-11-22 19:25:36 +090090 $(PRIVATE_CONFIGS_OUT),$(PRIVATE_CONFIGS_INTERMEDIATES))
Inseob Kim316f77b2019-05-23 08:59:55 +090091 $(hide) $(SOONG_ZIP) -o $@ -C $(PRIVATE_VNDK_SNAPSHOT_OUT) -D $(PRIVATE_VNDK_SNAPSHOT_OUT) \
92 -C $(PRIVATE_VNDK_SNAPSHOT_SOONG_DIR) $(foreach f,$(PRIVATE_VNDK_SNAPSHOT_SOONG_FILES),-f $(f))
Jae Shine6b7c842017-10-20 17:46:46 +090093
94.PHONY: vndk
95vndk: $(vndk_snapshot_zip)
96
97$(call dist-for-goals, vndk, $(vndk_snapshot_zip))
98
Jae Shin4736dc12017-11-22 19:25:36 +090099# clear global vars
100clang-ubsan-vndk-core :=
101paths-of-intermediates :=
Jae Shin4736dc12017-11-22 19:25:36 +0900102vndk_prebuilt_txts :=
Jae Shin4736dc12017-11-22 19:25:36 +0900103vndk_snapshot_top :=
104vndk_snapshot_out :=
Inseob Kim316f77b2019-05-23 08:59:55 +0900105vndk_snapshot_soong_dir :=
106vndk_snapshot_soong_files :=
Jae Shin893fca62017-12-28 16:00:10 +0900107vndk_snapshot_variant :=
Jae Shin4736dc12017-11-22 19:25:36 +0900108
Justin Yun4dff0c62018-01-04 10:51:16 +0900109else # BOARD_VNDK_RUNTIME_DISABLE is set to 'true'
110error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_RUNTIME_DISABLE must not be set to 'true'."
111endif # BOARD_VNDK_RUNTIME_DISABLE
112
Jae Shin0b1792e2017-12-21 19:04:13 +0900113else # PLATFORM_VNDK_VERSION is NOT set
Justin Yun4dff0c62018-01-04 10:51:16 +0900114error_msg := "CANNOT generate VNDK snapshot. PLATFORM_VNDK_VERSION must be set."
Jae Shin0b1792e2017-12-21 19:04:13 +0900115endif # PLATFORM_VNDK_VERSION
116
Jae Shine6b7c842017-10-20 17:46:46 +0900117else # BOARD_VNDK_VERSION is NOT set to 'current'
Justin Yun4dff0c62018-01-04 10:51:16 +0900118error_msg := "CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'."
119endif # BOARD_VNDK_VERSION
120
121ifneq (,$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900122
123.PHONY: vndk
124vndk:
Justin Yun4dff0c62018-01-04 10:51:16 +0900125 $(call echo-error,$(current_makefile),$(error_msg))
Jae Shine6b7c842017-10-20 17:46:46 +0900126 exit 1
127
Justin Yun4dff0c62018-01-04 10:51:16 +0900128endif