blob: 6265c4a1793c919b1a09c7b738a8da497d6d6acd [file] [log] [blame]
Tom Cherry14fc0132017-05-09 17:11:57 -07001//
2// Copyright (C) 2017 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Bob Badourd69ad692021-02-16 19:02:14 -080017package {
18 default_applicable_licenses: ["system_core_init_license"],
19}
20
21// Added automatically by a large-scale-change
22// See: http://go/android-license-faq
23license {
24 name: "system_core_init_license",
25 visibility: [":__subpackages__"],
26 license_kinds: [
27 "SPDX-license-identifier-Apache-2.0",
28 ],
29 license_text: [
30 "NOTICE",
31 ],
32}
33
Tom Cherry66196492020-02-06 11:56:58 -080034init_common_sources = [
35 "action.cpp",
36 "action_manager.cpp",
37 "action_parser.cpp",
38 "capabilities.cpp",
39 "epoll.cpp",
40 "import_parser.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -070041 "interprocess_fifo.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080042 "keychords.cpp",
43 "parser.cpp",
44 "property_type.cpp",
45 "rlimit_parser.cpp",
46 "service.cpp",
47 "service_list.cpp",
48 "service_parser.cpp",
49 "service_utils.cpp",
50 "subcontext.cpp",
51 "subcontext.proto",
52 "tokenizer.cpp",
53 "util.cpp",
54]
55init_device_sources = [
Deyao Ren238e9092022-07-21 23:05:13 +000056 "apex_init_util.cpp",
David Anderson41175592020-03-20 19:38:28 -070057 "block_dev_initializer.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080058 "bootchart.cpp",
59 "builtins.cpp",
60 "devices.cpp",
61 "firmware_handler.cpp",
Steve Mucklea4bf2ce2019-11-01 13:58:02 -070062 "first_stage_console.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080063 "first_stage_init.cpp",
64 "first_stage_mount.cpp",
65 "fscrypt_init_extensions.cpp",
66 "init.cpp",
67 "lmkd_service.cpp",
68 "modalias_handler.cpp",
69 "mount_handler.cpp",
70 "mount_namespace.cpp",
71 "persistent_properties.cpp",
72 "persistent_properties.proto",
73 "property_service.cpp",
74 "property_service.proto",
75 "reboot.cpp",
76 "reboot_utils.cpp",
77 "security.cpp",
78 "selabel.cpp",
79 "selinux.cpp",
80 "sigchld_handler.cpp",
David Anderson491e4da2020-12-08 00:21:20 -080081 "snapuserd_transition.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080082 "switch_root.cpp",
David Anderson5330b762025-04-18 15:54:34 -070083 "tradeinmode.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080084 "uevent_listener.cpp",
85 "ueventd.cpp",
86 "ueventd_parser.cpp",
dianlujitaoc721d012025-07-11 16:06:11 +080087 "vendor_init.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080088]
Tom Cherry66196492020-02-06 11:56:58 -080089
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +000090soong_config_module_type {
91 name: "libinit_cc_defaults",
92 module_type: "cc_defaults",
93 config_namespace: "ANDROID",
94 bool_variables: [
95 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
Nate Myrenb9e05452024-05-28 23:40:59 +000096 "release_write_appcompat_override_system_properties",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +000097 ],
98 properties: [
99 "cflags",
100 ],
101}
102
103libinit_cc_defaults {
Tom Cherry14fc0132017-05-09 17:11:57 -0700104 name: "init_defaults",
Tom Cherry14fc0132017-05-09 17:11:57 -0700105 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -0700106 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700107 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -0700108 cflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700109 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -0700110 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
111 "-DALLOW_PERMISSIVE_SELINUX=0",
Bart Van Asscheaee2ec82022-12-02 18:48:15 -0800112 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Tom Cherry14fc0132017-05-09 17:11:57 -0700113 "-DDUMP_ON_UMOUNT_FAILURE=0",
Tom Cherrya2f91362020-02-20 10:50:00 -0800114 "-DINIT_FULL_SOURCES",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000115 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=0",
Bart Van Assche91ba2192022-12-02 18:48:48 -0800116 "-DLOG_UEVENTS=0",
117 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
118 "-DSHUTDOWN_ZERO_TIMEOUT=0",
119 "-DWORLD_WRITABLE_KMSG=0",
Pranav Vashibc71da82021-10-22 04:07:18 +0530120 "-DSPOOF_SAFETYNET=1",
Bart Van Assche91ba2192022-12-02 18:48:48 -0800121 "-Wall",
122 "-Werror",
123 "-Wextra",
124 "-Wno-unused-parameter",
125 "-Wthread-safety",
Tom Cherry14fc0132017-05-09 17:11:57 -0700126 ],
127 product_variables: {
128 debuggable: {
129 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700130 "-UALLOW_FIRST_STAGE_CONSOLE",
131 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700132 "-UALLOW_LOCAL_PROP_OVERRIDE",
133 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
134 "-UALLOW_PERMISSIVE_SELINUX",
135 "-DALLOW_PERMISSIVE_SELINUX=1",
136 "-UREBOOT_BOOTLOADER_ON_PANIC",
137 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
138 "-UWORLD_WRITABLE_KMSG",
139 "-DWORLD_WRITABLE_KMSG=1",
140 "-UDUMP_ON_UMOUNT_FAILURE",
141 "-DDUMP_ON_UMOUNT_FAILURE=1",
Paul Lawrence6bb52892025-01-29 19:43:48 -0800142 "-UALLOW_REMOUNT_OVERLAYS",
143 "-DALLOW_REMOUNT_OVERLAYS=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700144 ],
145 },
146 eng: {
147 cppflags: [
148 "-USHUTDOWN_ZERO_TIMEOUT",
149 "-DSHUTDOWN_ZERO_TIMEOUT=1",
Pranav Vashibc71da82021-10-22 04:07:18 +0530150 "-USPOOF_SAFETYNET",
151 "-DSPOOF_SAFETYNET=0",
Tom Cherry14fc0132017-05-09 17:11:57 -0700152 ],
153 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700154 uml: {
155 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800156 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700157 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000158 soong_config_variables: {
159 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
160 cflags: [
161 "-UINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
162 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=1",
163 ],
164 },
Nate Myrenb9e05452024-05-28 23:40:59 +0000165 release_write_appcompat_override_system_properties: {
166 cflags: ["-DWRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES"],
Nelson Li064ac0b2024-06-17 05:02:56 +0000167 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000168 },
Tom Cherry618d3102018-01-19 14:25:48 -0800169 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800170 "libavb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000171 "libavf_cc_flags",
David Anderson12e53bc2022-10-03 21:37:12 -0700172 "libbootloader_message",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700173 "liblmkd_utils",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700174 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800175 "libzstd",
Steve Muckle18b981e2019-04-15 17:43:02 -0700176 "libmodprobe",
David Anderson9fd88622021-03-05 14:10:55 -0800177 "libprocinfo",
Tom Cherry618d3102018-01-19 14:25:48 -0800178 "libprotobuf-cpp-lite",
179 "libpropertyinfoserializer",
180 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700181 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700182 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900183 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900184 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700185 "update_metadata-protos",
Inseob Kime2efde32024-11-20 17:56:20 +0900186 "libgenfslabelsversion.ffi",
Jiyong Park787322c2018-06-01 19:26:42 +0900187 ],
188 shared_libs: [
Jiyong Park787322c2018-06-01 19:26:42 +0900189 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700190 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900191 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700192 "libext4_utils",
193 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800194 "libgsi",
Michael Bestas97da59b2024-06-14 18:50:46 +0300195 "libkeyutils",
Tao Bao66209ca2018-07-25 22:35:45 -0700196 "liblog",
197 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800198 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800199 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800200 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900201 "libselinux",
Christopher Ferrisd2bd6c52022-05-11 14:42:38 -0700202 "libunwindstack",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200203 "libutils",
Justin Yun6bc1bfe2024-01-10 13:47:02 +0900204 "libvendorsupport",
Tom Cherry618d3102018-01-19 14:25:48 -0800205 ],
Florian Mayerd705c2d2022-09-12 18:19:47 -0700206 header_libs: ["bionic_libc_platform_headers"],
Jiyong Park93318d42018-12-26 17:34:39 +0900207 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700208 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700209}
210
Devendra Singhi1df957b2022-02-15 21:52:55 +0530211cc_library_headers {
212 name: "libinit_headers",
213 export_include_dirs: ["."],
214 visibility: [":__subpackages__"],
215}
216
Nikita Ioffea66adf42023-06-26 14:55:31 +0100217cc_defaults {
218 name: "libinit_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700219 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700220 defaults: [
221 "init_defaults",
222 "selinux_policy_version",
223 ],
Tom Cherry66196492020-02-06 11:56:58 -0800224 srcs: init_common_sources + init_device_sources,
Deyao Ren07595e12022-07-15 22:02:14 +0000225 export_include_dirs: ["."],
Jooyung Han1d951b72020-07-05 03:33:36 +0900226 generated_sources: [
227 "apex-info-list",
228 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700229 whole_static_libs: [
230 "libcap",
David Ngf2fe3f32013-09-23 18:50:24 -0700231 ] + select(soong_config_variable("libinit", "vendor_init_lib"), {
232 any @ flag_val: [flag_val],
dianlujitaoc721d012025-07-11 16:06:11 +0800233 default: [],
David Ngf2fe3f32013-09-23 18:50:24 -0700234 }),
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700235 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700236 proto: {
237 type: "lite",
238 export_proto_headers: true,
239 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200240
241 target: {
242 recovery: {
243 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900244 exclude_static_libs: [
245 "libxml2",
246 ],
247 exclude_generated_sources: [
248 "apex-info-list",
249 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700250 exclude_shared_libs: [
251 "libbinder",
252 "libutils",
253 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200254 },
255 },
Nikita Ioffea66adf42023-06-26 14:55:31 +0100256}
257
258cc_library_static {
259 name: "libinit",
260 defaults: ["libinit_defaults"],
261}
262
263cc_library_static {
264 name: "libinit.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000265 defaults: [
266 "avf_build_flags_cc",
267 "libinit_defaults",
268 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900269 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100270 cflags: ["-DMICRODROID=1"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700271}
272
Steven Morelandceb36d02019-07-15 15:12:56 -0700273phony {
274 name: "init",
275 required: [
276 "init_second_stage",
Paul Lawrence6bb52892025-01-29 19:43:48 -0800277 ] + select(product_variable("debuggable"), {
278 true: ["overlay_remounter"],
279 false: [],
280 }),
Steven Morelandceb36d02019-07-15 15:12:56 -0700281}
282
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100283cc_defaults {
284 name: "init_second_stage_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700285 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700286 defaults: ["init_defaults"],
Tom Cherry618d3102018-01-19 14:25:48 -0800287 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700288 symlinks: ["ueventd"],
Jiyong Park12c64a72024-04-17 14:15:49 +0900289}
290
291cc_binary {
292 name: "init_second_stage",
293 defaults: ["init_second_stage_defaults"],
294 static_libs: ["libinit"],
295 visibility: ["//visibility:any_system_partition"],
Jihoon Kang9b5c6fd2024-12-06 23:33:42 +0000296 required: [
297 "init.rc",
298 "ueventd.rc",
299 "e2fsdroid",
300 "extra_free_kbytes",
301 "make_f2fs",
302 "mke2fs",
303 "sload_f2fs",
304 ],
305}
306
307cc_binary {
308 name: "init_second_stage.recovery",
309 defaults: ["init_second_stage_defaults"],
310 static_libs: ["libinit"],
311 recovery: true,
312 cflags: ["-DRECOVERY"],
313 exclude_static_libs: [
314 "libxml2",
315 ],
316 exclude_shared_libs: [
317 "libbinder",
318 "libutils",
319 ],
320 required: [
321 "init_recovery.rc",
322 "ueventd.rc.recovery",
323 "e2fsdroid.recovery",
324 "make_f2fs.recovery",
325 "mke2fs.recovery",
326 "sload_f2fs.recovery",
327 ],
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100328}
329
330cc_binary {
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100331 name: "init_second_stage.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000332 defaults: [
333 "avf_build_flags_cc",
334 "init_second_stage_defaults",
335 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100336 static_libs: ["libinit.microdroid"],
337 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900338 no_full_install: true,
Jiyong Parkd959fc72024-07-22 11:24:03 +0900339 visibility: ["//packages/modules/Virtualization/build/microdroid"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700340}
Tom Cherry14fc0132017-05-09 17:11:57 -0700341
Inseob Kim74182522021-06-11 12:58:53 +0900342soong_config_module_type {
343 name: "init_first_stage_cc_defaults",
344 module_type: "cc_defaults",
345 config_namespace: "ANDROID",
Yi-Yo Chiangddc97632022-10-07 21:15:03 +0800346 bool_variables: ["BOARD_USES_RECOVERY_AS_BOOT"],
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900347 properties: ["no_full_install"],
Inseob Kim74182522021-06-11 12:58:53 +0900348}
349
350// Do not install init_first_stage even with mma if we're system-as-root.
351// Otherwise, it will overwrite the symlink.
352init_first_stage_cc_defaults {
353 name: "init_first_stage_defaults",
354 soong_config_variables: {
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800355 BOARD_USES_RECOVERY_AS_BOOT: {
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900356 no_full_install: true,
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800357 },
Inseob Kim74182522021-06-11 12:58:53 +0900358 },
Inseob Kim74182522021-06-11 12:58:53 +0900359
Inseob Kim74182522021-06-11 12:58:53 +0900360 stem: "init",
Jiyong Park13eb0532021-02-15 14:13:51 +0900361
362 srcs: [
363 "block_dev_initializer.cpp",
364 "devices.cpp",
365 "first_stage_console.cpp",
366 "first_stage_init.cpp",
367 "first_stage_main.cpp",
368 "first_stage_mount.cpp",
369 "reboot_utils.cpp",
370 "selabel.cpp",
Jiyong Park13eb0532021-02-15 14:13:51 +0900371 "service_utils.cpp",
372 "snapuserd_transition.cpp",
373 "switch_root.cpp",
374 "uevent_listener.cpp",
375 "util.cpp",
376 ],
377
378 static_libs: [
Jiyong Park13eb0532021-02-15 14:13:51 +0900379 "libfs_avb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000380 "libavf_cc_flags",
Jiyong Park13eb0532021-02-15 14:13:51 +0900381 "libfs_mgr",
382 "libfec",
383 "libfec_rs",
384 "libsquashfs_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900385 "libcrypto_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900386 "libavb",
Jiyong Park13eb0532021-02-15 14:13:51 +0900387 "liblp",
388 "libcutils",
389 "libbase",
390 "liblog",
391 "libcrypto_static",
Jiyong Park13eb0532021-02-15 14:13:51 +0900392 "libselinux",
393 "libcap",
394 "libgsi",
Jiyong Park13eb0532021-02-15 14:13:51 +0900395 "liblzma",
396 "libunwindstack_no_dex",
Jiyong Park13eb0532021-02-15 14:13:51 +0900397 "libmodprobe",
398 "libext2_uuid",
399 "libprotobuf-cpp-lite",
400 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700401 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800402 "libzstd",
Jiyong Park13eb0532021-02-15 14:13:51 +0900403 "libsnapshot_init",
404 "update_metadata-protos",
David Anderson9fd88622021-03-05 14:10:55 -0800405 "libprocinfo",
David Anderson6f451a92024-10-02 19:35:21 -0700406 "libbootloader_message",
Jiyong Park13eb0532021-02-15 14:13:51 +0900407 ],
408
409 static_executable: true,
Inseob Kim74182522021-06-11 12:58:53 +0900410 system_shared_libs: [],
Jiyong Park13eb0532021-02-15 14:13:51 +0900411
412 cflags: [
413 "-Wall",
414 "-Wextra",
415 "-Wno-unused-parameter",
416 "-Werror",
417 "-DALLOW_FIRST_STAGE_CONSOLE=0",
418 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
419 "-DALLOW_PERMISSIVE_SELINUX=0",
420 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
421 "-DWORLD_WRITABLE_KMSG=0",
422 "-DDUMP_ON_UMOUNT_FAILURE=0",
423 "-DSHUTDOWN_ZERO_TIMEOUT=0",
424 "-DLOG_UEVENTS=0",
425 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
Pranav Vashibc71da82021-10-22 04:07:18 +0530426 "-DSPOOF_SAFETYNET=1",
Jiyong Park13eb0532021-02-15 14:13:51 +0900427 ],
428
429 product_variables: {
430 debuggable: {
431 cflags: [
432 "-UALLOW_FIRST_STAGE_CONSOLE",
433 "-DALLOW_FIRST_STAGE_CONSOLE=1",
434
435 "-UALLOW_LOCAL_PROP_OVERRIDE",
436 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
437
438 "-UALLOW_PERMISSIVE_SELINUX",
439 "-DALLOW_PERMISSIVE_SELINUX=1",
440
441 "-UREBOOT_BOOTLOADER_ON_PANIC",
442 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
443
444 "-UWORLD_WRITABLE_KMSG",
445 "-DWORLD_WRITABLE_KMSG=1",
446
447 "-UDUMP_ON_UMOUNT_FAILURE",
448 "-DDUMP_ON_UMOUNT_FAILURE=1",
449 ],
450 },
451
452 eng: {
453 cflags: [
454 "-USHUTDOWN_ZERO_TIMEOUT",
455 "-DSHUTDOWN_ZERO_TIMEOUT=1",
Pranav Vashibc71da82021-10-22 04:07:18 +0530456 "-USPOOF_SAFETYNET",
457 "-DSPOOF_SAFETYNET=0",
Jiyong Park13eb0532021-02-15 14:13:51 +0900458 ],
459 },
460 },
461
462 sanitize: {
463 misc_undefined: ["signed-integer-overflow"],
Inseob Kim74182522021-06-11 12:58:53 +0900464
465 // First stage init is weird: it may start without stdout/stderr, and no /proc.
Jiyong Park13eb0532021-02-15 14:13:51 +0900466 hwaddress: false,
Florian Mayerc2eaac52024-03-27 14:30:13 -0700467 memtag_stack: false,
Jiyong Park13eb0532021-02-15 14:13:51 +0900468 },
Inseob Kim74182522021-06-11 12:58:53 +0900469
470 // Install adb_debug.prop into debug ramdisk.
471 // This allows adb root on a user build, when debug ramdisk is used.
472 required: ["adb_debug.prop"],
473
474 ramdisk: true,
475
476 install_in_root: true,
477}
478
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100479cc_binary {
480 name: "init_first_stage",
481 defaults: ["init_first_stage_defaults"],
482}
483
484cc_binary {
485 name: "init_first_stage.microdroid",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000486 defaults: [
487 "avf_build_flags_cc",
Nikita Ioffe1e114e62024-03-05 00:23:31 +0000488 "init_first_stage_defaults",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000489 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100490 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900491 no_full_install: true,
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100492}
493
Inseob Kim74182522021-06-11 12:58:53 +0900494phony {
495 name: "init_system",
496 required: ["init_second_stage"],
Jiyong Park13eb0532021-02-15 14:13:51 +0900497}
498
Tom Cherry14fc0132017-05-09 17:11:57 -0700499// Tests
500// ------------------------------------------------------------------------------
501
502cc_test {
Jiyong Park75070b32024-01-30 10:17:37 +0900503 // Note: This is NOT a CTS test. See b/320800872
Tom Cherry17b2be02019-08-20 10:43:48 -0700504 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700505 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700506 require_root: true,
507
David Andersoncbd082d2022-12-06 20:11:40 -0800508 compile_multilib: "first",
Tom Cherry17b2be02019-08-20 10:43:48 -0700509
Tom Cherry14fc0132017-05-09 17:11:57 -0700510 srcs: [
511 "devices_test.cpp",
David Anderson1de73842021-05-13 20:18:14 -0700512 "epoll_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700513 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700514 "init_test.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -0700515 "interprocess_fifo_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700516 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800517 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700518 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700519 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800520 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000521 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700522 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700523 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700524 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700525 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700526 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700527 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700528 "util_test.cpp",
529 ],
Bart Van Assche1693f422022-10-19 16:30:15 -0700530 static_libs: [
531 "libgmock",
532 "libinit",
533 ],
Tom Cherry17b2be02019-08-20 10:43:48 -0700534
535 test_suites: [
Tom Cherry17b2be02019-08-20 10:43:48 -0700536 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700537 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700538}
539
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700540cc_benchmark {
541 name: "init_benchmarks",
542 defaults: ["init_defaults"],
543 srcs: [
544 "subcontext_benchmark.cpp",
545 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800546 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700547}
548
Tom Cherrya2f91362020-02-20 10:50:00 -0800549cc_defaults {
550 name: "libinit_test_utils_libraries_defaults",
551 shared_libs: [
552 "libbase",
553 "libcutils",
554 "libselinux",
Tom Cherrya2f91362020-02-20 10:50:00 -0800555 "liblog",
556 "libprocessgroup",
557 "libprotobuf-cpp-lite",
558 ],
Steven Moreland973aade2023-03-15 19:39:15 +0000559 static_libs: [
Yi-Yo Chiangb8c23252023-07-25 22:08:55 +0800560 "libfs_mgr",
Steven Moreland973aade2023-03-15 19:39:15 +0000561 "libhidl-gen-utils",
562 ],
Tom Cherrya2f91362020-02-20 10:50:00 -0800563}
564
565cc_library_static {
566 name: "libinit_test_utils",
567 defaults: ["libinit_test_utils_libraries_defaults"],
568 cflags: [
569 "-Wall",
570 "-Wextra",
571 "-Wno-unused-parameter",
572 "-Werror",
573 ],
574 srcs: init_common_sources + [
575 "test_utils/service_utils.cpp",
576 ],
577 whole_static_libs: [
578 "libcap",
579 ],
580 export_include_dirs: ["test_utils/include"], // for tests
Florian Mayerd705c2d2022-09-12 18:19:47 -0700581 header_libs: ["bionic_libc_platform_headers"],
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000582 product_variables: {
583 shipping_api_level: {
584 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
585 },
586 },
Tom Cherrya2f91362020-02-20 10:50:00 -0800587}
588
Tom Cherryde6bd502018-02-13 16:50:08 -0800589// Host Verifier
590// ------------------------------------------------------------------------------
591
592genrule {
593 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700594 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800595 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700596 srcs: [
597 "builtins.cpp",
598 "check_builtins.cpp",
599 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700600 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800601}
602
Daniel Normanf1200fb2022-03-09 10:49:26 -0800603cc_defaults {
604 name: "init_host_defaults",
Tom Cherryde6bd502018-02-13 16:50:08 -0800605 host_supported: true,
Tom Cherryde6bd502018-02-13 16:50:08 -0800606 cflags: [
607 "-Wall",
608 "-Wextra",
609 "-Wno-unused-parameter",
610 "-Werror",
611 ],
612 static_libs: [
613 "libbase",
Marcin Radomski77e36c82025-03-05 19:11:31 +0000614 "libfstab",
Tom Cherryde6bd502018-02-13 16:50:08 -0800615 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800616 "libpropertyinfoserializer",
617 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800618 ],
619 whole_static_libs: ["libcap"],
620 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800621 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700622 "liblog",
623 "libprocessgroup",
624 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800625 ],
Tom Cherryde6bd502018-02-13 16:50:08 -0800626 proto: {
627 type: "lite",
628 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800629 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800630 android: {
631 enabled: false,
632 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800633 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000634 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800635 },
636 },
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000637 product_variables: {
638 shipping_api_level: {
639 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
640 },
641 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800642}
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700643
Daniel Normanf1200fb2022-03-09 10:49:26 -0800644cc_binary {
645 name: "host_init_verifier",
646 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900647 srcs: [
648 "check_builtins.cpp",
649 "host_import_parser.cpp",
650 "host_init_verifier.cpp",
651 "interface_utils.cpp",
652 ] + init_common_sources,
Jooyung Han18407b72024-02-24 09:16:35 +0900653 generated_headers: [
654 "generated_android_ids",
Jooyung Han9b4ad172024-08-27 13:07:58 +0900655 "generated_stub_builtin_function_map",
Jooyung Han18407b72024-02-24 09:16:35 +0900656 ],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900657 shared_libs: [
658 "libhidl-gen-utils",
659 "libhidlmetadata",
660 ],
661}
662
663genrule {
664 name: "noop_builtin_function_map",
665 tool_files: ["host_builtin_map.py"],
666 out: ["noop_builtin_function_map.h"],
667 srcs: [
668 "builtins.cpp",
669 "noop_builtins.cpp",
670 ],
671 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location noop_builtins.cpp) > $(out)",
Daniel Normanf1200fb2022-03-09 10:49:26 -0800672}
673
674cc_library_host_static {
675 name: "libinit_host",
676 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900677 srcs: [
678 "noop_builtins.cpp",
679 ] + init_common_sources,
Daniel Normanf1200fb2022-03-09 10:49:26 -0800680 export_include_dirs: ["."],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900681 generated_headers: [
682 "noop_builtin_function_map",
683 ],
Daniel Normanf1200fb2022-03-09 10:49:26 -0800684 proto: {
685 export_proto_headers: true,
686 },
687 visibility: [
688 // host_apex_verifier performs a subset of init.rc validation
689 "//system/apex/tools",
690 ],
691}
692
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700693sh_binary {
Cole Faust7e279e92022-09-05 18:12:42 -0700694 name: "extra_free_kbytes",
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700695 src: "extra_free_kbytes.sh",
Cole Faust7e279e92022-09-05 18:12:42 -0700696 filename_from_src: true,
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700697}
Nelson Li064ac0b2024-06-17 05:02:56 +0000698
Nelson Lic2970dd2024-06-19 02:14:23 +0000699phony {
Nelson Li064ac0b2024-06-17 05:02:56 +0000700 name: "init_vendor",
Nelson Lic2970dd2024-06-19 02:14:23 +0000701 required: select(soong_config_variable("ANDROID", "BOARD_USES_RECOVERY_AS_BOOT"), {
702 true: [],
703 default: ["init_first_stage"],
704 }),
Nelson Li064ac0b2024-06-17 05:02:56 +0000705}