blob: 8da2e7c2eaf4ae546bba1f99340e42e02b294070 [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",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700166 "liblmkd_utils",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700167 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800168 "libzstd",
Steve Muckle18b981e2019-04-15 17:43:02 -0700169 "libmodprobe",
David Anderson9fd88622021-03-05 14:10:55 -0800170 "libprocinfo",
Tom Cherry618d3102018-01-19 14:25:48 -0800171 "libprotobuf-cpp-lite",
172 "libpropertyinfoserializer",
173 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700174 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700175 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900176 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900177 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700178 "update_metadata-protos",
Jiyong Park787322c2018-06-01 19:26:42 +0900179 ],
180 shared_libs: [
Jiyong Park787322c2018-06-01 19:26:42 +0900181 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700182 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900183 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700184 "libext4_utils",
185 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800186 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700187 "liblog",
188 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800189 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800190 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800191 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900192 "libselinux",
Christopher Ferrisd2bd6c52022-05-11 14:42:38 -0700193 "libunwindstack",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200194 "libutils",
Justin Yun6bc1bfe2024-01-10 13:47:02 +0900195 "libvendorsupport",
Tom Cherry618d3102018-01-19 14:25:48 -0800196 ],
Florian Mayerd705c2d2022-09-12 18:19:47 -0700197 header_libs: ["bionic_libc_platform_headers"],
Jiyong Park93318d42018-12-26 17:34:39 +0900198 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700199 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700200}
201
Devendra Singhi1df957b2022-02-15 21:52:55 +0530202cc_library_headers {
203 name: "libinit_headers",
204 export_include_dirs: ["."],
205 visibility: [":__subpackages__"],
206}
207
Nikita Ioffea66adf42023-06-26 14:55:31 +0100208cc_defaults {
209 name: "libinit_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700210 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700211 defaults: [
212 "init_defaults",
213 "selinux_policy_version",
214 ],
Tom Cherry66196492020-02-06 11:56:58 -0800215 srcs: init_common_sources + init_device_sources,
Deyao Ren07595e12022-07-15 22:02:14 +0000216 export_include_dirs: ["."],
Jooyung Han1d951b72020-07-05 03:33:36 +0900217 generated_sources: [
218 "apex-info-list",
219 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700220 whole_static_libs: [
221 "libcap",
Daniel Norman8082ba22019-07-23 10:26:15 -0700222 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700223 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700224 proto: {
225 type: "lite",
226 export_proto_headers: true,
227 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200228
229 target: {
230 recovery: {
231 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900232 exclude_static_libs: [
233 "libxml2",
234 ],
235 exclude_generated_sources: [
236 "apex-info-list",
237 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700238 exclude_shared_libs: [
239 "libbinder",
240 "libutils",
241 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200242 },
243 },
Nikita Ioffea66adf42023-06-26 14:55:31 +0100244}
245
246cc_library_static {
247 name: "libinit",
248 defaults: ["libinit_defaults"],
249}
250
251cc_library_static {
252 name: "libinit.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000253 defaults: [
254 "avf_build_flags_cc",
255 "libinit_defaults",
256 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900257 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100258 cflags: ["-DMICRODROID=1"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700259}
260
Steven Morelandceb36d02019-07-15 15:12:56 -0700261phony {
262 name: "init",
263 required: [
264 "init_second_stage",
265 ],
266}
267
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100268cc_defaults {
269 name: "init_second_stage_defaults",
Tom Cherry31438482018-07-20 14:57:00 -0700270 recovery_available: true,
271 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700272 defaults: ["init_defaults"],
Tom Cherry618d3102018-01-19 14:25:48 -0800273 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700274 symlinks: ["ueventd"],
Jiyong Park12c64a72024-04-17 14:15:49 +0900275}
276
277cc_binary {
278 name: "init_second_stage",
279 defaults: ["init_second_stage_defaults"],
280 static_libs: ["libinit"],
281 visibility: ["//visibility:any_system_partition"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200282 target: {
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800283 platform: {
284 required: [
285 "init.rc",
286 "ueventd.rc",
287 "e2fsdroid",
Cole Faust7e279e92022-09-05 18:12:42 -0700288 "extra_free_kbytes",
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800289 "make_f2fs",
290 "mke2fs",
291 "sload_f2fs",
292 ],
293 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200294 recovery: {
295 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900296 exclude_static_libs: [
297 "libxml2",
298 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700299 exclude_shared_libs: [
300 "libbinder",
301 "libutils",
302 ],
Yi-Yo Chiang9ba6a5b2021-07-24 22:50:17 +0800303 required: [
304 "init_recovery.rc",
305 "ueventd.rc.recovery",
306 "e2fsdroid.recovery",
307 "make_f2fs.recovery",
308 "mke2fs.recovery",
309 "sload_f2fs.recovery",
310 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200311 },
312 },
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100313}
314
315cc_binary {
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100316 name: "init_second_stage.microdroid",
Nikita Ioffefeb7e0e2024-03-28 00:32:36 +0000317 defaults: [
318 "avf_build_flags_cc",
319 "init_second_stage_defaults",
320 ],
Jiyong Park12c64a72024-04-17 14:15:49 +0900321 recovery_available: false,
Nikita Ioffea66adf42023-06-26 14:55:31 +0100322 static_libs: ["libinit.microdroid"],
323 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900324 no_full_install: true,
Jiyong Parkd959fc72024-07-22 11:24:03 +0900325 visibility: ["//packages/modules/Virtualization/build/microdroid"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700326}
Tom Cherry14fc0132017-05-09 17:11:57 -0700327
Inseob Kim74182522021-06-11 12:58:53 +0900328soong_config_module_type {
329 name: "init_first_stage_cc_defaults",
330 module_type: "cc_defaults",
331 config_namespace: "ANDROID",
Yi-Yo Chiangddc97632022-10-07 21:15:03 +0800332 bool_variables: ["BOARD_USES_RECOVERY_AS_BOOT"],
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900333 properties: ["no_full_install"],
Inseob Kim74182522021-06-11 12:58:53 +0900334}
335
336// Do not install init_first_stage even with mma if we're system-as-root.
337// Otherwise, it will overwrite the symlink.
338init_first_stage_cc_defaults {
339 name: "init_first_stage_defaults",
340 soong_config_variables: {
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800341 BOARD_USES_RECOVERY_AS_BOOT: {
Jiyong Park0bdd68b2024-07-03 18:41:05 +0900342 no_full_install: true,
Bowgo Tsaiab079af2021-07-14 15:39:53 +0800343 },
Inseob Kim74182522021-06-11 12:58:53 +0900344 },
Inseob Kim74182522021-06-11 12:58:53 +0900345
Inseob Kim74182522021-06-11 12:58:53 +0900346 stem: "init",
Jiyong Park13eb0532021-02-15 14:13:51 +0900347
348 srcs: [
349 "block_dev_initializer.cpp",
350 "devices.cpp",
351 "first_stage_console.cpp",
352 "first_stage_init.cpp",
353 "first_stage_main.cpp",
354 "first_stage_mount.cpp",
355 "reboot_utils.cpp",
356 "selabel.cpp",
Jiyong Park13eb0532021-02-15 14:13:51 +0900357 "service_utils.cpp",
358 "snapuserd_transition.cpp",
359 "switch_root.cpp",
360 "uevent_listener.cpp",
361 "util.cpp",
362 ],
363
364 static_libs: [
Jiyong Park13eb0532021-02-15 14:13:51 +0900365 "libfs_avb",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000366 "libavf_cc_flags",
Jiyong Park13eb0532021-02-15 14:13:51 +0900367 "libfs_mgr",
368 "libfec",
369 "libfec_rs",
370 "libsquashfs_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900371 "libcrypto_utils",
Jiyong Park13eb0532021-02-15 14:13:51 +0900372 "libavb",
Jiyong Park13eb0532021-02-15 14:13:51 +0900373 "liblp",
374 "libcutils",
375 "libbase",
376 "liblog",
377 "libcrypto_static",
Jiyong Park13eb0532021-02-15 14:13:51 +0900378 "libselinux",
379 "libcap",
380 "libgsi",
Jiyong Park13eb0532021-02-15 14:13:51 +0900381 "liblzma",
382 "libunwindstack_no_dex",
Jiyong Park13eb0532021-02-15 14:13:51 +0900383 "libmodprobe",
384 "libext2_uuid",
385 "libprotobuf-cpp-lite",
386 "libsnapshot_cow",
Kelvin Zhang5cb1b022022-04-11 17:29:27 -0700387 "liblz4",
Kelvin Zhang32dcac72023-02-15 16:23:46 -0800388 "libzstd",
Jiyong Park13eb0532021-02-15 14:13:51 +0900389 "libsnapshot_init",
390 "update_metadata-protos",
David Anderson9fd88622021-03-05 14:10:55 -0800391 "libprocinfo",
Jiyong Park13eb0532021-02-15 14:13:51 +0900392 ],
393
394 static_executable: true,
Inseob Kim74182522021-06-11 12:58:53 +0900395 system_shared_libs: [],
Jiyong Park13eb0532021-02-15 14:13:51 +0900396
397 cflags: [
398 "-Wall",
399 "-Wextra",
400 "-Wno-unused-parameter",
401 "-Werror",
402 "-DALLOW_FIRST_STAGE_CONSOLE=0",
403 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
404 "-DALLOW_PERMISSIVE_SELINUX=0",
405 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
406 "-DWORLD_WRITABLE_KMSG=0",
407 "-DDUMP_ON_UMOUNT_FAILURE=0",
408 "-DSHUTDOWN_ZERO_TIMEOUT=0",
409 "-DLOG_UEVENTS=0",
410 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
411 ],
412
413 product_variables: {
414 debuggable: {
415 cflags: [
416 "-UALLOW_FIRST_STAGE_CONSOLE",
417 "-DALLOW_FIRST_STAGE_CONSOLE=1",
418
419 "-UALLOW_LOCAL_PROP_OVERRIDE",
420 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
421
422 "-UALLOW_PERMISSIVE_SELINUX",
423 "-DALLOW_PERMISSIVE_SELINUX=1",
424
425 "-UREBOOT_BOOTLOADER_ON_PANIC",
426 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
427
428 "-UWORLD_WRITABLE_KMSG",
429 "-DWORLD_WRITABLE_KMSG=1",
430
431 "-UDUMP_ON_UMOUNT_FAILURE",
432 "-DDUMP_ON_UMOUNT_FAILURE=1",
433 ],
434 },
435
436 eng: {
437 cflags: [
438 "-USHUTDOWN_ZERO_TIMEOUT",
439 "-DSHUTDOWN_ZERO_TIMEOUT=1",
440 ],
441 },
442 },
443
444 sanitize: {
445 misc_undefined: ["signed-integer-overflow"],
Inseob Kim74182522021-06-11 12:58:53 +0900446
447 // First stage init is weird: it may start without stdout/stderr, and no /proc.
Jiyong Park13eb0532021-02-15 14:13:51 +0900448 hwaddress: false,
Florian Mayerc2eaac52024-03-27 14:30:13 -0700449 memtag_stack: false,
Jiyong Park13eb0532021-02-15 14:13:51 +0900450 },
Inseob Kim74182522021-06-11 12:58:53 +0900451
452 // Install adb_debug.prop into debug ramdisk.
453 // This allows adb root on a user build, when debug ramdisk is used.
454 required: ["adb_debug.prop"],
455
456 ramdisk: true,
457
458 install_in_root: true,
459}
460
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100461cc_binary {
462 name: "init_first_stage",
463 defaults: ["init_first_stage_defaults"],
464}
465
466cc_binary {
467 name: "init_first_stage.microdroid",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000468 defaults: [
469 "avf_build_flags_cc",
Nikita Ioffe1e114e62024-03-05 00:23:31 +0000470 "init_first_stage_defaults",
Nikita Ioffe2384e8a2024-03-12 15:34:11 +0000471 ],
Nikita Ioffea66adf42023-06-26 14:55:31 +0100472 cflags: ["-DMICRODROID=1"],
Jiyong Parkb3302582024-05-01 16:16:42 +0900473 no_full_install: true,
Nikita Ioffe55dd3252023-06-21 16:44:40 +0100474}
475
Inseob Kim74182522021-06-11 12:58:53 +0900476phony {
477 name: "init_system",
478 required: ["init_second_stage"],
Jiyong Park13eb0532021-02-15 14:13:51 +0900479}
480
Tom Cherry14fc0132017-05-09 17:11:57 -0700481// Tests
482// ------------------------------------------------------------------------------
483
484cc_test {
Jiyong Park75070b32024-01-30 10:17:37 +0900485 // Note: This is NOT a CTS test. See b/320800872
Tom Cherry17b2be02019-08-20 10:43:48 -0700486 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700487 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700488 require_root: true,
489
David Andersoncbd082d2022-12-06 20:11:40 -0800490 compile_multilib: "first",
Tom Cherry17b2be02019-08-20 10:43:48 -0700491
Tom Cherry14fc0132017-05-09 17:11:57 -0700492 srcs: [
493 "devices_test.cpp",
David Anderson1de73842021-05-13 20:18:14 -0700494 "epoll_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700495 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700496 "init_test.cpp",
Bart Van Assche1693f422022-10-19 16:30:15 -0700497 "interprocess_fifo_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700498 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800499 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700500 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700501 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800502 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000503 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700504 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700505 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700506 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700507 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700508 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700509 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700510 "util_test.cpp",
511 ],
Bart Van Assche1693f422022-10-19 16:30:15 -0700512 static_libs: [
513 "libgmock",
514 "libinit",
515 ],
Tom Cherry17b2be02019-08-20 10:43:48 -0700516
517 test_suites: [
Tom Cherry17b2be02019-08-20 10:43:48 -0700518 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700519 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700520}
521
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700522cc_benchmark {
523 name: "init_benchmarks",
524 defaults: ["init_defaults"],
525 srcs: [
526 "subcontext_benchmark.cpp",
527 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800528 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700529}
530
Tom Cherrya2f91362020-02-20 10:50:00 -0800531cc_defaults {
532 name: "libinit_test_utils_libraries_defaults",
533 shared_libs: [
534 "libbase",
535 "libcutils",
536 "libselinux",
Tom Cherrya2f91362020-02-20 10:50:00 -0800537 "liblog",
538 "libprocessgroup",
539 "libprotobuf-cpp-lite",
540 ],
Steven Moreland973aade2023-03-15 19:39:15 +0000541 static_libs: [
Yi-Yo Chiangb8c23252023-07-25 22:08:55 +0800542 "libfs_mgr",
Steven Moreland973aade2023-03-15 19:39:15 +0000543 "libhidl-gen-utils",
544 ],
Tom Cherrya2f91362020-02-20 10:50:00 -0800545}
546
547cc_library_static {
548 name: "libinit_test_utils",
549 defaults: ["libinit_test_utils_libraries_defaults"],
550 cflags: [
551 "-Wall",
552 "-Wextra",
553 "-Wno-unused-parameter",
554 "-Werror",
555 ],
556 srcs: init_common_sources + [
557 "test_utils/service_utils.cpp",
558 ],
559 whole_static_libs: [
560 "libcap",
561 ],
562 export_include_dirs: ["test_utils/include"], // for tests
Florian Mayerd705c2d2022-09-12 18:19:47 -0700563 header_libs: ["bionic_libc_platform_headers"],
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000564 product_variables: {
565 shipping_api_level: {
566 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
567 },
568 },
Tom Cherrya2f91362020-02-20 10:50:00 -0800569}
570
Tom Cherryde6bd502018-02-13 16:50:08 -0800571// Host Verifier
572// ------------------------------------------------------------------------------
573
574genrule {
575 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700576 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800577 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700578 srcs: [
579 "builtins.cpp",
580 "check_builtins.cpp",
581 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700582 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800583}
584
Daniel Normanf1200fb2022-03-09 10:49:26 -0800585cc_defaults {
586 name: "init_host_defaults",
Tom Cherryde6bd502018-02-13 16:50:08 -0800587 host_supported: true,
Tom Cherryde6bd502018-02-13 16:50:08 -0800588 cflags: [
589 "-Wall",
590 "-Wextra",
591 "-Wno-unused-parameter",
592 "-Werror",
593 ],
594 static_libs: [
595 "libbase",
596 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800597 "libpropertyinfoserializer",
598 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800599 ],
600 whole_static_libs: ["libcap"],
601 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800602 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700603 "liblog",
604 "libprocessgroup",
605 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800606 ],
Tom Cherryde6bd502018-02-13 16:50:08 -0800607 proto: {
608 type: "lite",
609 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800610 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800611 android: {
612 enabled: false,
613 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800614 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000615 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800616 },
617 },
Steven Moreland81a1b3e2024-05-20 22:31:11 +0000618 product_variables: {
619 shipping_api_level: {
620 cflags: ["-DBUILD_SHIPPING_API_LEVEL=%s"],
621 },
622 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800623}
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700624
Daniel Normanf1200fb2022-03-09 10:49:26 -0800625cc_binary {
626 name: "host_init_verifier",
627 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900628 srcs: [
629 "check_builtins.cpp",
630 "host_import_parser.cpp",
631 "host_init_verifier.cpp",
632 "interface_utils.cpp",
633 ] + init_common_sources,
Jooyung Han18407b72024-02-24 09:16:35 +0900634 generated_headers: [
635 "generated_android_ids",
Jooyung Han9b4ad172024-08-27 13:07:58 +0900636 "generated_stub_builtin_function_map",
Jooyung Han18407b72024-02-24 09:16:35 +0900637 ],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900638 shared_libs: [
639 "libhidl-gen-utils",
640 "libhidlmetadata",
641 ],
642}
643
644genrule {
645 name: "noop_builtin_function_map",
646 tool_files: ["host_builtin_map.py"],
647 out: ["noop_builtin_function_map.h"],
648 srcs: [
649 "builtins.cpp",
650 "noop_builtins.cpp",
651 ],
652 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location noop_builtins.cpp) > $(out)",
Daniel Normanf1200fb2022-03-09 10:49:26 -0800653}
654
655cc_library_host_static {
656 name: "libinit_host",
657 defaults: ["init_host_defaults"],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900658 srcs: [
659 "noop_builtins.cpp",
660 ] + init_common_sources,
Daniel Normanf1200fb2022-03-09 10:49:26 -0800661 export_include_dirs: ["."],
Jooyung Han9b4ad172024-08-27 13:07:58 +0900662 generated_headers: [
663 "noop_builtin_function_map",
664 ],
Daniel Normanf1200fb2022-03-09 10:49:26 -0800665 proto: {
666 export_proto_headers: true,
667 },
668 visibility: [
669 // host_apex_verifier performs a subset of init.rc validation
670 "//system/apex/tools",
671 ],
672}
673
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700674sh_binary {
Cole Faust7e279e92022-09-05 18:12:42 -0700675 name: "extra_free_kbytes",
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700676 src: "extra_free_kbytes.sh",
Cole Faust7e279e92022-09-05 18:12:42 -0700677 filename_from_src: true,
Suren Baghdasaryan642048d2021-06-15 12:28:24 -0700678}
Nelson Li064ac0b2024-06-17 05:02:56 +0000679
Nelson Lic2970dd2024-06-19 02:14:23 +0000680phony {
Nelson Li064ac0b2024-06-17 05:02:56 +0000681 name: "init_vendor",
Nelson Lic2970dd2024-06-19 02:14:23 +0000682 required: select(soong_config_variable("ANDROID", "BOARD_USES_RECOVERY_AS_BOOT"), {
683 true: [],
684 default: ["init_first_stage"],
685 }),
Nelson Li064ac0b2024-06-17 05:02:56 +0000686}