blob: b209c47c94b2b6f954a4e60f6360868d87220bcb [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",
83 "uevent_listener.cpp",
84 "ueventd.cpp",
85 "ueventd_parser.cpp",
86]
Tom Cherry66196492020-02-06 11:56:58 -080087
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +000088soong_config_module_type {
89 name: "libinit_cc_defaults",
90 module_type: "cc_defaults",
91 config_namespace: "ANDROID",
92 bool_variables: [
93 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
Nate Myrenb9e05452024-05-28 23:40:59 +000094 "release_write_appcompat_override_system_properties",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +000095 ],
96 properties: [
97 "cflags",
98 ],
99}
100
101libinit_cc_defaults {
Tom Cherry14fc0132017-05-09 17:11:57 -0700102 name: "init_defaults",
Tom Cherry14fc0132017-05-09 17:11:57 -0700103 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -0700104 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700105 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -0700106 cflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700107 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -0700108 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
109 "-DALLOW_PERMISSIVE_SELINUX=0",
Bart Van Asscheaee2ec82022-12-02 18:48:15 -0800110 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Tom Cherry14fc0132017-05-09 17:11:57 -0700111 "-DDUMP_ON_UMOUNT_FAILURE=0",
Tom Cherrya2f91362020-02-20 10:50:00 -0800112 "-DINIT_FULL_SOURCES",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000113 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=0",
Bart Van Assche91ba2192022-12-02 18:48:48 -0800114 "-DLOG_UEVENTS=0",
115 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
116 "-DSHUTDOWN_ZERO_TIMEOUT=0",
117 "-DWORLD_WRITABLE_KMSG=0",
118 "-Wall",
119 "-Werror",
120 "-Wextra",
121 "-Wno-unused-parameter",
122 "-Wthread-safety",
Tom Cherry14fc0132017-05-09 17:11:57 -0700123 ],
124 product_variables: {
125 debuggable: {
126 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700127 "-UALLOW_FIRST_STAGE_CONSOLE",
128 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700129 "-UALLOW_LOCAL_PROP_OVERRIDE",
130 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
131 "-UALLOW_PERMISSIVE_SELINUX",
132 "-DALLOW_PERMISSIVE_SELINUX=1",
133 "-UREBOOT_BOOTLOADER_ON_PANIC",
134 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
135 "-UWORLD_WRITABLE_KMSG",
136 "-DWORLD_WRITABLE_KMSG=1",
137 "-UDUMP_ON_UMOUNT_FAILURE",
138 "-DDUMP_ON_UMOUNT_FAILURE=1",
Paul Lawrence6bb52892025-01-29 19:43:48 -0800139 "-UALLOW_REMOUNT_OVERLAYS",
140 "-DALLOW_REMOUNT_OVERLAYS=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700141 ],
142 },
143 eng: {
144 cppflags: [
145 "-USHUTDOWN_ZERO_TIMEOUT",
146 "-DSHUTDOWN_ZERO_TIMEOUT=1",
147 ],
148 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700149 uml: {
150 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800151 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700152 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000153 soong_config_variables: {
154 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
155 cflags: [
156 "-UINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
157 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=1",
158 ],
159 },
Nate Myrenb9e05452024-05-28 23:40:59 +0000160 release_write_appcompat_override_system_properties: {
161 cflags: ["-DWRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES"],
Nelson Li064ac0b2024-06-17 05:02:56 +0000162 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000163 },
Tom Cherry618d3102018-01-19 14:25:48 -0800164 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800165 "libavb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000166 "libavf_cc_flags",
David Anderson12e53bc2022-10-03 21:37:12 -0700167 "libbootloader_message",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700168 "liblmkd_utils",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700169 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800170 "libzstd",
Steve Muckle18b981e2019-04-15 17:43:02 -0700171 "libmodprobe",
David Anderson9fd88622021-03-05 14:10:55 -0800172 "libprocinfo",
Tom Cherry618d3102018-01-19 14:25:48 -0800173 "libprotobuf-cpp-lite",
174 "libpropertyinfoserializer",
175 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700176 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700177 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900178 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900179 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700180 "update_metadata-protos",
Inseob Kime2efde32024-11-20 17:56:20 +0900181 "libgenfslabelsversion.ffi",
Jiyong Park787322c2018-06-01 19:26:42 +0900182 ],
183 shared_libs: [
Jiyong Park787322c2018-06-01 19:26:42 +0900184 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700185 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900186 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700187 "libext4_utils",
188 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800189 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700190 "liblog",
191 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800192 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800193 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800194 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900195 "libselinux",
Christopher Ferrisd2bd6c52022-05-11 14:42:38 -0700196 "libunwindstack",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200197 "libutils",
Justin Yun6bc1bfe2024-01-10 13:47:02 +0900198 "libvendorsupport",
Tom Cherry618d3102018-01-19 14:25:48 -0800199 ],
Florian Mayerd705c2d2022-09-12 18:19:47 -0700200 header_libs: ["bionic_libc_platform_headers"],
Jiyong Park93318d42018-12-26 17:34:39 +0900201 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700202 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700203}
204
Devendra Singhi1df957b2022-02-15 21:52:55 +0530205cc_library_headers {
206 name: "libinit_headers",
207 export_include_dirs: ["."],
208 visibility: [":__subpackages__"],
209}
210
Nikita Ioffea66adf42023-06-26 14:55:31 +0100211cc_defaults {
212 name: "libinit_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700213 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700214 defaults: [
215 "init_defaults",
216 "selinux_policy_version",
217 ],
Tom Cherry66196492020-02-06 11:56:58 -0800218 srcs: init_common_sources + init_device_sources,
Deyao Ren07595e12022-07-15 22:02:14 +0000219 export_include_dirs: ["."],
Jooyung Han1d951b72020-07-05 03:33:36 +0900220 generated_sources: [
221 "apex-info-list",
222 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700223 whole_static_libs: [
224 "libcap",
Daniel Norman8082ba22019-07-23 10:26:15 -0700225 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700226 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700227 proto: {
228 type: "lite",
229 export_proto_headers: true,
230 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200231
232 target: {
233 recovery: {
234 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900235 exclude_static_libs: [
236 "libxml2",
237 ],
238 exclude_generated_sources: [
239 "apex-info-list",
240 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700241 exclude_shared_libs: [
242 "libbinder",
243 "libutils",
244 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200245 },
246 },
Nikita Ioffea66adf42023-06-26 14:55:31 +0100247}
248
249cc_library_static {
250 name: "libinit",
251 defaults: ["libinit_defaults"],
252}
253
254cc_library_static {
255 name: "libinit.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000256 defaults: [
257 "avf_build_flags_cc",
258 "libinit_defaults",
259 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900260 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100261 cflags: ["-DMICRODROID=1"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700262}
263
Steven Morelandceb36d02019-07-15 15:12:56 -0700264phony {
265 name: "init",
266 required: [
267 "init_second_stage",
Paul Lawrence6bb52892025-01-29 19:43:48 -0800268 ] + select(product_variable("debuggable"), {
269 true: ["overlay_remounter"],
270 false: [],
271 }),
Steven Morelandceb36d02019-07-15 15:12:56 -0700272}
273
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100274cc_defaults {
275 name: "init_second_stage_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700276 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700277 defaults: ["init_defaults"],
Tom Cherry618d3102018-01-19 14:25:48 -0800278 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700279 symlinks: ["ueventd"],
Jiyong Park12c64a72024-04-17 14:15:49 +0900280}
281
282cc_binary {
283 name: "init_second_stage",
284 defaults: ["init_second_stage_defaults"],
285 static_libs: ["libinit"],
286 visibility: ["//visibility:any_system_partition"],
Jihoon Kang9b5c6fd2024-12-06 23:33:42 +0000287 required: [
288 "init.rc",
289 "ueventd.rc",
290 "e2fsdroid",
291 "extra_free_kbytes",
292 "make_f2fs",
293 "mke2fs",
294 "sload_f2fs",
295 ],
296}
297
298cc_binary {
299 name: "init_second_stage.recovery",
300 defaults: ["init_second_stage_defaults"],
301 static_libs: ["libinit"],
302 recovery: true,
303 cflags: ["-DRECOVERY"],
304 exclude_static_libs: [
305 "libxml2",
306 ],
307 exclude_shared_libs: [
308 "libbinder",
309 "libutils",
310 ],
311 required: [
312 "init_recovery.rc",
313 "ueventd.rc.recovery",
314 "e2fsdroid.recovery",
315 "make_f2fs.recovery",
316 "mke2fs.recovery",
317 "sload_f2fs.recovery",
318 ],
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100319}
320
321cc_binary {
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100322 name: "init_second_stage.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000323 defaults: [
324 "avf_build_flags_cc",
325 "init_second_stage_defaults",
326 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100327 static_libs: ["libinit.microdroid"],
328 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900329 no_full_install: true,
Jiyong Parkd959fc72024-07-22 11:24:03 +0900330 visibility: ["//packages/modules/Virtualization/build/microdroid"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700331}
Tom Cherry14fc0132017-05-09 17:11:57 -0700332
Inseob Kim74182522021-06-11 12:58:53 +0900333soong_config_module_type {
334 name: "init_first_stage_cc_defaults",
335 module_type: "cc_defaults",
336 config_namespace: "ANDROID",
Yi-Yo Chiangddc97632022-10-07 21:15:03 +0800337 bool_variables: ["BOARD_USES_RECOVERY_AS_BOOT"],
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900338 properties: ["no_full_install"],
Inseob Kim74182522021-06-11 12:58:53 +0900339}
340
341// Do not install init_first_stage even with mma if we're system-as-root.
342// Otherwise, it will overwrite the symlink.
343init_first_stage_cc_defaults {
344 name: "init_first_stage_defaults",
345 soong_config_variables: {
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800346 BOARD_USES_RECOVERY_AS_BOOT: {
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900347 no_full_install: true,
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800348 },
Inseob Kim74182522021-06-11 12:58:53 +0900349 },
Inseob Kim74182522021-06-11 12:58:53 +0900350
Inseob Kim74182522021-06-11 12:58:53 +0900351 stem: "init",
Jiyong Park13eb0532021-02-15 14:13:51 +0900352
353 srcs: [
354 "block_dev_initializer.cpp",
355 "devices.cpp",
356 "first_stage_console.cpp",
357 "first_stage_init.cpp",
358 "first_stage_main.cpp",
359 "first_stage_mount.cpp",
360 "reboot_utils.cpp",
361 "selabel.cpp",
Jiyong Park13eb0532021-02-15 14:13:51 +0900362 "service_utils.cpp",
363 "snapuserd_transition.cpp",
364 "switch_root.cpp",
365 "uevent_listener.cpp",
366 "util.cpp",
367 ],
368
369 static_libs: [
Jiyong Park13eb0532021-02-15 14:13:51 +0900370 "libfs_avb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000371 "libavf_cc_flags",
Jiyong Park13eb0532021-02-15 14:13:51 +0900372 "libfs_mgr",
373 "libfec",
374 "libfec_rs",
375 "libsquashfs_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900376 "libcrypto_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900377 "libavb",
Jiyong Park13eb0532021-02-15 14:13:51 +0900378 "liblp",
379 "libcutils",
380 "libbase",
381 "liblog",
382 "libcrypto_static",
Jiyong Park13eb0532021-02-15 14:13:51 +0900383 "libselinux",
384 "libcap",
385 "libgsi",
Jiyong Park13eb0532021-02-15 14:13:51 +0900386 "liblzma",
387 "libunwindstack_no_dex",
Jiyong Park13eb0532021-02-15 14:13:51 +0900388 "libmodprobe",
389 "libext2_uuid",
390 "libprotobuf-cpp-lite",
391 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700392 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800393 "libzstd",
Jiyong Park13eb0532021-02-15 14:13:51 +0900394 "libsnapshot_init",
395 "update_metadata-protos",
David Anderson9fd88622021-03-05 14:10:55 -0800396 "libprocinfo",
David Anderson6f451a92024-10-02 19:35:21 -0700397 "libbootloader_message",
Jiyong Park13eb0532021-02-15 14:13:51 +0900398 ],
399
400 static_executable: true,
Inseob Kim74182522021-06-11 12:58:53 +0900401 system_shared_libs: [],
Jiyong Park13eb0532021-02-15 14:13:51 +0900402
403 cflags: [
404 "-Wall",
405 "-Wextra",
406 "-Wno-unused-parameter",
407 "-Werror",
408 "-DALLOW_FIRST_STAGE_CONSOLE=0",
409 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
410 "-DALLOW_PERMISSIVE_SELINUX=0",
411 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
412 "-DWORLD_WRITABLE_KMSG=0",
413 "-DDUMP_ON_UMOUNT_FAILURE=0",
414 "-DSHUTDOWN_ZERO_TIMEOUT=0",
415 "-DLOG_UEVENTS=0",
416 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
417 ],
418
419 product_variables: {
420 debuggable: {
421 cflags: [
422 "-UALLOW_FIRST_STAGE_CONSOLE",
423 "-DALLOW_FIRST_STAGE_CONSOLE=1",
424
425 "-UALLOW_LOCAL_PROP_OVERRIDE",
426 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
427
428 "-UALLOW_PERMISSIVE_SELINUX",
429 "-DALLOW_PERMISSIVE_SELINUX=1",
430
431 "-UREBOOT_BOOTLOADER_ON_PANIC",
432 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
433
434 "-UWORLD_WRITABLE_KMSG",
435 "-DWORLD_WRITABLE_KMSG=1",
436
437 "-UDUMP_ON_UMOUNT_FAILURE",
438 "-DDUMP_ON_UMOUNT_FAILURE=1",
439 ],
440 },
441
442 eng: {
443 cflags: [
444 "-USHUTDOWN_ZERO_TIMEOUT",
445 "-DSHUTDOWN_ZERO_TIMEOUT=1",
446 ],
447 },
448 },
449
450 sanitize: {
451 misc_undefined: ["signed-integer-overflow"],
Inseob Kim74182522021-06-11 12:58:53 +0900452
453 // First stage init is weird: it may start without stdout/stderr, and no /proc.
Jiyong Park13eb0532021-02-15 14:13:51 +0900454 hwaddress: false,
Florian Mayerc2eaac52024-03-27 14:30:13 -0700455 memtag_stack: false,
Jiyong Park13eb0532021-02-15 14:13:51 +0900456 },
Inseob Kim74182522021-06-11 12:58:53 +0900457
458 // Install adb_debug.prop into debug ramdisk.
459 // This allows adb root on a user build, when debug ramdisk is used.
460 required: ["adb_debug.prop"],
461
462 ramdisk: true,
463
464 install_in_root: true,
465}
466
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100467cc_binary {
468 name: "init_first_stage",
469 defaults: ["init_first_stage_defaults"],
470}
471
472cc_binary {
473 name: "init_first_stage.microdroid",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000474 defaults: [
475 "avf_build_flags_cc",
Nikita Ioffe1e114e62024-03-05 00:23:31 +0000476 "init_first_stage_defaults",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000477 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100478 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900479 no_full_install: true,
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100480}
481
Inseob Kim74182522021-06-11 12:58:53 +0900482phony {
483 name: "init_system",
484 required: ["init_second_stage"],
Jiyong Park13eb0532021-02-15 14:13:51 +0900485}
486
Tom Cherry14fc0132017-05-09 17:11:57 -0700487// Tests
488// ------------------------------------------------------------------------------
489
490cc_test {
Jiyong Park75070b32024-01-30 10:17:37 +0900491 // Note: This is NOT a CTS test. See b/320800872
Tom Cherry17b2be02019-08-20 10:43:48 -0700492 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700493 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700494 require_root: true,
495
David Andersoncbd082d2022-12-06 20:11:40 -0800496 compile_multilib: "first",
Tom Cherry17b2be02019-08-20 10:43:48 -0700497
Tom Cherry14fc0132017-05-09 17:11:57 -0700498 srcs: [
499 "devices_test.cpp",
David Anderson1de73842021-05-13 20:18:14 -0700500 "epoll_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700501 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700502 "init_test.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -0700503 "interprocess_fifo_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700504 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800505 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700506 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700507 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800508 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000509 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700510 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700511 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700512 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700513 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700514 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700515 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700516 "util_test.cpp",
517 ],
Bart Van Assche1693f422022-10-19 16:30:15 -0700518 static_libs: [
519 "libgmock",
520 "libinit",
521 ],
Tom Cherry17b2be02019-08-20 10:43:48 -0700522
523 test_suites: [
Tom Cherry17b2be02019-08-20 10:43:48 -0700524 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700525 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700526}
527
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700528cc_benchmark {
529 name: "init_benchmarks",
530 defaults: ["init_defaults"],
531 srcs: [
532 "subcontext_benchmark.cpp",
533 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800534 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700535}
536
Tom Cherrya2f91362020-02-20 10:50:00 -0800537cc_defaults {
538 name: "libinit_test_utils_libraries_defaults",
539 shared_libs: [
540 "libbase",
541 "libcutils",
542 "libselinux",
Tom Cherrya2f91362020-02-20 10:50:00 -0800543 "liblog",
544 "libprocessgroup",
545 "libprotobuf-cpp-lite",
546 ],
Steven Moreland973aade2023-03-15 19:39:15 +0000547 static_libs: [
Yi-Yo Chiangb8c23252023-07-25 22:08:55 +0800548 "libfs_mgr",
Steven Moreland973aade2023-03-15 19:39:15 +0000549 "libhidl-gen-utils",
550 ],
Tom Cherrya2f91362020-02-20 10:50:00 -0800551}
552
553cc_library_static {
554 name: "libinit_test_utils",
555 defaults: ["libinit_test_utils_libraries_defaults"],
556 cflags: [
557 "-Wall",
558 "-Wextra",
559 "-Wno-unused-parameter",
560 "-Werror",
561 ],
562 srcs: init_common_sources + [
563 "test_utils/service_utils.cpp",
564 ],
565 whole_static_libs: [
566 "libcap",
567 ],
568 export_include_dirs: ["test_utils/include"], // for tests
Florian Mayerd705c2d2022-09-12 18:19:47 -0700569 header_libs: ["bionic_libc_platform_headers"],
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000570 product_variables: {
571 shipping_api_level: {
572 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
573 },
574 },
Tom Cherrya2f91362020-02-20 10:50:00 -0800575}
576
Tom Cherryde6bd502018-02-13 16:50:08 -0800577// Host Verifier
578// ------------------------------------------------------------------------------
579
580genrule {
581 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700582 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800583 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700584 srcs: [
585 "builtins.cpp",
586 "check_builtins.cpp",
587 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700588 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800589}
590
Daniel Normanf1200fb2022-03-09 10:49:26 -0800591cc_defaults {
592 name: "init_host_defaults",
Tom Cherryde6bd502018-02-13 16:50:08 -0800593 host_supported: true,
Tom Cherryde6bd502018-02-13 16:50:08 -0800594 cflags: [
595 "-Wall",
596 "-Wextra",
597 "-Wno-unused-parameter",
598 "-Werror",
599 ],
600 static_libs: [
601 "libbase",
Marcin Radomski77e36c82025-03-05 19:11:31 +0000602 "libfstab",
Tom Cherryde6bd502018-02-13 16:50:08 -0800603 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800604 "libpropertyinfoserializer",
605 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800606 ],
607 whole_static_libs: ["libcap"],
608 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800609 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700610 "liblog",
611 "libprocessgroup",
612 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800613 ],
Tom Cherryde6bd502018-02-13 16:50:08 -0800614 proto: {
615 type: "lite",
616 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800617 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800618 android: {
619 enabled: false,
620 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800621 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000622 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800623 },
624 },
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000625 product_variables: {
626 shipping_api_level: {
627 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
628 },
629 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800630}
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700631
Daniel Normanf1200fb2022-03-09 10:49:26 -0800632cc_binary {
633 name: "host_init_verifier",
634 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900635 srcs: [
636 "check_builtins.cpp",
637 "host_import_parser.cpp",
638 "host_init_verifier.cpp",
639 "interface_utils.cpp",
640 ] + init_common_sources,
Jooyung Han18407b72024-02-24 09:16:35 +0900641 generated_headers: [
642 "generated_android_ids",
Jooyung Han9b4ad172024-08-27 13:07:58 +0900643 "generated_stub_builtin_function_map",
Jooyung Han18407b72024-02-24 09:16:35 +0900644 ],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900645 shared_libs: [
646 "libhidl-gen-utils",
647 "libhidlmetadata",
648 ],
649}
650
651genrule {
652 name: "noop_builtin_function_map",
653 tool_files: ["host_builtin_map.py"],
654 out: ["noop_builtin_function_map.h"],
655 srcs: [
656 "builtins.cpp",
657 "noop_builtins.cpp",
658 ],
659 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location noop_builtins.cpp) > $(out)",
Daniel Normanf1200fb2022-03-09 10:49:26 -0800660}
661
662cc_library_host_static {
663 name: "libinit_host",
664 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900665 srcs: [
666 "noop_builtins.cpp",
667 ] + init_common_sources,
Daniel Normanf1200fb2022-03-09 10:49:26 -0800668 export_include_dirs: ["."],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900669 generated_headers: [
670 "noop_builtin_function_map",
671 ],
Daniel Normanf1200fb2022-03-09 10:49:26 -0800672 proto: {
673 export_proto_headers: true,
674 },
675 visibility: [
676 // host_apex_verifier performs a subset of init.rc validation
677 "//system/apex/tools",
678 ],
679}
680
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700681sh_binary {
Cole Faust7e279e92022-09-05 18:12:42 -0700682 name: "extra_free_kbytes",
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700683 src: "extra_free_kbytes.sh",
Cole Faust7e279e92022-09-05 18:12:42 -0700684 filename_from_src: true,
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700685}
Nelson Li064ac0b2024-06-17 05:02:56 +0000686
Nelson Lic2970dd2024-06-19 02:14:23 +0000687phony {
Nelson Li064ac0b2024-06-17 05:02:56 +0000688 name: "init_vendor",
Nelson Lic2970dd2024-06-19 02:14:23 +0000689 required: select(soong_config_variable("ANDROID", "BOARD_USES_RECOVERY_AS_BOOT"), {
690 true: [],
691 default: ["init_first_stage"],
692 }),
Nelson Li064ac0b2024-06-17 05:02:56 +0000693}