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