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 | |
| 20 | # Returns arch-specific libclang_rt.ubsan* library name. |
| 21 | # Because VNDK_CORE_LIBRARIES includes all arch variants for libclang_rt.ubsan* |
| 22 | # libs, the arch-specific libs are selected separately. |
| 23 | # |
| 24 | # Args: |
| 25 | # $(1): if not empty, evaluates for TARGET_2ND_ARCH |
| 26 | define clang-ubsan-vndk-core |
| 27 | $(eval prefix := $(if $(1),2ND_,)) |
| 28 | $(addsuffix .vendor,$($(addprefix $(prefix),UBSAN_RUNTIME_LIBRARY))) |
| 29 | endef |
| 30 | |
| 31 | # Args: |
| 32 | # $(1): list of lib names without '.so' suffix (e.g., libX.vendor) |
| 33 | # $(2): if not empty, evaluates for TARGET_2ND_ARCH |
| 34 | define paths-of-intermediates |
| 35 | $(strip \ |
| 36 | $(foreach lib,$(1), \ |
| 37 | $(call append-path,$(call intermediates-dir-for,SHARED_LIBRARIES,$(lib),,,$(2)),$(lib).so))) |
| 38 | endef |
| 39 | |
| 40 | vndk_core_libs := $(addsuffix .vendor,$(filter-out libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES))) |
| 41 | vndk_sp_libs := $(addsuffix .vendor,$(VNDK_SAMEPROCESS_LIBRARIES)) |
| 42 | vndk_snapshot_dependencies := \ |
| 43 | $(vndk_core_libs) \ |
| 44 | $(vndk_sp_libs) |
| 45 | |
| 46 | # If in the future libclang_rt.ubsan* is removed from the VNDK-core list, |
| 47 | # need to update the related logic in this file. |
| 48 | ifeq (,$(filter libclang_rt.ubsan%,$(VNDK_CORE_LIBRARIES))) |
| 49 | $(error libclang_rt.ubsan* is no longer a VNDK-core library.) |
| 50 | endif |
| 51 | |
| 52 | # for TARGET_ARCH |
| 53 | clang_ubsan_vndk_core_$(TARGET_ARCH) := $(call clang-ubsan-vndk-core) |
| 54 | vndk_snapshot_dependencies += \ |
| 55 | $(clang_ubsan_vndk_core_$(TARGET_ARCH)) |
| 56 | |
| 57 | ifdef TARGET_2ND_ARCH |
| 58 | clang_ubsan_vndk_core_$(TARGET_2ND_ARCH) := $(call clang-ubsan-vndk-core,true) |
| 59 | vndk_snapshot_dependencies += \ |
| 60 | $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH)) |
| 61 | endif |
| 62 | |
| 63 | vndk_snapshot_zip := $(PRODUCT_OUT)/android-vndk-$(TARGET_ARCH).zip |
| 64 | vndk_snapshot_out := $(call intermediates-dir-for,PACKAGING,vndk-snapshot) |
| 65 | $(vndk_snapshot_zip): PRIVATE_VNDK_SNAPSHOT_OUT := $(vndk_snapshot_out) |
| 66 | |
| 67 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH) := \ |
| 68 | $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-core |
| 69 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH) := \ |
| 70 | $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_ARCH))) |
| 71 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH) := \ |
| 72 | $(vndk_snapshot_out)/arch-$(TARGET_ARCH)/shared/vndk-sp |
| 73 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH) := \ |
| 74 | $(call paths-of-intermediates,$(vndk_sp_libs)) |
| 75 | |
| 76 | ifdef TARGET_2ND_ARCH |
| 77 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH) := \ |
| 78 | $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-core |
| 79 | $(vndk_snapshot_zip): PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH) := \ |
| 80 | $(call paths-of-intermediates,$(vndk_core_libs) $(clang_ubsan_vndk_core_$(TARGET_2ND_ARCH)),true) |
| 81 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH) := \ |
| 82 | $(vndk_snapshot_out)/arch-$(TARGET_2ND_ARCH)/shared/vndk-sp |
| 83 | $(vndk_snapshot_zip): PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH) := \ |
| 84 | $(call paths-of-intermediates,$(vndk_sp_libs),true) |
| 85 | endif |
| 86 | |
| 87 | # Args |
| 88 | # $(1): destination directory |
| 89 | # $(2): list of libs to copy |
| 90 | $(vndk_snapshot_zip): private-copy-vndk-intermediates = \ |
| 91 | @mkdir -p $(1); \ |
| 92 | $(foreach lib,$(2),cp -p $(lib) $(call append-path,$(1),$(subst .vendor,,$(notdir $(lib))));) |
| 93 | |
| 94 | $(vndk_snapshot_zip): $(vndk_snapshot_dependencies) $(SOONG_ZIP) |
| 95 | @echo 'Generating VNDK snapshot: $@' |
| 96 | @rm -f $@ |
| 97 | @rm -rf $(PRIVATE_VNDK_SNAPSHOT_OUT) |
| 98 | @mkdir -p $(PRIVATE_VNDK_SNAPSHOT_OUT) |
| 99 | $(call private-copy-vndk-intermediates, \ |
| 100 | $(PRIVATE_VNDK_CORE_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_ARCH))) |
| 101 | $(call private-copy-vndk-intermediates, \ |
| 102 | $(PRIVATE_VNDK_SP_OUT_$(TARGET_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_ARCH))) |
| 103 | ifdef TARGET_2ND_ARCH |
| 104 | $(call private-copy-vndk-intermediates, \ |
| 105 | $(PRIVATE_VNDK_CORE_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_CORE_INTERMEDIATES_$(TARGET_2ND_ARCH))) |
| 106 | $(call private-copy-vndk-intermediates, \ |
| 107 | $(PRIVATE_VNDK_SP_OUT_$(TARGET_2ND_ARCH)),$(PRIVATE_VNDK_SP_INTERMEDIATES_$(TARGET_2ND_ARCH))) |
| 108 | endif |
| 109 | $(hide) $(SOONG_ZIP) -o $@ -P vndk-snapshot -C $(PRIVATE_VNDK_SNAPSHOT_OUT) \ |
| 110 | -D $(PRIVATE_VNDK_SNAPSHOT_OUT) |
| 111 | |
| 112 | .PHONY: vndk |
| 113 | vndk: $(vndk_snapshot_zip) |
| 114 | |
| 115 | $(call dist-for-goals, vndk, $(vndk_snapshot_zip)) |
| 116 | |
| 117 | else # BOARD_VNDK_VERSION is NOT set to 'current' |
| 118 | |
| 119 | .PHONY: vndk |
| 120 | vndk: |
| 121 | $(call echo-error,$(current_makefile),CANNOT generate VNDK snapshot. BOARD_VNDK_VERSION must be set to 'current'.) |
| 122 | exit 1 |
| 123 | |
| 124 | endif # BOARD_VNDK_VERSION |