1LOCAL_PATH:= $(call my-dir)
2
3#####################################################################
4# Create the list of vndk libraries from the source code.
5INTERNAL_VNDK_LIB_LIST := $(call intermediates-dir-for,PACKAGING,vndk)/libs.txt
6$(INTERNAL_VNDK_LIB_LIST):
7	@echo "Generate: $@"
8	@mkdir -p $(dir $@)
9	$(hide) echo -n > $@
10	$(hide) $(foreach lib, $(filter-out libclang_rt.%,$(LLNDK_LIBRARIES)), \
11	  echo LLNDK: $(lib).so >> $@;)
12	$(hide) $(foreach lib, $(VNDK_SAMEPROCESS_LIBRARIES), \
13	  echo VNDK-SP: $(lib).so >> $@;)
14	$(hide) $(foreach lib, $(filter-out libclang_rt.%,$(VNDK_CORE_LIBRARIES)), \
15	  echo VNDK-core: $(lib).so >> $@;)
16	$(hide) $(foreach lib, $(VNDK_PRIVATE_LIBRARIES), \
17	  echo VNDK-private: $(lib).so >> $@;)
18
19#####################################################################
20# This is the up-to-date list of vndk libs.
21# TODO(b/62012285): the lib list should be stored somewhere under
22# /prebuilts/vndk
23ifeq (REL,$(PLATFORM_VERSION_CODENAME))
24LATEST_VNDK_LIB_LIST := $(LOCAL_PATH)/$(PLATFORM_VNDK_VERSION).txt
25ifeq ($(wildcard $(LATEST_VNDK_LIB_LIST)),)
26$(error $(LATEST_VNDK_LIB_LIST) file not found. Please copy "$(LOCAL_PATH)/current.txt" to "$(LATEST_VNDK_LIB_LIST)" and commit a CL for release branch)
27endif
28else
29LATEST_VNDK_LIB_LIST := $(LOCAL_PATH)/current.txt
30endif
31
32#####################################################################
33# Check the generate list against the latest list stored in the
34# source tree
35.PHONY: check-vndk-list
36
37# Check if vndk list is changed
38droidcore: check-vndk-list
39
40check-vndk-list-timestamp := $(call intermediates-dir-for,PACKAGING,vndk)/check-list-timestamp
41
42ifeq ($(TARGET_IS_64_BIT)|$(TARGET_2ND_ARCH),true|)
43# TODO(b/110429754) remove this condition when we support 64-bit-only device
44check-vndk-list: ;
45else ifeq ($(TARGET_BUILD_PDK),true)
46# b/118634643: don't check VNDK lib list when building PDK. Some libs (libandroid_net.so
47# and some render-script related ones) can't be built in PDK due to missing frameworks/base.
48check-vndk-list: ;
49else
50check-vndk-list: $(check-vndk-list-timestamp)
51endif
52
53_vndk_check_failure_message := " error: VNDK library list has been changed.\n"
54ifeq (REL,$(PLATFORM_VERSION_CODENAME))
55_vndk_check_failure_message += "       Changing the VNDK library list is not allowed in API locked branches."
56else
57_vndk_check_failure_message += "       Run update-vndk-list.sh to update $(LATEST_VNDK_LIB_LIST)"
58endif
59
60$(check-vndk-list-timestamp): $(INTERNAL_VNDK_LIB_LIST) $(LATEST_VNDK_LIB_LIST) $(HOST_OUT_EXECUTABLES)/update-vndk-list.sh
61	$(hide) ( diff --old-line-format="Removed %L" \
62	  --new-line-format="Added %L" \
63	  --unchanged-line-format="" \
64	  $(LATEST_VNDK_LIB_LIST) $(INTERNAL_VNDK_LIB_LIST) \
65	  || ( echo -e $(_vndk_check_failure_message); exit 1 ))
66	$(hide) mkdir -p $(dir $@)
67	$(hide) touch $@
68
69#####################################################################
70# Script to update the latest VNDK lib list
71include $(CLEAR_VARS)
72LOCAL_MODULE := update-vndk-list.sh
73LOCAL_MODULE_CLASS := EXECUTABLES
74LOCAL_MODULE_STEM := $(LOCAL_MODULE)
75LOCAL_IS_HOST_MODULE := true
76include $(BUILD_SYSTEM)/base_rules.mk
77$(LOCAL_BUILT_MODULE): PRIVATE_INTERNAL_VNDK_LIB_LIST := $(INTERNAL_VNDK_LIB_LIST)
78$(LOCAL_BUILT_MODULE): PRIVATE_LATEST_VNDK_LIB_LIST := $(LATEST_VNDK_LIB_LIST)
79$(LOCAL_BUILT_MODULE):
80	@echo "Generate: $@"
81	@mkdir -p $(dir $@)
82	@rm -f $@
83	$(hide) echo "#!/bin/bash" > $@
84ifeq (REL,$(PLATFORM_VERSION_CODENAME))
85	$(hide) echo "echo Updating VNDK library list is NOT allowed in API locked branches." >> $@; \
86	        echo "exit 1" >> $@
87else
88	$(hide) echo "if [ -z \"\$${ANDROID_BUILD_TOP}\" ]; then" >> $@; \
89	        echo "  echo Run lunch or choosecombo first" >> $@; \
90	        echo "  exit 1" >> $@; \
91	        echo "fi" >> $@; \
92	        echo "cd \$${ANDROID_BUILD_TOP}" >> $@; \
93	        echo "cp $(PRIVATE_INTERNAL_VNDK_LIB_LIST) $(PRIVATE_LATEST_VNDK_LIB_LIST)" >> $@; \
94	        echo "echo $(PRIVATE_LATEST_VNDK_LIB_LIST) updated." >> $@
95endif
96	@chmod a+x $@
97
98ifneq ($(BOARD_VNDK_VERSION),)
99
100include $(CLEAR_VARS)
101LOCAL_MODULE := vndk_package
102LOCAL_REQUIRED_MODULES := \
103    $(LLNDK_LIBRARIES) \
104    llndk.libraries.txt \
105    vndksp.libraries.txt
106ifneq ($(TARGET_SKIP_CURRENT_VNDK),true)
107LOCAL_REQUIRED_MODULES += \
108    $(addsuffix .vendor,$(VNDK_CORE_LIBRARIES)) \
109    $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES))
110endif
111include $(BUILD_PHONY_PACKAGE)
112
113include $(CLEAR_VARS)
114LOCAL_MODULE := vndk_snapshot_package
115_binder32 :=
116ifneq ($(TARGET_USES_64_BIT_BINDER),true)
117ifneq ($(TARGET_IS_64_BIT),true)
118_binder32 := _binder32
119endif
120endif
121LOCAL_REQUIRED_MODULES := \
122    $(foreach vndk_ver,$(PRODUCT_EXTRA_VNDK_VERSIONS),vndk_v$(vndk_ver)_$(TARGET_ARCH)$(_binder32))
123_binder32 :=
124include $(BUILD_PHONY_PACKAGE)
125
126endif # BOARD_VNDK_VERSION is set
127