blob: 5e06000a4a96db28f74f906f9d36da2910cc6e79 [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",
139 ],
140 },
141 eng: {
142 cppflags: [
143 "-USHUTDOWN_ZERO_TIMEOUT",
144 "-DSHUTDOWN_ZERO_TIMEOUT=1",
145 ],
146 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700147 uml: {
148 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800149 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700150 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000151 soong_config_variables: {
152 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
153 cflags: [
154 "-UINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
155 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=1",
156 ],
157 },
Nate Myrenb9e05452024-05-28 23:40:59 +0000158 release_write_appcompat_override_system_properties: {
159 cflags: ["-DWRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES"],
Nelson Li064ac0b2024-06-17 05:02:56 +0000160 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000161 },
Tom Cherry618d3102018-01-19 14:25:48 -0800162 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800163 "libavb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000164 "libavf_cc_flags",
David Anderson12e53bc2022-10-03 21:37:12 -0700165 "libbootloader_message",
Yifan Hongd8ce1fb2019-03-22 17:21:58 -0700166 "libcgrouprc_format",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700167 "liblmkd_utils",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700168 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800169 "libzstd",
Steve Muckle18b981e2019-04-15 17:43:02 -0700170 "libmodprobe",
David Anderson9fd88622021-03-05 14:10:55 -0800171 "libprocinfo",
Tom Cherry618d3102018-01-19 14:25:48 -0800172 "libprotobuf-cpp-lite",
173 "libpropertyinfoserializer",
174 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700175 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700176 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900177 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900178 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700179 "update_metadata-protos",
Jiyong Park787322c2018-06-01 19:26:42 +0900180 ],
181 shared_libs: [
Jiyong Park787322c2018-06-01 19:26:42 +0900182 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700183 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900184 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700185 "libext4_utils",
186 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800187 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700188 "liblog",
189 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800190 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800191 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800192 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900193 "libselinux",
Christopher Ferrisd2bd6c52022-05-11 14:42:38 -0700194 "libunwindstack",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200195 "libutils",
Justin Yun6bc1bfe2024-01-10 13:47:02 +0900196 "libvendorsupport",
Tom Cherry618d3102018-01-19 14:25:48 -0800197 ],
Florian Mayerd705c2d2022-09-12 18:19:47 -0700198 header_libs: ["bionic_libc_platform_headers"],
Jiyong Park93318d42018-12-26 17:34:39 +0900199 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700200 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700201}
202
Devendra Singhi1df957b2022-02-15 21:52:55 +0530203cc_library_headers {
204 name: "libinit_headers",
205 export_include_dirs: ["."],
206 visibility: [":__subpackages__"],
207}
208
Nikita Ioffea66adf42023-06-26 14:55:31 +0100209cc_defaults {
210 name: "libinit_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700211 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700212 defaults: [
213 "init_defaults",
214 "selinux_policy_version",
215 ],
Tom Cherry66196492020-02-06 11:56:58 -0800216 srcs: init_common_sources + init_device_sources,
Deyao Ren07595e12022-07-15 22:02:14 +0000217 export_include_dirs: ["."],
Jooyung Han1d951b72020-07-05 03:33:36 +0900218 generated_sources: [
219 "apex-info-list",
220 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700221 whole_static_libs: [
222 "libcap",
Daniel Norman8082ba22019-07-23 10:26:15 -0700223 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700224 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700225 proto: {
226 type: "lite",
227 export_proto_headers: true,
228 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200229
230 target: {
231 recovery: {
232 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900233 exclude_static_libs: [
234 "libxml2",
235 ],
236 exclude_generated_sources: [
237 "apex-info-list",
238 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700239 exclude_shared_libs: [
240 "libbinder",
241 "libutils",
242 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200243 },
244 },
Nikita Ioffea66adf42023-06-26 14:55:31 +0100245}
246
247cc_library_static {
248 name: "libinit",
249 defaults: ["libinit_defaults"],
250}
251
252cc_library_static {
253 name: "libinit.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000254 defaults: [
255 "avf_build_flags_cc",
256 "libinit_defaults",
257 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900258 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100259 cflags: ["-DMICRODROID=1"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700260}
261
Steven Morelandceb36d02019-07-15 15:12:56 -0700262phony {
263 name: "init",
264 required: [
265 "init_second_stage",
266 ],
267}
268
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100269cc_defaults {
270 name: "init_second_stage_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700271 recovery_available: true,
272 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700273 defaults: ["init_defaults"],
Tom Cherry618d3102018-01-19 14:25:48 -0800274 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700275 symlinks: ["ueventd"],
Jiyong Park12c64a72024-04-17 14:15:49 +0900276}
277
278cc_binary {
279 name: "init_second_stage",
280 defaults: ["init_second_stage_defaults"],
281 static_libs: ["libinit"],
282 visibility: ["//visibility:any_system_partition"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200283 target: {
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800284 platform: {
285 required: [
286 "init.rc",
287 "ueventd.rc",
288 "e2fsdroid",
Cole Faust7e279e92022-09-05 18:12:42 -0700289 "extra_free_kbytes",
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800290 "make_f2fs",
291 "mke2fs",
292 "sload_f2fs",
293 ],
294 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200295 recovery: {
296 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900297 exclude_static_libs: [
298 "libxml2",
299 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700300 exclude_shared_libs: [
301 "libbinder",
302 "libutils",
303 ],
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800304 required: [
305 "init_recovery.rc",
306 "ueventd.rc.recovery",
307 "e2fsdroid.recovery",
308 "make_f2fs.recovery",
309 "mke2fs.recovery",
310 "sload_f2fs.recovery",
311 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200312 },
313 },
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100314}
315
316cc_binary {
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100317 name: "init_second_stage.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000318 defaults: [
319 "avf_build_flags_cc",
320 "init_second_stage_defaults",
321 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900322 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100323 static_libs: ["libinit.microdroid"],
324 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900325 no_full_install: true,
Jiyong Parkd959fc72024-07-22 11:24:03 +0900326 visibility: ["//packages/modules/Virtualization/build/microdroid"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700327}
Tom Cherry14fc0132017-05-09 17:11:57 -0700328
Inseob Kim74182522021-06-11 12:58:53 +0900329soong_config_module_type {
330 name: "init_first_stage_cc_defaults",
331 module_type: "cc_defaults",
332 config_namespace: "ANDROID",
Yi-Yo Chiangddc97632022-10-07 21:15:03 +0800333 bool_variables: ["BOARD_USES_RECOVERY_AS_BOOT"],
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900334 properties: ["no_full_install"],
Inseob Kim74182522021-06-11 12:58:53 +0900335}
336
337// Do not install init_first_stage even with mma if we're system-as-root.
338// Otherwise, it will overwrite the symlink.
339init_first_stage_cc_defaults {
340 name: "init_first_stage_defaults",
341 soong_config_variables: {
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800342 BOARD_USES_RECOVERY_AS_BOOT: {
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900343 no_full_install: true,
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800344 },
Inseob Kim74182522021-06-11 12:58:53 +0900345 },
Inseob Kim74182522021-06-11 12:58:53 +0900346
Inseob Kim74182522021-06-11 12:58:53 +0900347 stem: "init",
Jiyong Park13eb0532021-02-15 14:13:51 +0900348
349 srcs: [
350 "block_dev_initializer.cpp",
351 "devices.cpp",
352 "first_stage_console.cpp",
353 "first_stage_init.cpp",
354 "first_stage_main.cpp",
355 "first_stage_mount.cpp",
356 "reboot_utils.cpp",
357 "selabel.cpp",
Jiyong Park13eb0532021-02-15 14:13:51 +0900358 "service_utils.cpp",
359 "snapuserd_transition.cpp",
360 "switch_root.cpp",
361 "uevent_listener.cpp",
362 "util.cpp",
363 ],
364
365 static_libs: [
Jiyong Park13eb0532021-02-15 14:13:51 +0900366 "libfs_avb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000367 "libavf_cc_flags",
Jiyong Park13eb0532021-02-15 14:13:51 +0900368 "libfs_mgr",
369 "libfec",
370 "libfec_rs",
371 "libsquashfs_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900372 "libcrypto_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900373 "libavb",
Jiyong Park13eb0532021-02-15 14:13:51 +0900374 "liblp",
375 "libcutils",
376 "libbase",
377 "liblog",
378 "libcrypto_static",
Jiyong Park13eb0532021-02-15 14:13:51 +0900379 "libselinux",
380 "libcap",
381 "libgsi",
Jiyong Park13eb0532021-02-15 14:13:51 +0900382 "liblzma",
383 "libunwindstack_no_dex",
Jiyong Park13eb0532021-02-15 14:13:51 +0900384 "libmodprobe",
385 "libext2_uuid",
386 "libprotobuf-cpp-lite",
387 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700388 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800389 "libzstd",
Jiyong Park13eb0532021-02-15 14:13:51 +0900390 "libsnapshot_init",
391 "update_metadata-protos",
David Anderson9fd88622021-03-05 14:10:55 -0800392 "libprocinfo",
David Anderson6f451a92024-10-02 19:35:21 -0700393 "libbootloader_message",
Jiyong Park13eb0532021-02-15 14:13:51 +0900394 ],
395
396 static_executable: true,
Inseob Kim74182522021-06-11 12:58:53 +0900397 system_shared_libs: [],
Jiyong Park13eb0532021-02-15 14:13:51 +0900398
399 cflags: [
400 "-Wall",
401 "-Wextra",
402 "-Wno-unused-parameter",
403 "-Werror",
404 "-DALLOW_FIRST_STAGE_CONSOLE=0",
405 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
406 "-DALLOW_PERMISSIVE_SELINUX=0",
407 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
408 "-DWORLD_WRITABLE_KMSG=0",
409 "-DDUMP_ON_UMOUNT_FAILURE=0",
410 "-DSHUTDOWN_ZERO_TIMEOUT=0",
411 "-DLOG_UEVENTS=0",
412 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
413 ],
414
415 product_variables: {
416 debuggable: {
417 cflags: [
418 "-UALLOW_FIRST_STAGE_CONSOLE",
419 "-DALLOW_FIRST_STAGE_CONSOLE=1",
420
421 "-UALLOW_LOCAL_PROP_OVERRIDE",
422 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
423
424 "-UALLOW_PERMISSIVE_SELINUX",
425 "-DALLOW_PERMISSIVE_SELINUX=1",
426
427 "-UREBOOT_BOOTLOADER_ON_PANIC",
428 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
429
430 "-UWORLD_WRITABLE_KMSG",
431 "-DWORLD_WRITABLE_KMSG=1",
432
433 "-UDUMP_ON_UMOUNT_FAILURE",
434 "-DDUMP_ON_UMOUNT_FAILURE=1",
435 ],
436 },
437
438 eng: {
439 cflags: [
440 "-USHUTDOWN_ZERO_TIMEOUT",
441 "-DSHUTDOWN_ZERO_TIMEOUT=1",
442 ],
443 },
444 },
445
446 sanitize: {
447 misc_undefined: ["signed-integer-overflow"],
Inseob Kim74182522021-06-11 12:58:53 +0900448
449 // First stage init is weird: it may start without stdout/stderr, and no /proc.
Jiyong Park13eb0532021-02-15 14:13:51 +0900450 hwaddress: false,
Florian Mayerc2eaac52024-03-27 14:30:13 -0700451 memtag_stack: false,
Jiyong Park13eb0532021-02-15 14:13:51 +0900452 },
Inseob Kim74182522021-06-11 12:58:53 +0900453
454 // Install adb_debug.prop into debug ramdisk.
455 // This allows adb root on a user build, when debug ramdisk is used.
456 required: ["adb_debug.prop"],
457
458 ramdisk: true,
459
460 install_in_root: true,
461}
462
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100463cc_binary {
464 name: "init_first_stage",
465 defaults: ["init_first_stage_defaults"],
466}
467
468cc_binary {
469 name: "init_first_stage.microdroid",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000470 defaults: [
471 "avf_build_flags_cc",
Nikita Ioffe1e114e62024-03-05 00:23:31 +0000472 "init_first_stage_defaults",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000473 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100474 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900475 no_full_install: true,
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100476}
477
Inseob Kim74182522021-06-11 12:58:53 +0900478phony {
479 name: "init_system",
480 required: ["init_second_stage"],
Jiyong Park13eb0532021-02-15 14:13:51 +0900481}
482
Tom Cherry14fc0132017-05-09 17:11:57 -0700483// Tests
484// ------------------------------------------------------------------------------
485
486cc_test {
Jiyong Park75070b32024-01-30 10:17:37 +0900487 // Note: This is NOT a CTS test. See b/320800872
Tom Cherry17b2be02019-08-20 10:43:48 -0700488 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700489 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700490 require_root: true,
491
David Andersoncbd082d2022-12-06 20:11:40 -0800492 compile_multilib: "first",
Tom Cherry17b2be02019-08-20 10:43:48 -0700493
Tom Cherry14fc0132017-05-09 17:11:57 -0700494 srcs: [
495 "devices_test.cpp",
David Anderson1de73842021-05-13 20:18:14 -0700496 "epoll_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700497 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700498 "init_test.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -0700499 "interprocess_fifo_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700500 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800501 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700502 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700503 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800504 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000505 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700506 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700507 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700508 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700509 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700510 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700511 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700512 "util_test.cpp",
513 ],
Bart Van Assche1693f422022-10-19 16:30:15 -0700514 static_libs: [
515 "libgmock",
516 "libinit",
517 ],
Tom Cherry17b2be02019-08-20 10:43:48 -0700518
519 test_suites: [
Tom Cherry17b2be02019-08-20 10:43:48 -0700520 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700521 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700522}
523
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700524cc_benchmark {
525 name: "init_benchmarks",
526 defaults: ["init_defaults"],
527 srcs: [
528 "subcontext_benchmark.cpp",
529 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800530 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700531}
532
Tom Cherrya2f91362020-02-20 10:50:00 -0800533cc_defaults {
534 name: "libinit_test_utils_libraries_defaults",
535 shared_libs: [
536 "libbase",
537 "libcutils",
538 "libselinux",
Tom Cherrya2f91362020-02-20 10:50:00 -0800539 "liblog",
540 "libprocessgroup",
541 "libprotobuf-cpp-lite",
542 ],
Steven Moreland973aade2023-03-15 19:39:15 +0000543 static_libs: [
Yi-Yo Chiangb8c23252023-07-25 22:08:55 +0800544 "libfs_mgr",
Steven Moreland973aade2023-03-15 19:39:15 +0000545 "libhidl-gen-utils",
546 ],
Tom Cherrya2f91362020-02-20 10:50:00 -0800547}
548
549cc_library_static {
550 name: "libinit_test_utils",
551 defaults: ["libinit_test_utils_libraries_defaults"],
552 cflags: [
553 "-Wall",
554 "-Wextra",
555 "-Wno-unused-parameter",
556 "-Werror",
557 ],
558 srcs: init_common_sources + [
559 "test_utils/service_utils.cpp",
560 ],
561 whole_static_libs: [
562 "libcap",
563 ],
564 export_include_dirs: ["test_utils/include"], // for tests
Florian Mayerd705c2d2022-09-12 18:19:47 -0700565 header_libs: ["bionic_libc_platform_headers"],
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000566 product_variables: {
567 shipping_api_level: {
568 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
569 },
570 },
Tom Cherrya2f91362020-02-20 10:50:00 -0800571}
572
Tom Cherryde6bd502018-02-13 16:50:08 -0800573// Host Verifier
574// ------------------------------------------------------------------------------
575
576genrule {
577 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700578 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800579 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700580 srcs: [
581 "builtins.cpp",
582 "check_builtins.cpp",
583 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700584 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800585}
586
Daniel Normanf1200fb2022-03-09 10:49:26 -0800587cc_defaults {
588 name: "init_host_defaults",
Tom Cherryde6bd502018-02-13 16:50:08 -0800589 host_supported: true,
Tom Cherryde6bd502018-02-13 16:50:08 -0800590 cflags: [
591 "-Wall",
592 "-Wextra",
593 "-Wno-unused-parameter",
594 "-Werror",
595 ],
596 static_libs: [
597 "libbase",
598 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800599 "libpropertyinfoserializer",
600 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800601 ],
602 whole_static_libs: ["libcap"],
603 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800604 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700605 "liblog",
606 "libprocessgroup",
607 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800608 ],
Tom Cherryde6bd502018-02-13 16:50:08 -0800609 proto: {
610 type: "lite",
611 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800612 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800613 android: {
614 enabled: false,
615 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800616 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000617 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800618 },
619 },
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000620 product_variables: {
621 shipping_api_level: {
622 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
623 },
624 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800625}
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700626
Daniel Normanf1200fb2022-03-09 10:49:26 -0800627cc_binary {
628 name: "host_init_verifier",
629 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900630 srcs: [
631 "check_builtins.cpp",
632 "host_import_parser.cpp",
633 "host_init_verifier.cpp",
634 "interface_utils.cpp",
635 ] + init_common_sources,
Jooyung Han18407b72024-02-24 09:16:35 +0900636 generated_headers: [
637 "generated_android_ids",
Jooyung Han9b4ad172024-08-27 13:07:58 +0900638 "generated_stub_builtin_function_map",
Jooyung Han18407b72024-02-24 09:16:35 +0900639 ],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900640 shared_libs: [
641 "libhidl-gen-utils",
642 "libhidlmetadata",
643 ],
644}
645
646genrule {
647 name: "noop_builtin_function_map",
648 tool_files: ["host_builtin_map.py"],
649 out: ["noop_builtin_function_map.h"],
650 srcs: [
651 "builtins.cpp",
652 "noop_builtins.cpp",
653 ],
654 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location noop_builtins.cpp) > $(out)",
Daniel Normanf1200fb2022-03-09 10:49:26 -0800655}
656
657cc_library_host_static {
658 name: "libinit_host",
659 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900660 srcs: [
661 "noop_builtins.cpp",
662 ] + init_common_sources,
Daniel Normanf1200fb2022-03-09 10:49:26 -0800663 export_include_dirs: ["."],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900664 generated_headers: [
665 "noop_builtin_function_map",
666 ],
Daniel Normanf1200fb2022-03-09 10:49:26 -0800667 proto: {
668 export_proto_headers: true,
669 },
670 visibility: [
671 // host_apex_verifier performs a subset of init.rc validation
672 "//system/apex/tools",
673 ],
674}
675
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700676sh_binary {
Cole Faust7e279e92022-09-05 18:12:42 -0700677 name: "extra_free_kbytes",
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700678 src: "extra_free_kbytes.sh",
Cole Faust7e279e92022-09-05 18:12:42 -0700679 filename_from_src: true,
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700680}
Nelson Li064ac0b2024-06-17 05:02:56 +0000681
Nelson Lic2970dd2024-06-19 02:14:23 +0000682phony {
Nelson Li064ac0b2024-06-17 05:02:56 +0000683 name: "init_vendor",
Nelson Lic2970dd2024-06-19 02:14:23 +0000684 required: select(soong_config_variable("ANDROID", "BOARD_USES_RECOVERY_AS_BOOT"), {
685 true: [],
686 default: ["init_first_stage"],
687 }),
Nelson Li064ac0b2024-06-17 05:02:56 +0000688}