nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 1 | # Copyright (C) 2017 TeamWin Recovery 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 | LOCAL_PATH := $(call my-dir) |
| 16 | |
| 17 | ifeq ($(TW_INCLUDE_CRYPTO), true) |
| 18 | ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),) |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 19 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 20 | # Parse TW_CRYPTO_USE_SYSTEM_VOLD |
| 21 | ifeq ($(TW_CRYPTO_USE_SYSTEM_VOLD),true) |
| 22 | # Just enabled, so only vold + vdc |
| 23 | services := |
| 24 | else |
| 25 | # Additional services needed by vold |
| 26 | services := $(TW_CRYPTO_USE_SYSTEM_VOLD) |
| 27 | endif |
| 28 | |
nijel8 | 2c821a8 | 2018-12-29 04:56:41 -0500 | [diff] [blame] | 29 | # Parse TW_CRYPTO_SYSTEM_VOLD_MOUNT |
| 30 | ifneq ($(TW_CRYPTO_SYSTEM_VOLD_MOUNT),) |
| 31 | # Per device additional partitions to mount |
| 32 | partitions := $(TW_CRYPTO_SYSTEM_VOLD_MOUNT) |
| 33 | endif |
| 34 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 35 | # List of .rc files for each additional service |
| 36 | rc_files := $(foreach item,$(services),init.recovery.vold_decrypt.$(item).rc) |
| 37 | |
| 38 | |
| 39 | include $(CLEAR_VARS) |
| 40 | LOCAL_MODULE := init.recovery.vold_decrypt.rc |
| 41 | LOCAL_MODULE_TAGS := eng |
| 42 | LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES |
| 43 | |
| 44 | # Cannot send to TARGET_RECOVERY_ROOT_OUT since build system wipes init*.rc |
| 45 | # during ramdisk creation and only allows init.recovery.*.rc files to be copied |
| 46 | # from TARGET_ROOT_OUT thereafter |
| 47 | LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
| 48 | |
| 49 | LOCAL_SRC_FILES := $(LOCAL_MODULE) |
| 50 | |
| 51 | # Add additional .rc files and imports into init.recovery.vold_decrypt.rc |
| 52 | # Note: any init.recovery.vold_decrypt.{service}.rc that are not default |
| 53 | # in crypto/vold_decrypt should be in the device tree |
| 54 | LOCAL_POST_INSTALL_CMD := $(hide) \ |
| 55 | $(foreach item, $(rc_files), \ |
| 56 | sed -i '1iimport \/$(item)' "$(TARGET_ROOT_OUT)/$(LOCAL_MODULE)"; \ |
| 57 | if [ -f "$(LOCAL_PATH)/$(item)" ]; then \ |
| 58 | cp -f "$(LOCAL_PATH)/$(item)" "$(TARGET_ROOT_OUT)"/; \ |
| 59 | fi; \ |
| 60 | ) |
nkk71 | 7d1222a | 2017-11-06 17:27:21 +0200 | [diff] [blame] | 61 | |
| 62 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0) |
| 63 | # Truncate service_name to max 16 characters |
| 64 | LOCAL_POST_INSTALL_CMD += \ |
| 65 | $(foreach item, $(rc_files), \ |
| 66 | if [ -f "$(TARGET_ROOT_OUT)/$(item)" ]; then \ |
| 67 | sed -i 's/\([ \t]*service[ \t]*\)\(.\{16\}\).*\([ \t].*\)/\1\2\3/' "$(TARGET_ROOT_OUT)/$(item)"; \ |
| 68 | fi; \ |
| 69 | ) |
| 70 | endif |
| 71 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 72 | include $(BUILD_PREBUILT) |
| 73 | |
| 74 | |
| 75 | include $(CLEAR_VARS) |
| 76 | LOCAL_MODULE := libvolddecrypt |
| 77 | LOCAL_MODULE_TAGS := eng optional |
| 78 | LOCAL_CFLAGS := -Wall |
| 79 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23; echo $$?),0) |
| 80 | LOCAL_C_INCLUDES += external/stlport/stlport bionic bionic/libstdc++/include |
| 81 | endif |
| 82 | |
| 83 | ifneq ($(services),) |
nkk71 | 7d1222a | 2017-11-06 17:27:21 +0200 | [diff] [blame] | 84 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 26; echo $$?),0) |
| 85 | # Truncate service_name to max 12 characters due to the 4 character prefix |
| 86 | truncated_services := $(foreach item,$(services),$(shell echo -n "$(item)" | sed 's/\(.\{12\}\).*/\1/')) |
| 87 | LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_SERVICES='"$(truncated_services)"' |
| 88 | LOCAL_CFLAGS += -D_USING_SHORT_SERVICE_NAMES |
| 89 | else |
| 90 | LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_SERVICES='"$(services)"' |
| 91 | endif |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 92 | endif |
| 93 | |
nijel8 | 2c821a8 | 2018-12-29 04:56:41 -0500 | [diff] [blame] | 94 | ifneq ($(partitions),) |
| 95 | LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_MOUNT='"$(partitions)"' |
| 96 | endif |
| 97 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 98 | ifeq ($(TW_CRYPTO_SYSTEM_VOLD_DEBUG),true) |
| 99 | # Enabling strace will expose the password in the strace logs!! |
| 100 | LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_DEBUG |
nailyk-fr | ca3fd0c | 2018-03-28 14:55:45 +0200 | [diff] [blame] | 101 | else |
| 102 | ifneq ($(TW_CRYPTO_SYSTEM_VOLD_DEBUG),) |
| 103 | # Specify strace path |
| 104 | LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_DEBUG |
| 105 | LOCAL_CFLAGS += -DVD_STRACE_BIN=\"$(TW_CRYPTO_SYSTEM_VOLD_DEBUG)\" |
| 106 | endif |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 107 | endif |
| 108 | |
Captain Throwback | 3284a66 | 2020-02-04 15:34:06 -0500 | [diff] [blame] | 109 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 26; echo $$?),0) |
| 110 | ifeq ($(TW_INCLUDE_LIBRESETPROP), true) |
| 111 | LOCAL_CFLAGS += -DTW_INCLUDE_LIBRESETPROP |
| 112 | endif |
| 113 | endif |
| 114 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 115 | LOCAL_SRC_FILES = vold_decrypt.cpp |
| 116 | LOCAL_SHARED_LIBRARIES := libcutils |
bigbiff | 5db50de | 2020-05-18 11:26:23 -0400 | [diff] [blame] | 117 | LOCAL_C_INCLUDES += system/extras/ext4_utils/include |
| 118 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 29; echo $$?),0) |
| 119 | LOCAL_C_INCLUDES += bootable/recovery/crypto/fscrypt |
| 120 | else |
| 121 | LOCAL_C_INCLUDES += bootable/recovery/crypto/ext4crypt |
| 122 | endif |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 123 | include $(BUILD_STATIC_LIBRARY) |
| 124 | |
nijel8 | 2c821a8 | 2018-12-29 04:56:41 -0500 | [diff] [blame] | 125 | ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0) |
| 126 | include $(CLEAR_VARS) |
| 127 | LOCAL_MODULE := vdc_pie |
| 128 | LOCAL_SRC_FILES := vdc_pie.cpp |
| 129 | LOCAL_MODULE_TAGS := eng |
| 130 | LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES |
| 131 | LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin |
| 132 | LOCAL_CLANG := true |
| 133 | LOCAL_TIDY := true |
| 134 | LOCAL_TIDY_FLAGS := -warnings-as-errors=clang-analyzer-security*,cert-* |
| 135 | LOCAL_TIDY_CHECKS := -*,cert-*,clang,-analyzer-security* |
| 136 | LOCAL_STATIC_LIBRARIES := libvold_binder |
| 137 | LOCAL_SHARED_LIBRARIES := libbase libcutils libutils libbinder |
| 138 | LOCAL_CFLAGS := -Wall |
| 139 | ifeq ($(TWRP_INCLUDE_LOGCAT), true) |
| 140 | LOCAL_CFLAGS += -DTWRP_INCLUDE_LOGCAT |
| 141 | endif |
| 142 | ifneq ($(TARGET_ARCH), arm64) |
| 143 | ifneq ($(TARGET_ARCH), x86_64) |
| 144 | LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker |
| 145 | else |
| 146 | LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 |
| 147 | endif |
| 148 | else |
| 149 | LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64 |
| 150 | endif |
| 151 | |
| 152 | include $(BUILD_EXECUTABLE) |
| 153 | endif |
| 154 | |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 155 | endif |
nkk71 | 71c6c50 | 2017-01-05 23:55:05 +0200 | [diff] [blame] | 156 | endif |