blob: 860e61f2035a15347cf5aa7a9ab1c3934528a134 [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
nkk7171c6c502017-01-05 23:55:05 +0200110 LOCAL_SRC_FILES = vold_decrypt.cpp
111 LOCAL_SHARED_LIBRARIES := libcutils
112 include $(BUILD_STATIC_LIBRARY)
113
nijel82c821a82018-12-29 04:56:41 -0500114 ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 28; echo $$?),0)
115 include $(CLEAR_VARS)
116 LOCAL_MODULE := vdc_pie
117 LOCAL_SRC_FILES := vdc_pie.cpp
118 LOCAL_MODULE_TAGS := eng
119 LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
120 LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
121 LOCAL_CLANG := true
122 LOCAL_TIDY := true
123 LOCAL_TIDY_FLAGS := -warnings-as-errors=clang-analyzer-security*,cert-*
124 LOCAL_TIDY_CHECKS := -*,cert-*,clang,-analyzer-security*
125 LOCAL_STATIC_LIBRARIES := libvold_binder
126 LOCAL_SHARED_LIBRARIES := libbase libcutils libutils libbinder
127 LOCAL_CFLAGS := -Wall
128 ifeq ($(TWRP_INCLUDE_LOGCAT), true)
129 LOCAL_CFLAGS += -DTWRP_INCLUDE_LOGCAT
130 endif
131 ifneq ($(TARGET_ARCH), arm64)
132 ifneq ($(TARGET_ARCH), x86_64)
133 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker
134 else
135 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
136 endif
137 else
138 LOCAL_LDFLAGS += -Wl,-dynamic-linker,/sbin/linker64
139 endif
140
141 include $(BUILD_EXECUTABLE)
142 endif
143
nkk7171c6c502017-01-05 23:55:05 +0200144 endif
nkk7171c6c502017-01-05 23:55:05 +0200145endif