blob: a36abf49321cf9f2eeaa16ee0e62a1bbfd76ec07 [file] [log] [blame]
nkk7171c6c502017-01-05 23:55:05 +02001# 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
15LOCAL_PATH := $(call my-dir)
16
17ifeq ($(TW_INCLUDE_CRYPTO), true)
18 ifneq ($(TW_CRYPTO_USE_SYSTEM_VOLD),)
nkk7171c6c502017-01-05 23:55:05 +020019
nkk7171c6c502017-01-05 23:55:05 +020020 # 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
nijel82c821a82018-12-29 04:56:41 -050029 # 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
nkk7171c6c502017-01-05 23:55:05 +020035 # 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
bigbiffd58ba182020-03-23 10:02:29 -040041 LOCAL_MODULE_TAGS := optional
nkk7171c6c502017-01-05 23:55:05 +020042 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 )
nkk717d1222a2017-11-06 17:27:21 +020061
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
nkk7171c6c502017-01-05 23:55:05 +020072 include $(BUILD_PREBUILT)
73
74
75 include $(CLEAR_VARS)
76 LOCAL_MODULE := libvolddecrypt
bigbiffd58ba182020-03-23 10:02:29 -040077 LOCAL_MODULE_TAGS := optional
nkk7171c6c502017-01-05 23:55:05 +020078 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),)
nkk717d1222a2017-11-06 17:27:21 +020084 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
nkk7171c6c502017-01-05 23:55:05 +020092 endif
93
nijel82c821a82018-12-29 04:56:41 -050094 ifneq ($(partitions),)
95 LOCAL_CFLAGS += -DTW_CRYPTO_SYSTEM_VOLD_MOUNT='"$(partitions)"'
96 endif
97
nkk7171c6c502017-01-05 23:55:05 +020098 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-frca3fd0c2018-03-28 14:55:45 +0200101 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
nkk7171c6c502017-01-05 23:55:05 +0200107 endif
108
Captain Throwback89a03cc2020-02-04 15:34:06 -0500109 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
nkk7171c6c502017-01-05 23:55:05 +0200115 LOCAL_SRC_FILES = vold_decrypt.cpp
116 LOCAL_SHARED_LIBRARIES := libcutils
bigbiffd4aed462020-05-18 11:26:23 -0400117 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
nkk7171c6c502017-01-05 23:55:05 +0200123 include $(BUILD_STATIC_LIBRARY)
124
nijel82c821a82018-12-29 04:56:41 -0500125 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
bigbiffd58ba182020-03-23 10:02:29 -0400129 LOCAL_MODULE_TAGS := optional
nijel82c821a82018-12-29 04:56:41 -0500130 LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
bigbiffad58e1b2020-07-06 20:24:34 -0400131 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
nijel82c821a82018-12-29 04:56:41 -0500132 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)
bigbiffad58e1b2020-07-06 20:24:34 -0400144 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker
nijel82c821a82018-12-29 04:56:41 -0500145 else
bigbiffad58e1b2020-07-06 20:24:34 -0400146 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
nijel82c821a82018-12-29 04:56:41 -0500147 endif
148 else
bigbiffad58e1b2020-07-06 20:24:34 -0400149 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/system/bin/linker64
nijel82c821a82018-12-29 04:56:41 -0500150 endif
151
152 include $(BUILD_EXECUTABLE)
153 endif
154
nkk7171c6c502017-01-05 23:55:05 +0200155 endif
nkk7171c6c502017-01-05 23:55:05 +0200156endif