1LOCAL_PATH:= $(call my-dir) 2 3####################################### 4# init-debug.rc 5include $(CLEAR_VARS) 6 7LOCAL_MODULE := init-debug.rc 8LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 9LOCAL_LICENSE_CONDITIONS := notice 10LOCAL_SRC_FILES := $(LOCAL_MODULE) 11LOCAL_MODULE_CLASS := ETC 12LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/init 13 14include $(BUILD_PREBUILT) 15 16####################################### 17# asan.options 18ifneq ($(filter address,$(SANITIZE_TARGET)),) 19 20include $(CLEAR_VARS) 21 22LOCAL_MODULE := asan.options 23LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 24LOCAL_LICENSE_CONDITIONS := notice 25LOCAL_MODULE_CLASS := ETC 26LOCAL_SRC_FILES := $(LOCAL_MODULE) 27LOCAL_MODULE_PATH := $(TARGET_OUT) 28 29include $(BUILD_PREBUILT) 30 31# ASAN extration. 32ASAN_EXTRACT_FILES := 33ifeq ($(SANITIZE_TARGET_SYSTEM),true) 34include $(CLEAR_VARS) 35LOCAL_MODULE:= asan_extract 36LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0 37LOCAL_LICENSE_CONDITIONS:= notice 38LOCAL_MODULE_TAGS := optional 39LOCAL_MODULE_CLASS := EXECUTABLES 40LOCAL_SRC_FILES := asan_extract.sh 41LOCAL_INIT_RC := asan_extract.rc 42# We need bzip2 on device for extraction. 43LOCAL_REQUIRED_MODULES := bzip2 44include $(BUILD_PREBUILT) 45ASAN_EXTRACT_FILES := asan_extract 46endif 47 48endif 49 50####################################### 51# init.environ.rc 52 53include $(CLEAR_VARS) 54LOCAL_MODULE_CLASS := ETC 55LOCAL_MODULE := init.environ.rc 56LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 57LOCAL_LICENSE_CONDITIONS := notice 58LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) 59 60EXPORT_GLOBAL_ASAN_OPTIONS := 61ifneq ($(filter address,$(SANITIZE_TARGET)),) 62 EXPORT_GLOBAL_ASAN_OPTIONS := export ASAN_OPTIONS include=/system/asan.options 63 LOCAL_REQUIRED_MODULES := asan.options $(ASAN_OPTIONS_FILES) $(ASAN_EXTRACT_FILES) 64endif 65 66EXPORT_GLOBAL_HWASAN_OPTIONS := 67ifneq ($(filter hwaddress,$(SANITIZE_TARGET)),) 68 ifneq ($(HWADDRESS_SANITIZER_GLOBAL_OPTIONS),) 69 EXPORT_GLOBAL_HWASAN_OPTIONS := export HWASAN_OPTIONS $(HWADDRESS_SANITIZER_GLOBAL_OPTIONS) 70 endif 71endif 72 73EXPORT_GLOBAL_GCOV_OPTIONS := 74ifeq ($(NATIVE_COVERAGE),true) 75 EXPORT_GLOBAL_GCOV_OPTIONS := export GCOV_PREFIX /data/misc/trace 76endif 77 78EXPORT_GLOBAL_CLANG_COVERAGE_OPTIONS := 79ifeq ($(CLANG_COVERAGE),true) 80 EXPORT_GLOBAL_CLANG_COVERAGE_OPTIONS := export LLVM_PROFILE_FILE /data/misc/trace/clang-%20m.profraw 81endif 82 83# Put it here instead of in init.rc module definition, 84# because init.rc is conditionally included. 85# 86# create some directories (some are mount points) and symlinks 87LOCAL_POST_INSTALL_CMD := mkdir -p $(addprefix $(TARGET_ROOT_OUT)/, \ 88 dev proc sys system data data_mirror odm oem acct config storage mnt apex debug_ramdisk \ 89 linkerconfig second_stage_resources postinstall $(BOARD_ROOT_EXTRA_FOLDERS)); \ 90 ln -sf /system/bin $(TARGET_ROOT_OUT)/bin; \ 91 ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \ 92 ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \ 93 ln -sfn /sys/kernel/debug $(TARGET_ROOT_OUT)/d; \ 94 ln -sf /storage/self/primary $(TARGET_ROOT_OUT)/sdcard 95ifdef BOARD_USES_VENDORIMAGE 96 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/vendor 97else 98 LOCAL_POST_INSTALL_CMD += ; ln -sf /system/vendor $(TARGET_ROOT_OUT)/vendor 99endif 100ifdef BOARD_USES_PRODUCTIMAGE 101 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/product 102else 103 LOCAL_POST_INSTALL_CMD += ; ln -sf /system/product $(TARGET_ROOT_OUT)/product 104endif 105ifdef BOARD_USES_SYSTEM_EXTIMAGE 106 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/system_ext 107else 108 LOCAL_POST_INSTALL_CMD += ; ln -sf /system/system_ext $(TARGET_ROOT_OUT)/system_ext 109endif 110ifdef BOARD_USES_METADATA_PARTITION 111 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/metadata 112endif 113 114# For /odm partition. 115LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/odm 116# For Treble Generic System Image (GSI), system-as-root GSI needs to work on 117# both devices with and without /odm partition. Those symlinks are for devices 118# without /odm partition. For devices with /odm partition, mount odm.img under 119# /odm will hide those symlinks. 120LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/app $(TARGET_ROOT_OUT)/odm/app 121LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/bin $(TARGET_ROOT_OUT)/odm/bin 122LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/etc $(TARGET_ROOT_OUT)/odm/etc 123LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/firmware $(TARGET_ROOT_OUT)/odm/firmware 124LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/framework $(TARGET_ROOT_OUT)/odm/framework 125LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/lib $(TARGET_ROOT_OUT)/odm/lib 126LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/lib64 $(TARGET_ROOT_OUT)/odm/lib64 127LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/overlay $(TARGET_ROOT_OUT)/odm/overlay 128LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/priv-app $(TARGET_ROOT_OUT)/odm/priv-app 129LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/usr $(TARGET_ROOT_OUT)/odm/usr 130 131 132# For /vendor_dlkm partition. 133LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/vendor_dlkm 134# For Treble Generic System Image (GSI), system-as-root GSI needs to work on 135# both devices with and without /vendor_dlkm partition. Those symlinks are for 136# devices without /vendor_dlkm partition. For devices with /vendor_dlkm 137# partition, mount vendor_dlkm.img under /vendor_dlkm will hide those symlinks. 138# Note that /vendor_dlkm/lib is omitted because vendor DLKMs should be accessed 139# via /vendor/lib/modules directly. 140LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/vendor_dlkm/etc $(TARGET_ROOT_OUT)/vendor_dlkm/etc 141 142# For /odm_dlkm partition. 143LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/odm_dlkm 144# For Treble Generic System Image (GSI), system-as-root GSI needs to work on 145# both devices with and without /odm_dlkm partition. Those symlinks are for 146# devices without /odm_dlkm partition. For devices with /odm_dlkm 147# partition, mount odm_dlkm.img under /odm_dlkm will hide those symlinks. 148# Note that /odm_dlkm/lib is omitted because odm DLKMs should be accessed 149# via /odm/lib/modules directly. 150LOCAL_POST_INSTALL_CMD += ; ln -sf /odm/odm_dlkm/etc $(TARGET_ROOT_OUT)/odm_dlkm/etc 151 152ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE 153 LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/cache 154else 155 LOCAL_POST_INSTALL_CMD += ; ln -sf /data/cache $(TARGET_ROOT_OUT)/cache 156endif 157ifdef BOARD_ROOT_EXTRA_SYMLINKS 158# BOARD_ROOT_EXTRA_SYMLINKS is a list of <target>:<link_name>. 159 LOCAL_POST_INSTALL_CMD += $(foreach s, $(BOARD_ROOT_EXTRA_SYMLINKS),\ 160 $(eval p := $(subst :,$(space),$(s)))\ 161 ; mkdir -p $(dir $(TARGET_ROOT_OUT)/$(word 2,$(p))) \ 162 ; ln -sf $(word 1,$(p)) $(TARGET_ROOT_OUT)/$(word 2,$(p))) 163endif 164 165# The init symlink must be a post install command of a file that is to TARGET_ROOT_OUT. 166# Since init.environ.rc is required for init and satisfies that requirement, we hijack it to create the symlink. 167LOCAL_POST_INSTALL_CMD += ; ln -sf /system/bin/init $(TARGET_ROOT_OUT)/init 168 169include $(BUILD_SYSTEM)/base_rules.mk 170 171$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/init.environ.rc.in 172 @echo "Generate: $< -> $@" 173 @mkdir -p $(dir $@) 174 $(hide) cp $< $@ 175 $(hide) sed -i -e 's?%EXPORT_GLOBAL_ASAN_OPTIONS%?$(EXPORT_GLOBAL_ASAN_OPTIONS)?g' $@ 176 $(hide) sed -i -e 's?%EXPORT_GLOBAL_GCOV_OPTIONS%?$(EXPORT_GLOBAL_GCOV_OPTIONS)?g' $@ 177 $(hide) sed -i -e 's?%EXPORT_GLOBAL_CLANG_COVERAGE_OPTIONS%?$(EXPORT_GLOBAL_CLANG_COVERAGE_OPTIONS)?g' $@ 178 $(hide) sed -i -e 's?%EXPORT_GLOBAL_HWASAN_OPTIONS%?$(EXPORT_GLOBAL_HWASAN_OPTIONS)?g' $@ 179 180# Append PLATFORM_VNDK_VERSION to base name. 181define append_vndk_version 182$(strip \ 183 $(basename $(1)).$(PLATFORM_VNDK_VERSION)$(suffix $(1)) \ 184) 185endef 186 187####################################### 188# sanitizer.libraries.txt 189include $(CLEAR_VARS) 190LOCAL_MODULE := sanitizer.libraries.txt 191LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 192LOCAL_LICENSE_CONDITIONS := notice 193LOCAL_MODULE_CLASS := ETC 194LOCAL_MODULE_PATH := $(TARGET_OUT_ETC) 195LOCAL_MODULE_STEM := $(LOCAL_MODULE) 196include $(BUILD_SYSTEM)/base_rules.mk 197$(LOCAL_BUILT_MODULE): PRIVATE_SANITIZER_RUNTIME_LIBRARIES := $(addsuffix .so,\ 198 $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) \ 199 $(HWADDRESS_SANITIZER_RUNTIME_LIBRARY) \ 200 $(UBSAN_RUNTIME_LIBRARY) \ 201 $(TSAN_RUNTIME_LIBRARY) \ 202 $(2ND_ADDRESS_SANITIZER_RUNTIME_LIBRARY) \ 203 $(2ND_HWADDRESS_SANITIZER_RUNTIME_LIBRARY) \ 204 $(2ND_UBSAN_RUNTIME_LIBRARY) \ 205 $(2ND_TSAN_RUNTIME_LIBRARY)) 206$(LOCAL_BUILT_MODULE): 207 @echo "Generate: $@" 208 @mkdir -p $(dir $@) 209 $(hide) echo -n > $@ 210 $(hide) $(foreach lib,$(PRIVATE_SANITIZER_RUNTIME_LIBRARIES), \ 211 echo $(lib) >> $@;) 212 213####################################### 214# adb_debug.prop in debug ramdisk 215include $(CLEAR_VARS) 216LOCAL_MODULE := adb_debug.prop 217LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 218LOCAL_LICENSE_CONDITIONS := notice 219LOCAL_SRC_FILES := $(LOCAL_MODULE) 220LOCAL_MODULE_CLASS := ETC 221LOCAL_MODULE_PATH := $(TARGET_DEBUG_RAMDISK_OUT) 222include $(BUILD_PREBUILT) 223 224include $(call all-makefiles-under,$(LOCAL_PATH)) 225