blob: 7b7a856e91ee2f18b7a11958cd1e3b8250f8f21f [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",
41 "interface_utils.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -070042 "interprocess_fifo.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080043 "keychords.cpp",
44 "parser.cpp",
45 "property_type.cpp",
46 "rlimit_parser.cpp",
47 "service.cpp",
48 "service_list.cpp",
49 "service_parser.cpp",
50 "service_utils.cpp",
51 "subcontext.cpp",
52 "subcontext.proto",
53 "tokenizer.cpp",
54 "util.cpp",
55]
56init_device_sources = [
Deyao Ren238e9092022-07-21 23:05:13 +000057 "apex_init_util.cpp",
David Anderson41175592020-03-20 19:38:28 -070058 "block_dev_initializer.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080059 "bootchart.cpp",
60 "builtins.cpp",
61 "devices.cpp",
62 "firmware_handler.cpp",
Steve Mucklea4bf2ce2019-11-01 13:58:02 -070063 "first_stage_console.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080064 "first_stage_init.cpp",
65 "first_stage_mount.cpp",
66 "fscrypt_init_extensions.cpp",
67 "init.cpp",
68 "lmkd_service.cpp",
69 "modalias_handler.cpp",
70 "mount_handler.cpp",
71 "mount_namespace.cpp",
72 "persistent_properties.cpp",
73 "persistent_properties.proto",
74 "property_service.cpp",
75 "property_service.proto",
76 "reboot.cpp",
77 "reboot_utils.cpp",
78 "security.cpp",
79 "selabel.cpp",
80 "selinux.cpp",
81 "sigchld_handler.cpp",
David Anderson491e4da2020-12-08 00:21:20 -080082 "snapuserd_transition.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080083 "switch_root.cpp",
84 "uevent_listener.cpp",
85 "ueventd.cpp",
86 "ueventd_parser.cpp",
87]
88init_host_sources = [
89 "check_builtins.cpp",
90 "host_import_parser.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080091]
92
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +000093soong_config_module_type {
94 name: "libinit_cc_defaults",
95 module_type: "cc_defaults",
96 config_namespace: "ANDROID",
97 bool_variables: [
98 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
Nate Myrenb9e05452024-05-28 23:40:59 +000099 "release_write_appcompat_override_system_properties",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000100 ],
101 properties: [
102 "cflags",
103 ],
104}
105
106libinit_cc_defaults {
Tom Cherry14fc0132017-05-09 17:11:57 -0700107 name: "init_defaults",
Tom Cherry14fc0132017-05-09 17:11:57 -0700108 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -0700109 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700110 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -0700111 cflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700112 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -0700113 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
114 "-DALLOW_PERMISSIVE_SELINUX=0",
Bart Van Asscheaee2ec82022-12-02 18:48:15 -0800115 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Tom Cherry14fc0132017-05-09 17:11:57 -0700116 "-DDUMP_ON_UMOUNT_FAILURE=0",
Tom Cherrya2f91362020-02-20 10:50:00 -0800117 "-DINIT_FULL_SOURCES",
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000118 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=0",
Bart Van Assche91ba2192022-12-02 18:48:48 -0800119 "-DLOG_UEVENTS=0",
120 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
121 "-DSHUTDOWN_ZERO_TIMEOUT=0",
122 "-DWORLD_WRITABLE_KMSG=0",
123 "-Wall",
124 "-Werror",
125 "-Wextra",
126 "-Wno-unused-parameter",
127 "-Wthread-safety",
Tom Cherry14fc0132017-05-09 17:11:57 -0700128 ],
129 product_variables: {
130 debuggable: {
131 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -0700132 "-UALLOW_FIRST_STAGE_CONSOLE",
133 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700134 "-UALLOW_LOCAL_PROP_OVERRIDE",
135 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
136 "-UALLOW_PERMISSIVE_SELINUX",
137 "-DALLOW_PERMISSIVE_SELINUX=1",
138 "-UREBOOT_BOOTLOADER_ON_PANIC",
139 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
140 "-UWORLD_WRITABLE_KMSG",
141 "-DWORLD_WRITABLE_KMSG=1",
142 "-UDUMP_ON_UMOUNT_FAILURE",
143 "-DDUMP_ON_UMOUNT_FAILURE=1",
144 ],
145 },
146 eng: {
147 cppflags: [
148 "-USHUTDOWN_ZERO_TIMEOUT",
149 "-DSHUTDOWN_ZERO_TIMEOUT=1",
150 ],
151 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700152 uml: {
153 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800154 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700155 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000156 soong_config_variables: {
157 PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT: {
158 cflags: [
159 "-UINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT",
160 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=1",
161 ],
162 },
Nate Myrenb9e05452024-05-28 23:40:59 +0000163 release_write_appcompat_override_system_properties: {
164 cflags: ["-DWRITE_APPCOMPAT_OVERRIDE_SYSTEM_PROPERTIES"],
Nelson Li064ac0b2024-06-17 05:02:56 +0000165 },
Yi-Yo Chiangbb77c542021-09-23 14:14:16 +0000166 },
Tom Cherry618d3102018-01-19 14:25:48 -0800167 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800168 "libavb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000169 "libavf_cc_flags",
David Anderson12e53bc2022-10-03 21:37:12 -0700170 "libbootloader_message",
Yifan Hongd8ce1fb2019-03-22 17:21:58 -0700171 "libcgrouprc_format",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700172 "liblmkd_utils",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700173 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800174 "libzstd",
Steve Muckle18b981e2019-04-15 17:43:02 -0700175 "libmodprobe",
David Anderson9fd88622021-03-05 14:10:55 -0800176 "libprocinfo",
Tom Cherry618d3102018-01-19 14:25:48 -0800177 "libprotobuf-cpp-lite",
178 "libpropertyinfoserializer",
179 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700180 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700181 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900182 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900183 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700184 "update_metadata-protos",
Jiyong Park787322c2018-06-01 19:26:42 +0900185 ],
186 shared_libs: [
Jiyong Park787322c2018-06-01 19:26:42 +0900187 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700188 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900189 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700190 "libext4_utils",
191 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800192 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700193 "libhidl-gen-utils",
Tao Bao66209ca2018-07-25 22:35:45 -0700194 "liblog",
195 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800196 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800197 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800198 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900199 "libselinux",
Christopher Ferrisd2bd6c52022-05-11 14:42:38 -0700200 "libunwindstack",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200201 "libutils",
Justin Yun6bc1bfe2024-01-10 13:47:02 +0900202 "libvendorsupport",
Tom Cherry618d3102018-01-19 14:25:48 -0800203 ],
Florian Mayerd705c2d2022-09-12 18:19:47 -0700204 header_libs: ["bionic_libc_platform_headers"],
Jiyong Park93318d42018-12-26 17:34:39 +0900205 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700206 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700207}
208
Devendra Singhi1df957b2022-02-15 21:52:55 +0530209cc_library_headers {
210 name: "libinit_headers",
211 export_include_dirs: ["."],
212 visibility: [":__subpackages__"],
213}
214
Nikita Ioffea66adf42023-06-26 14:55:31 +0100215cc_defaults {
216 name: "libinit_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700217 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700218 defaults: [
219 "init_defaults",
220 "selinux_policy_version",
221 ],
Tom Cherry66196492020-02-06 11:56:58 -0800222 srcs: init_common_sources + init_device_sources,
Deyao Ren07595e12022-07-15 22:02:14 +0000223 export_include_dirs: ["."],
Jooyung Han1d951b72020-07-05 03:33:36 +0900224 generated_sources: [
225 "apex-info-list",
226 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700227 whole_static_libs: [
228 "libcap",
Trevor Radcliffefcfd7252022-06-08 14:19:45 +0000229 "libcom.android.sysprop.init",
Daniel Norman8082ba22019-07-23 10:26:15 -0700230 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700231 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700232 proto: {
233 type: "lite",
234 export_proto_headers: true,
235 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200236
237 target: {
238 recovery: {
239 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900240 exclude_static_libs: [
241 "libxml2",
242 ],
243 exclude_generated_sources: [
244 "apex-info-list",
245 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700246 exclude_shared_libs: [
247 "libbinder",
248 "libutils",
249 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200250 },
251 },
Nikita Ioffea66adf42023-06-26 14:55:31 +0100252}
253
254cc_library_static {
255 name: "libinit",
256 defaults: ["libinit_defaults"],
257}
258
259cc_library_static {
260 name: "libinit.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000261 defaults: [
262 "avf_build_flags_cc",
263 "libinit_defaults",
264 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900265 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100266 cflags: ["-DMICRODROID=1"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700267}
268
Steven Morelandceb36d02019-07-15 15:12:56 -0700269phony {
270 name: "init",
271 required: [
272 "init_second_stage",
273 ],
274}
275
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100276cc_defaults {
277 name: "init_second_stage_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700278 recovery_available: true,
279 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700280 defaults: ["init_defaults"],
Tom Cherry618d3102018-01-19 14:25:48 -0800281 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700282 symlinks: ["ueventd"],
Jiyong Park12c64a72024-04-17 14:15:49 +0900283}
284
285cc_binary {
286 name: "init_second_stage",
287 defaults: ["init_second_stage_defaults"],
288 static_libs: ["libinit"],
289 visibility: ["//visibility:any_system_partition"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200290 target: {
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800291 platform: {
292 required: [
293 "init.rc",
294 "ueventd.rc",
295 "e2fsdroid",
Cole Faust7e279e92022-09-05 18:12:42 -0700296 "extra_free_kbytes",
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800297 "make_f2fs",
298 "mke2fs",
299 "sload_f2fs",
300 ],
301 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200302 recovery: {
303 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900304 exclude_static_libs: [
305 "libxml2",
306 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700307 exclude_shared_libs: [
308 "libbinder",
309 "libutils",
310 ],
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800311 required: [
312 "init_recovery.rc",
313 "ueventd.rc.recovery",
314 "e2fsdroid.recovery",
315 "make_f2fs.recovery",
316 "mke2fs.recovery",
317 "sload_f2fs.recovery",
318 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200319 },
320 },
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100321}
322
323cc_binary {
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100324 name: "init_second_stage.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000325 defaults: [
326 "avf_build_flags_cc",
327 "init_second_stage_defaults",
328 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900329 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100330 static_libs: ["libinit.microdroid"],
331 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900332 no_full_install: true,
Jiyong Park90353782021-01-25 18:41:40 +0900333 visibility: ["//packages/modules/Virtualization/microdroid"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700334}
Tom Cherry14fc0132017-05-09 17:11:57 -0700335
Inseob Kim74182522021-06-11 12:58:53 +0900336soong_config_module_type {
337 name: "init_first_stage_cc_defaults",
338 module_type: "cc_defaults",
339 config_namespace: "ANDROID",
Yi-Yo Chiangddc97632022-10-07 21:15:03 +0800340 bool_variables: ["BOARD_USES_RECOVERY_AS_BOOT"],
Inseob Kim74182522021-06-11 12:58:53 +0900341 properties: ["installable"],
342}
343
344// Do not install init_first_stage even with mma if we're system-as-root.
345// Otherwise, it will overwrite the symlink.
346init_first_stage_cc_defaults {
347 name: "init_first_stage_defaults",
348 soong_config_variables: {
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800349 BOARD_USES_RECOVERY_AS_BOOT: {
350 installable: false,
351 },
Inseob Kim74182522021-06-11 12:58:53 +0900352 },
Inseob Kim74182522021-06-11 12:58:53 +0900353
Inseob Kim74182522021-06-11 12:58:53 +0900354 stem: "init",
Jiyong Park13eb0532021-02-15 14:13:51 +0900355
356 srcs: [
357 "block_dev_initializer.cpp",
358 "devices.cpp",
359 "first_stage_console.cpp",
360 "first_stage_init.cpp",
361 "first_stage_main.cpp",
362 "first_stage_mount.cpp",
363 "reboot_utils.cpp",
364 "selabel.cpp",
Jiyong Park13eb0532021-02-15 14:13:51 +0900365 "service_utils.cpp",
366 "snapuserd_transition.cpp",
367 "switch_root.cpp",
368 "uevent_listener.cpp",
369 "util.cpp",
370 ],
371
372 static_libs: [
Jiyong Park13eb0532021-02-15 14:13:51 +0900373 "libfs_avb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000374 "libavf_cc_flags",
Jiyong Park13eb0532021-02-15 14:13:51 +0900375 "libfs_mgr",
376 "libfec",
377 "libfec_rs",
378 "libsquashfs_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900379 "libcrypto_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900380 "libavb",
Jiyong Park13eb0532021-02-15 14:13:51 +0900381 "liblp",
382 "libcutils",
383 "libbase",
384 "liblog",
385 "libcrypto_static",
Jiyong Park13eb0532021-02-15 14:13:51 +0900386 "libselinux",
387 "libcap",
388 "libgsi",
Jiyong Park13eb0532021-02-15 14:13:51 +0900389 "liblzma",
390 "libunwindstack_no_dex",
Jiyong Park13eb0532021-02-15 14:13:51 +0900391 "libmodprobe",
392 "libext2_uuid",
393 "libprotobuf-cpp-lite",
394 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700395 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800396 "libzstd",
Jiyong Park13eb0532021-02-15 14:13:51 +0900397 "libsnapshot_init",
398 "update_metadata-protos",
David Anderson9fd88622021-03-05 14:10:55 -0800399 "libprocinfo",
Jiyong Park13eb0532021-02-15 14:13:51 +0900400 ],
401
402 static_executable: true,
Inseob Kim74182522021-06-11 12:58:53 +0900403 system_shared_libs: [],
Jiyong Park13eb0532021-02-15 14:13:51 +0900404
405 cflags: [
406 "-Wall",
407 "-Wextra",
408 "-Wno-unused-parameter",
409 "-Werror",
410 "-DALLOW_FIRST_STAGE_CONSOLE=0",
411 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
412 "-DALLOW_PERMISSIVE_SELINUX=0",
413 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
414 "-DWORLD_WRITABLE_KMSG=0",
415 "-DDUMP_ON_UMOUNT_FAILURE=0",
416 "-DSHUTDOWN_ZERO_TIMEOUT=0",
417 "-DLOG_UEVENTS=0",
418 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
419 ],
420
421 product_variables: {
422 debuggable: {
423 cflags: [
424 "-UALLOW_FIRST_STAGE_CONSOLE",
425 "-DALLOW_FIRST_STAGE_CONSOLE=1",
426
427 "-UALLOW_LOCAL_PROP_OVERRIDE",
428 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
429
430 "-UALLOW_PERMISSIVE_SELINUX",
431 "-DALLOW_PERMISSIVE_SELINUX=1",
432
433 "-UREBOOT_BOOTLOADER_ON_PANIC",
434 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
435
436 "-UWORLD_WRITABLE_KMSG",
437 "-DWORLD_WRITABLE_KMSG=1",
438
439 "-UDUMP_ON_UMOUNT_FAILURE",
440 "-DDUMP_ON_UMOUNT_FAILURE=1",
441 ],
442 },
443
444 eng: {
445 cflags: [
446 "-USHUTDOWN_ZERO_TIMEOUT",
447 "-DSHUTDOWN_ZERO_TIMEOUT=1",
448 ],
449 },
450 },
451
452 sanitize: {
453 misc_undefined: ["signed-integer-overflow"],
Inseob Kim74182522021-06-11 12:58:53 +0900454
455 // First stage init is weird: it may start without stdout/stderr, and no /proc.
Jiyong Park13eb0532021-02-15 14:13:51 +0900456 hwaddress: false,
Florian Mayerc2eaac52024-03-27 14:30:13 -0700457 memtag_stack: false,
Jiyong Park13eb0532021-02-15 14:13:51 +0900458 },
Inseob Kim74182522021-06-11 12:58:53 +0900459
460 // Install adb_debug.prop into debug ramdisk.
461 // This allows adb root on a user build, when debug ramdisk is used.
462 required: ["adb_debug.prop"],
463
464 ramdisk: true,
465
466 install_in_root: true,
467}
468
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100469cc_binary {
470 name: "init_first_stage",
471 defaults: ["init_first_stage_defaults"],
472}
473
474cc_binary {
475 name: "init_first_stage.microdroid",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000476 defaults: [
477 "avf_build_flags_cc",
Nikita Ioffe1e114e62024-03-05 00:23:31 +0000478 "init_first_stage_defaults",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000479 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100480 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900481 no_full_install: true,
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100482}
483
Inseob Kim74182522021-06-11 12:58:53 +0900484phony {
485 name: "init_system",
486 required: ["init_second_stage"],
Jiyong Park13eb0532021-02-15 14:13:51 +0900487}
488
Tom Cherry14fc0132017-05-09 17:11:57 -0700489// Tests
490// ------------------------------------------------------------------------------
491
492cc_test {
Jiyong Park75070b32024-01-30 10:17:37 +0900493 // Note: This is NOT a CTS test. See b/320800872
Tom Cherry17b2be02019-08-20 10:43:48 -0700494 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700495 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700496 require_root: true,
497
David Andersoncbd082d2022-12-06 20:11:40 -0800498 compile_multilib: "first",
Tom Cherry17b2be02019-08-20 10:43:48 -0700499
Tom Cherry14fc0132017-05-09 17:11:57 -0700500 srcs: [
501 "devices_test.cpp",
David Anderson1de73842021-05-13 20:18:14 -0700502 "epoll_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700503 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700504 "init_test.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -0700505 "interprocess_fifo_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700506 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800507 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700508 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700509 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800510 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000511 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700512 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700513 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700514 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700515 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700516 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700517 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700518 "util_test.cpp",
519 ],
Bart Van Assche1693f422022-10-19 16:30:15 -0700520 static_libs: [
521 "libgmock",
522 "libinit",
523 ],
Tom Cherry17b2be02019-08-20 10:43:48 -0700524
525 test_suites: [
Tom Cherry17b2be02019-08-20 10:43:48 -0700526 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700527 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700528}
529
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700530cc_benchmark {
531 name: "init_benchmarks",
532 defaults: ["init_defaults"],
533 srcs: [
534 "subcontext_benchmark.cpp",
535 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800536 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700537}
538
Tom Cherrya2f91362020-02-20 10:50:00 -0800539cc_defaults {
540 name: "libinit_test_utils_libraries_defaults",
541 shared_libs: [
542 "libbase",
543 "libcutils",
544 "libselinux",
Tom Cherrya2f91362020-02-20 10:50:00 -0800545 "liblog",
546 "libprocessgroup",
547 "libprotobuf-cpp-lite",
548 ],
Steven Moreland973aade2023-03-15 19:39:15 +0000549 static_libs: [
Yi-Yo Chiangb8c23252023-07-25 22:08:55 +0800550 "libfs_mgr",
Steven Moreland973aade2023-03-15 19:39:15 +0000551 "libhidl-gen-utils",
552 ],
Tom Cherrya2f91362020-02-20 10:50:00 -0800553}
554
555cc_library_static {
556 name: "libinit_test_utils",
557 defaults: ["libinit_test_utils_libraries_defaults"],
558 cflags: [
559 "-Wall",
560 "-Wextra",
561 "-Wno-unused-parameter",
562 "-Werror",
563 ],
564 srcs: init_common_sources + [
565 "test_utils/service_utils.cpp",
566 ],
567 whole_static_libs: [
568 "libcap",
569 ],
570 export_include_dirs: ["test_utils/include"], // for tests
Florian Mayerd705c2d2022-09-12 18:19:47 -0700571 header_libs: ["bionic_libc_platform_headers"],
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000572 product_variables: {
573 shipping_api_level: {
574 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
575 },
576 },
Tom Cherrya2f91362020-02-20 10:50:00 -0800577}
578
Tom Cherryde6bd502018-02-13 16:50:08 -0800579// Host Verifier
580// ------------------------------------------------------------------------------
581
582genrule {
583 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700584 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800585 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700586 srcs: [
587 "builtins.cpp",
588 "check_builtins.cpp",
589 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700590 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800591}
592
Daniel Normanf1200fb2022-03-09 10:49:26 -0800593cc_defaults {
594 name: "init_host_defaults",
Tom Cherryde6bd502018-02-13 16:50:08 -0800595 host_supported: true,
Tom Cherryde6bd502018-02-13 16:50:08 -0800596 cflags: [
597 "-Wall",
598 "-Wextra",
599 "-Wno-unused-parameter",
600 "-Werror",
601 ],
602 static_libs: [
603 "libbase",
604 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800605 "libpropertyinfoserializer",
606 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800607 ],
608 whole_static_libs: ["libcap"],
609 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800610 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700611 "libhidl-gen-utils",
Steven Moreland422a7582019-10-15 14:53:19 -0700612 "libhidlmetadata",
Daniel Norman3f42a762019-07-09 11:00:53 -0700613 "liblog",
614 "libprocessgroup",
615 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800616 ],
Tom Cherryde6bd502018-02-13 16:50:08 -0800617 proto: {
618 type: "lite",
619 },
Yifan Hong3c4aa112018-06-20 22:49:48 +0000620 generated_headers: [
621 "generated_stub_builtin_function_map",
Yifan Hong3c4aa112018-06-20 22:49:48 +0000622 ],
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800623 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800624 android: {
625 enabled: false,
626 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800627 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000628 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800629 },
630 },
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000631 product_variables: {
632 shipping_api_level: {
633 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
634 },
635 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800636}
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700637
Daniel Normanf1200fb2022-03-09 10:49:26 -0800638cc_binary {
639 name: "host_init_verifier",
640 defaults: ["init_host_defaults"],
Jooyung Han39e8be42024-02-16 17:23:34 +0900641 srcs: ["host_init_verifier.cpp"] + init_common_sources + init_host_sources,
Jooyung Han18407b72024-02-24 09:16:35 +0900642 generated_headers: [
643 "generated_android_ids",
644 ],
Daniel Normanf1200fb2022-03-09 10:49:26 -0800645}
646
647cc_library_host_static {
648 name: "libinit_host",
649 defaults: ["init_host_defaults"],
Jooyung Han39e8be42024-02-16 17:23:34 +0900650 srcs: init_common_sources + init_host_sources,
Daniel Normanf1200fb2022-03-09 10:49:26 -0800651 export_include_dirs: ["."],
652 proto: {
653 export_proto_headers: true,
654 },
655 visibility: [
656 // host_apex_verifier performs a subset of init.rc validation
657 "//system/apex/tools",
658 ],
659}
660
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700661sh_binary {
Cole Faust7e279e92022-09-05 18:12:42 -0700662 name: "extra_free_kbytes",
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700663 src: "extra_free_kbytes.sh",
Cole Faust7e279e92022-09-05 18:12:42 -0700664 filename_from_src: true,
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700665}
Nelson Li064ac0b2024-06-17 05:02:56 +0000666
Nelson Lic2970dd2024-06-19 02:14:23 +0000667phony {
Nelson Li064ac0b2024-06-17 05:02:56 +0000668 name: "init_vendor",
Nelson Lic2970dd2024-06-19 02:14:23 +0000669 required: select(soong_config_variable("ANDROID", "BOARD_USES_RECOVERY_AS_BOOT"), {
670 true: [],
671 default: ["init_first_stage"],
672 }),
Nelson Li064ac0b2024-06-17 05:02:56 +0000673}