• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1LOCAL_PATH:= $(call my-dir)
2
3#######################################
4# init.rc
5include $(CLEAR_VARS)
6
7LOCAL_MODULE := init.rc
8LOCAL_SRC_FILES := $(LOCAL_MODULE)
9LOCAL_MODULE_CLASS := ETC
10LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
11
12include $(BUILD_PREBUILT)
13
14#######################################
15# init-debug.rc
16include $(CLEAR_VARS)
17
18LOCAL_MODULE := init-debug.rc
19LOCAL_SRC_FILES := $(LOCAL_MODULE)
20LOCAL_MODULE_CLASS := ETC
21LOCAL_MODULE_TAGS := debug
22LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/init
23
24include $(BUILD_PREBUILT)
25
26#######################################
27# asan.options
28ifneq ($(filter address,$(SANITIZE_TARGET)),)
29
30include $(CLEAR_VARS)
31
32LOCAL_MODULE := asan.options
33LOCAL_MODULE_CLASS := ETC
34LOCAL_SRC_FILES := $(LOCAL_MODULE)
35LOCAL_MODULE_PATH := $(TARGET_OUT)
36
37include $(BUILD_PREBUILT)
38
39# ASAN extration.
40ASAN_EXTRACT_FILES :=
41ifeq ($(SANITIZE_TARGET_SYSTEM),true)
42include $(CLEAR_VARS)
43LOCAL_MODULE:= asan_extract
44LOCAL_MODULE_TAGS := optional
45LOCAL_MODULE_CLASS := EXECUTABLES
46LOCAL_SRC_FILES := asan_extract.sh
47LOCAL_INIT_RC := asan_extract.rc
48# We need bzip2 on device for extraction.
49LOCAL_REQUIRED_MODULES := bzip2
50include $(BUILD_PREBUILT)
51ASAN_EXTRACT_FILES := asan_extract
52endif
53
54endif
55
56#######################################
57# init.environ.rc
58
59include $(CLEAR_VARS)
60LOCAL_MODULE_CLASS := ETC
61LOCAL_MODULE := init.environ.rc
62LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
63
64EXPORT_GLOBAL_ASAN_OPTIONS :=
65ifneq ($(filter address,$(SANITIZE_TARGET)),)
66  EXPORT_GLOBAL_ASAN_OPTIONS := export ASAN_OPTIONS include=/system/asan.options
67  LOCAL_REQUIRED_MODULES := asan.options $(ASAN_OPTIONS_FILES) $(ASAN_EXTRACT_FILES)
68endif
69
70EXPORT_GLOBAL_GCOV_OPTIONS :=
71ifeq ($(NATIVE_COVERAGE),true)
72  EXPORT_GLOBAL_GCOV_OPTIONS := export GCOV_PREFIX /data/misc/gcov
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    sbin dev proc sys system data odm oem acct config storage mnt $(BOARD_ROOT_EXTRA_FOLDERS)); \
81    ln -sf /system/bin $(TARGET_ROOT_OUT)/bin; \
82    ln -sf /system/etc $(TARGET_ROOT_OUT)/etc; \
83    ln -sf /data/user_de/0/com.android.shell/files/bugreports $(TARGET_ROOT_OUT)/bugreports; \
84    ln -sf /sys/kernel/debug $(TARGET_ROOT_OUT)/d; \
85    ln -sf /storage/self/primary $(TARGET_ROOT_OUT)/sdcard
86ifdef BOARD_USES_VENDORIMAGE
87  LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/vendor
88else
89  LOCAL_POST_INSTALL_CMD += ; ln -sf /system/vendor $(TARGET_ROOT_OUT)/vendor
90endif
91ifdef BOARD_USES_PRODUCTIMAGE
92  LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/product
93else
94  LOCAL_POST_INSTALL_CMD += ; ln -sf /system/product $(TARGET_ROOT_OUT)/product
95endif
96ifdef BOARD_USES_METADATA_PARTITION
97  LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/metadata
98endif
99
100# For /odm partition.
101LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/odm
102# For Treble Generic System Image (GSI), system-as-root GSI needs to work on
103# both devices with and without /odm partition. Those symlinks are for devices
104# without /odm partition. For devices with /odm partition, mount odm.img under
105# /odm will hide those symlinks.
106LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/app $(TARGET_ROOT_OUT)/odm/app
107LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/bin $(TARGET_ROOT_OUT)/odm/bin
108LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/etc $(TARGET_ROOT_OUT)/odm/etc
109LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/firmware $(TARGET_ROOT_OUT)/odm/firmware
110LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/framework $(TARGET_ROOT_OUT)/odm/framework
111LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/lib $(TARGET_ROOT_OUT)/odm/lib
112LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/lib64 $(TARGET_ROOT_OUT)/odm/lib64
113LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/overlay $(TARGET_ROOT_OUT)/odm/overlay
114LOCAL_POST_INSTALL_CMD += ; ln -sf /vendor/odm/priv-app $(TARGET_ROOT_OUT)/odm/priv-app
115
116ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
117  LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/cache
118else
119  LOCAL_POST_INSTALL_CMD += ; ln -sf /data/cache $(TARGET_ROOT_OUT)/cache
120endif
121ifdef BOARD_ROOT_EXTRA_SYMLINKS
122# BOARD_ROOT_EXTRA_SYMLINKS is a list of <target>:<link_name>.
123  LOCAL_POST_INSTALL_CMD += $(foreach s, $(BOARD_ROOT_EXTRA_SYMLINKS),\
124    $(eval p := $(subst :,$(space),$(s)))\
125    ; mkdir -p $(dir $(TARGET_ROOT_OUT)/$(word 2,$(p))) \
126    ; ln -sf $(word 1,$(p)) $(TARGET_ROOT_OUT)/$(word 2,$(p)))
127endif
128# The A/B updater uses a top-level /postinstall directory to mount the new
129# system before reboot.
130ifeq ($(AB_OTA_UPDATER),true)
131  LOCAL_POST_INSTALL_CMD += ; mkdir -p $(TARGET_ROOT_OUT)/postinstall
132endif
133
134include $(BUILD_SYSTEM)/base_rules.mk
135
136# Regenerate init.environ.rc if PRODUCT_BOOTCLASSPATH has changed.
137bcp_md5 := $(word 1, $(shell echo $(PRODUCT_BOOTCLASSPATH) $(PRODUCT_SYSTEM_SERVER_CLASSPATH) | $(MD5SUM)))
138bcp_dep := $(intermediates)/$(bcp_md5).bcp.dep
139$(bcp_dep) :
140	$(hide) mkdir -p $(dir $@) && rm -rf $(dir $@)*.bcp.dep && touch $@
141
142$(LOCAL_BUILT_MODULE): $(LOCAL_PATH)/init.environ.rc.in $(bcp_dep)
143	@echo "Generate: $< -> $@"
144	@mkdir -p $(dir $@)
145	$(hide) sed -e 's?%BOOTCLASSPATH%?$(PRODUCT_BOOTCLASSPATH)?g' $< >$@
146	$(hide) sed -i -e 's?%SYSTEMSERVERCLASSPATH%?$(PRODUCT_SYSTEM_SERVER_CLASSPATH)?g' $@
147	$(hide) sed -i -e 's?%EXPORT_GLOBAL_ASAN_OPTIONS%?$(EXPORT_GLOBAL_ASAN_OPTIONS)?g' $@
148	$(hide) sed -i -e 's?%EXPORT_GLOBAL_GCOV_OPTIONS%?$(EXPORT_GLOBAL_GCOV_OPTIONS)?g' $@
149
150bcp_md5 :=
151bcp_dep :=
152
153# Append PLATFORM_VNDK_VERSION to base name.
154define append_vndk_version
155$(strip \
156  $(basename $(1)).$(PLATFORM_VNDK_VERSION)$(suffix $(1)) \
157)
158endef
159
160# Update namespace configuration file with library lists and VNDK version
161#
162# $(1): Input source file (ld.config.txt)
163# $(2): Output built module
164# $(3): VNDK version suffix
165# $(4): true if libz must be included in llndk not in vndk-sp
166define update_and_install_ld_config
167# If $(4) is true, move libz to llndk from vndk-sp.
168$(if $(filter true,$(4)),\
169  $(eval llndk_libraries_list := $(LLNDK_LIBRARIES) libz) \
170  $(eval vndksp_libraries_list := $(filter-out libz,$(VNDK_SAMEPROCESS_LIBRARIES))),\
171  $(eval llndk_libraries_list := $(LLNDK_LIBRARIES)) \
172  $(eval vndksp_libraries_list := $(VNDK_SAMEPROCESS_LIBRARIES)))
173
174llndk_libraries := $(call normalize-path-list,$(addsuffix .so,\
175  $(filter-out $(VNDK_PRIVATE_LIBRARIES),$(llndk_libraries_list))))
176private_llndk_libraries := $(call normalize-path-list,$(addsuffix .so,\
177  $(filter $(VNDK_PRIVATE_LIBRARIES),$(llndk_libraries_list))))
178vndk_sameprocess_libraries := $(call normalize-path-list,$(addsuffix .so,\
179  $(filter-out $(VNDK_PRIVATE_LIBRARIES),$(vndksp_libraries_list))))
180vndk_core_libraries := $(call normalize-path-list,$(addsuffix .so,\
181  $(filter-out $(VNDK_PRIVATE_LIBRARIES),$(VNDK_CORE_LIBRARIES))))
182sanitizer_runtime_libraries := $(call normalize-path-list,$(addsuffix .so,\
183  $(ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
184  $(UBSAN_RUNTIME_LIBRARY) \
185  $(TSAN_RUNTIME_LIBRARY) \
186  $(2ND_ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
187  $(2ND_UBSAN_RUNTIME_LIBRARY) \
188  $(2ND_TSAN_RUNTIME_LIBRARY)))
189# If BOARD_VNDK_VERSION is not defined, VNDK version suffix will not be used.
190vndk_version_suffix := $(if $(strip $(3)),-$(strip $(3)))
191
192$(2): PRIVATE_LLNDK_LIBRARIES := $$(llndk_libraries)
193$(2): PRIVATE_PRIVATE_LLNDK_LIBRARIES := $$(private_llndk_libraries)
194$(2): PRIVATE_VNDK_SAMEPROCESS_LIBRARIES := $$(vndk_sameprocess_libraries)
195$(2): PRIVATE_VNDK_CORE_LIBRARIES := $$(vndk_core_libraries)
196$(2): PRIVATE_SANITIZER_RUNTIME_LIBRARIES := $$(sanitizer_runtime_libraries)
197$(2): PRIVATE_VNDK_VERSION := $$(vndk_version_suffix)
198$(2): $(1)
199	@echo "Generate: $$< -> $$@"
200	@mkdir -p $$(dir $$@)
201	$$(hide) sed -e 's?%LLNDK_LIBRARIES%?$$(PRIVATE_LLNDK_LIBRARIES)?g' $$< >$$@
202	$$(hide) sed -i -e 's?%PRIVATE_LLNDK_LIBRARIES%?$$(PRIVATE_PRIVATE_LLNDK_LIBRARIES)?g' $$@
203	$$(hide) sed -i -e 's?%VNDK_SAMEPROCESS_LIBRARIES%?$$(PRIVATE_VNDK_SAMEPROCESS_LIBRARIES)?g' $$@
204	$$(hide) sed -i -e 's?%VNDK_CORE_LIBRARIES%?$$(PRIVATE_VNDK_CORE_LIBRARIES)?g' $$@
205	$$(hide) sed -i -e 's?%SANITIZER_RUNTIME_LIBRARIES%?$$(PRIVATE_SANITIZER_RUNTIME_LIBRARIES)?g' $$@
206	$$(hide) sed -i -e 's?%VNDK_VER%?$$(PRIVATE_VNDK_VERSION)?g' $$@
207	$$(hide) sed -i -e 's?%PRODUCT%?$$(TARGET_COPY_OUT_PRODUCT)?g' $$@
208
209llndk_libraries_list :=
210vndksp_libraries_list :=
211llndk_libraries :=
212private_llndk_libraries :=
213vndk_sameprocess_libraries :=
214vndk_core_libraries :=
215sanitizer_runtime_libraries :=
216vndk_version_suffix :=
217endef # update_and_install_ld_config
218
219
220#######################################
221# ld.config.txt selection variables
222#
223_enforce_vndk_at_runtime := false
224ifdef BOARD_VNDK_VERSION
225  ifneq ($(BOARD_VNDK_RUNTIME_DISABLE),true)
226    _enforce_vndk_at_runtime := true
227  endif
228endif
229
230_enforce_vndk_lite_at_runtime := false
231ifeq ($(_enforce_vndk_at_runtime),false)
232  ifeq ($(PRODUCT_TREBLE_LINKER_NAMESPACES)|$(SANITIZE_TARGET),true|)
233    _enforce_vndk_lite_at_runtime := true
234  endif
235endif
236
237#######################################
238# ld.config.txt
239#
240# For VNDK enforced devices that have defined BOARD_VNDK_VERSION, use
241# "ld.config.txt" as a source file. This configuration includes strict VNDK
242# run-time restrictions for vendor process.
243#
244# Other treblized devices, that have not defined BOARD_VNDK_VERSION or that
245# have set BOARD_VNDK_RUNTIME_DISABLE to true, use "ld.config.vndk_lite.txt"
246# as a source file. This configuration does not have strict VNDK run-time
247# restrictions.
248#
249# If the device is not treblized, use "ld.config.legacy.txt" for legacy
250# namespace configuration.
251#
252include $(CLEAR_VARS)
253LOCAL_MODULE := ld.config.txt
254LOCAL_MODULE_CLASS := ETC
255LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
256
257ifeq ($(_enforce_vndk_at_runtime),true)
258
259# for VNDK enforced devices
260LOCAL_MODULE_STEM := $(call append_vndk_version,$(LOCAL_MODULE))
261include $(BUILD_SYSTEM)/base_rules.mk
262$(eval $(call update_and_install_ld_config,\
263  $(LOCAL_PATH)/etc/ld.config.txt,\
264  $(LOCAL_BUILT_MODULE),\
265  $(PLATFORM_VNDK_VERSION)))
266
267else ifeq ($(_enforce_vndk_lite_at_runtime),true)
268
269# for treblized but VNDK lightly enforced devices
270LOCAL_MODULE_STEM := ld.config.vndk_lite.txt
271include $(BUILD_SYSTEM)/base_rules.mk
272$(eval $(call update_and_install_ld_config,\
273  $(LOCAL_PATH)/etc/ld.config.vndk_lite.txt,\
274  $(LOCAL_BUILT_MODULE),\
275  $(PLATFORM_VNDK_VERSION),\
276  true))
277
278else
279
280# for legacy non-treblized devices
281LOCAL_MODULE_STEM := $(LOCAL_MODULE)
282LOCAL_SRC_FILES := etc/ld.config.legacy.txt
283include $(BUILD_PREBUILT)
284
285endif  # ifeq ($(_enforce_vndk_at_runtime),true)
286
287
288#######################################
289# ld.config.vndk_lite.txt
290#
291# This module is only for GSI.
292#
293ifeq ($(_enforce_vndk_lite_at_runtime),false)
294
295include $(CLEAR_VARS)
296LOCAL_MODULE := ld.config.vndk_lite.txt
297LOCAL_MODULE_CLASS := ETC
298LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
299LOCAL_MODULE_STEM := $(LOCAL_MODULE)
300include $(BUILD_SYSTEM)/base_rules.mk
301$(eval $(call update_and_install_ld_config,\
302  $(LOCAL_PATH)/etc/ld.config.vndk_lite.txt,\
303  $(LOCAL_BUILT_MODULE),\
304  $(PLATFORM_VNDK_VERSION),\
305  true))
306
307endif  # ifeq ($(_enforce_vndk_lite_at_runtime),false)
308
309_enforce_vndk_at_runtime :=
310_enforce_vndk_lite_at_runtime :=
311
312#######################################
313# llndk.libraries.txt
314include $(CLEAR_VARS)
315LOCAL_MODULE := llndk.libraries.txt
316LOCAL_MODULE_CLASS := ETC
317LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
318LOCAL_MODULE_STEM := $(call append_vndk_version,$(LOCAL_MODULE))
319include $(BUILD_SYSTEM)/base_rules.mk
320$(LOCAL_BUILT_MODULE): PRIVATE_LLNDK_LIBRARIES := $(LLNDK_LIBRARIES)
321$(LOCAL_BUILT_MODULE):
322	@echo "Generate: $@"
323	@mkdir -p $(dir $@)
324	$(hide) echo -n > $@
325	$(hide) $(foreach lib,$(PRIVATE_LLNDK_LIBRARIES), \
326		echo $(lib).so >> $@;)
327
328#######################################
329# vndksp.libraries.txt
330include $(CLEAR_VARS)
331LOCAL_MODULE := vndksp.libraries.txt
332LOCAL_MODULE_CLASS := ETC
333LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)
334LOCAL_MODULE_STEM := $(call append_vndk_version,$(LOCAL_MODULE))
335include $(BUILD_SYSTEM)/base_rules.mk
336$(LOCAL_BUILT_MODULE): PRIVATE_VNDK_SAMEPROCESS_LIBRARIES := $(VNDK_SAMEPROCESS_LIBRARIES)
337$(LOCAL_BUILT_MODULE):
338	@echo "Generate: $@"
339	@mkdir -p $(dir $@)
340	$(hide) echo -n > $@
341	$(hide) $(foreach lib,$(PRIVATE_VNDK_SAMEPROCESS_LIBRARIES), \
342		echo $(lib).so >> $@;)
343