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