1// 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 17package { 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 34init_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", 42 "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 = [ 56 "block_dev_initializer.cpp", 57 "bootchart.cpp", 58 "builtins.cpp", 59 "devices.cpp", 60 "firmware_handler.cpp", 61 "first_stage_console.cpp", 62 "first_stage_init.cpp", 63 "first_stage_mount.cpp", 64 "fscrypt_init_extensions.cpp", 65 "init.cpp", 66 "lmkd_service.cpp", 67 "modalias_handler.cpp", 68 "mount_handler.cpp", 69 "mount_namespace.cpp", 70 "persistent_properties.cpp", 71 "persistent_properties.proto", 72 "property_service.cpp", 73 "property_service.proto", 74 "reboot.cpp", 75 "reboot_utils.cpp", 76 "security.cpp", 77 "selabel.cpp", 78 "selinux.cpp", 79 "sigchld_handler.cpp", 80 "snapuserd_transition.cpp", 81 "switch_root.cpp", 82 "uevent_listener.cpp", 83 "ueventd.cpp", 84 "ueventd_parser.cpp", 85] 86init_host_sources = [ 87 "check_builtins.cpp", 88 "host_import_parser.cpp", 89 "host_init_verifier.cpp", 90] 91 92soong_config_module_type { 93 name: "libinit_cc_defaults", 94 module_type: "cc_defaults", 95 config_namespace: "ANDROID", 96 bool_variables: [ 97 "PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT", 98 ], 99 properties: [ 100 "cflags", 101 ], 102} 103 104libinit_cc_defaults { 105 name: "init_defaults", 106 sanitize: { 107 misc_undefined: ["signed-integer-overflow"], 108 }, 109 cflags: [ 110 "-DLOG_UEVENTS=0", 111 "-Wall", 112 "-Wextra", 113 "-Wno-unused-parameter", 114 "-Werror", 115 "-Wthread-safety", 116 "-DALLOW_FIRST_STAGE_CONSOLE=0", 117 "-DALLOW_LOCAL_PROP_OVERRIDE=0", 118 "-DALLOW_PERMISSIVE_SELINUX=0", 119 "-DREBOOT_BOOTLOADER_ON_PANIC=0", 120 "-DWORLD_WRITABLE_KMSG=0", 121 "-DDUMP_ON_UMOUNT_FAILURE=0", 122 "-DSHUTDOWN_ZERO_TIMEOUT=0", 123 "-DINIT_FULL_SOURCES", 124 "-DINSTALL_DEBUG_POLICY_TO_SYSTEM_EXT=0", 125 ], 126 product_variables: { 127 debuggable: { 128 cppflags: [ 129 "-UALLOW_FIRST_STAGE_CONSOLE", 130 "-DALLOW_FIRST_STAGE_CONSOLE=1", 131 "-UALLOW_LOCAL_PROP_OVERRIDE", 132 "-DALLOW_LOCAL_PROP_OVERRIDE=1", 133 "-UALLOW_PERMISSIVE_SELINUX", 134 "-DALLOW_PERMISSIVE_SELINUX=1", 135 "-UREBOOT_BOOTLOADER_ON_PANIC", 136 "-DREBOOT_BOOTLOADER_ON_PANIC=1", 137 "-UWORLD_WRITABLE_KMSG", 138 "-DWORLD_WRITABLE_KMSG=1", 139 "-UDUMP_ON_UMOUNT_FAILURE", 140 "-DDUMP_ON_UMOUNT_FAILURE=1", 141 ], 142 }, 143 eng: { 144 cppflags: [ 145 "-USHUTDOWN_ZERO_TIMEOUT", 146 "-DSHUTDOWN_ZERO_TIMEOUT=1", 147 ], 148 }, 149 uml: { 150 cppflags: ["-DUSER_MODE_LINUX"], 151 }, 152 }, 153 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 }, 160 }, 161 static_libs: [ 162 "libavb", 163 "libc++fs", 164 "libcgrouprc_format", 165 "liblmkd_utils", 166 "libmodprobe", 167 "libprocinfo", 168 "libprotobuf-cpp-lite", 169 "libpropertyinfoserializer", 170 "libpropertyinfoparser", 171 "libsnapshot_cow", 172 "libsnapshot_init", 173 "libxml2", 174 "lib_apex_manifest_proto_lite", 175 "update_metadata-protos", 176 ], 177 shared_libs: [ 178 "libbacktrace", 179 "libbase", 180 "libbootloader_message", 181 "libcutils", 182 "libdl", 183 "libext4_utils", 184 "libfs_mgr", 185 "libgsi", 186 "libhidl-gen-utils", 187 "libkeyutils", 188 "liblog", 189 "liblogwrap", 190 "liblp", 191 "libprocessgroup", 192 "libprocessgroup_setup", 193 "libselinux", 194 "libutils", 195 ], 196 bootstrap: true, 197 visibility: [":__subpackages__"], 198} 199 200cc_library_static { 201 name: "libinit", 202 recovery_available: true, 203 defaults: [ 204 "init_defaults", 205 "selinux_policy_version", 206 ], 207 srcs: init_common_sources + init_device_sources, 208 generated_sources: [ 209 "apex-info-list", 210 ], 211 whole_static_libs: [ 212 "libcap", 213 "com.android.sysprop.apex", 214 "com.android.sysprop.init", 215 ], 216 header_libs: ["bootimg_headers"], 217 proto: { 218 type: "lite", 219 export_proto_headers: true, 220 }, 221 222 target: { 223 recovery: { 224 cflags: ["-DRECOVERY"], 225 exclude_static_libs: [ 226 "libxml2", 227 ], 228 exclude_generated_sources: [ 229 "apex-info-list", 230 ], 231 exclude_shared_libs: [ 232 "libbinder", 233 "libutils", 234 ], 235 }, 236 }, 237} 238 239phony { 240 name: "init", 241 required: [ 242 "init_second_stage", 243 ], 244} 245 246cc_binary { 247 name: "init_second_stage", 248 recovery_available: true, 249 stem: "init", 250 defaults: ["init_defaults"], 251 static_libs: ["libinit"], 252 required: [ 253 "e2fsdroid", 254 "init.rc", 255 "mke2fs", 256 "sload_f2fs", 257 "make_f2fs", 258 "ueventd.rc", 259 ], 260 srcs: ["main.cpp"], 261 symlinks: ["ueventd"], 262 target: { 263 recovery: { 264 cflags: ["-DRECOVERY"], 265 exclude_static_libs: [ 266 "libxml2", 267 ], 268 exclude_shared_libs: [ 269 "libbinder", 270 "libutils", 271 ], 272 }, 273 }, 274 visibility: ["//packages/modules/Virtualization/microdroid"], 275} 276 277// This currently is only for the VM usecase. 278// TODO(jiyong): replace init_first_stage in Android.mk with this 279cc_binary { 280 name: "init_first_stage_soong", 281 stem: "init_vendor", 282 283 srcs: [ 284 "block_dev_initializer.cpp", 285 "devices.cpp", 286 "first_stage_console.cpp", 287 "first_stage_init.cpp", 288 "first_stage_main.cpp", 289 "first_stage_mount.cpp", 290 "reboot_utils.cpp", 291 "selabel.cpp", 292 "selinux.cpp", 293 "service_utils.cpp", 294 "snapuserd_transition.cpp", 295 "switch_root.cpp", 296 "uevent_listener.cpp", 297 "util.cpp", 298 ], 299 300 static_libs: [ 301 "libc++fs", 302 "libfs_avb", 303 "libfs_mgr", 304 "libfec", 305 "libfec_rs", 306 "libsquashfs_utils", 307 "liblogwrap", 308 "libext4_utils", 309 "libcrypto_utils", 310 "libsparse", 311 "libavb", 312 "libkeyutils", 313 "liblp", 314 "libcutils", 315 "libbase", 316 "liblog", 317 "libcrypto_static", 318 "libdl", 319 "libz", 320 "libselinux", 321 "libcap", 322 "libgsi", 323 "libcom.android.sysprop.apex", 324 "liblzma", 325 "libunwindstack_no_dex", 326 "libbacktrace_no_dex", 327 "libmodprobe", 328 "libext2_uuid", 329 "libprotobuf-cpp-lite", 330 "libsnapshot_cow", 331 "libsnapshot_init", 332 "update_metadata-protos", 333 "libprocinfo", 334 ], 335 336 static_executable: true, 337 338 cflags: [ 339 "-Wall", 340 "-Wextra", 341 "-Wno-unused-parameter", 342 "-Werror", 343 "-DALLOW_FIRST_STAGE_CONSOLE=0", 344 "-DALLOW_LOCAL_PROP_OVERRIDE=0", 345 "-DALLOW_PERMISSIVE_SELINUX=0", 346 "-DREBOOT_BOOTLOADER_ON_PANIC=0", 347 "-DWORLD_WRITABLE_KMSG=0", 348 "-DDUMP_ON_UMOUNT_FAILURE=0", 349 "-DSHUTDOWN_ZERO_TIMEOUT=0", 350 "-DLOG_UEVENTS=0", 351 "-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number 352 ], 353 354 product_variables: { 355 debuggable: { 356 cflags: [ 357 "-UALLOW_FIRST_STAGE_CONSOLE", 358 "-DALLOW_FIRST_STAGE_CONSOLE=1", 359 360 "-UALLOW_LOCAL_PROP_OVERRIDE", 361 "-DALLOW_LOCAL_PROP_OVERRIDE=1", 362 363 "-UALLOW_PERMISSIVE_SELINUX", 364 "-DALLOW_PERMISSIVE_SELINUX=1", 365 366 "-UREBOOT_BOOTLOADER_ON_PANIC", 367 "-DREBOOT_BOOTLOADER_ON_PANIC=1", 368 369 "-UWORLD_WRITABLE_KMSG", 370 "-DWORLD_WRITABLE_KMSG=1", 371 372 "-UDUMP_ON_UMOUNT_FAILURE", 373 "-DDUMP_ON_UMOUNT_FAILURE=1", 374 ], 375 }, 376 377 eng: { 378 cflags: [ 379 "-USHUTDOWN_ZERO_TIMEOUT", 380 "-DSHUTDOWN_ZERO_TIMEOUT=1", 381 ], 382 }, 383 }, 384 385 sanitize: { 386 misc_undefined: ["signed-integer-overflow"], 387 hwaddress: false, 388 }, 389} 390 391// Tests 392// ------------------------------------------------------------------------------ 393 394cc_test { 395 name: "CtsInitTestCases", 396 defaults: ["init_defaults"], 397 require_root: true, 398 399 compile_multilib: "both", 400 multilib: { 401 lib32: { 402 suffix: "32", 403 }, 404 lib64: { 405 suffix: "64", 406 }, 407 }, 408 409 srcs: [ 410 "devices_test.cpp", 411 "epoll_test.cpp", 412 "firmware_handler_test.cpp", 413 "init_test.cpp", 414 "keychords_test.cpp", 415 "oneshot_on_test.cpp", 416 "persistent_properties_test.cpp", 417 "property_service_test.cpp", 418 "property_type_test.cpp", 419 "reboot_test.cpp", 420 "rlimit_parser_test.cpp", 421 "service_test.cpp", 422 "subcontext_test.cpp", 423 "tokenizer_test.cpp", 424 "ueventd_parser_test.cpp", 425 "ueventd_test.cpp", 426 "util_test.cpp", 427 ], 428 static_libs: ["libinit"], 429 430 test_suites: [ 431 "cts", 432 "device-tests", 433 ], 434} 435 436cc_benchmark { 437 name: "init_benchmarks", 438 defaults: ["init_defaults"], 439 srcs: [ 440 "subcontext_benchmark.cpp", 441 ], 442 static_libs: ["libinit"], 443} 444 445cc_defaults { 446 name: "libinit_test_utils_libraries_defaults", 447 shared_libs: [ 448 "libbase", 449 "libcutils", 450 "libselinux", 451 "libhidl-gen-utils", 452 "liblog", 453 "libprocessgroup", 454 "libprotobuf-cpp-lite", 455 ], 456} 457 458cc_library_static { 459 name: "libinit_test_utils", 460 defaults: ["libinit_test_utils_libraries_defaults"], 461 cflags: [ 462 "-Wall", 463 "-Wextra", 464 "-Wno-unused-parameter", 465 "-Werror", 466 ], 467 srcs: init_common_sources + [ 468 "test_utils/service_utils.cpp", 469 ], 470 whole_static_libs: [ 471 "libcap", 472 ], 473 export_include_dirs: ["test_utils/include"], // for tests 474} 475 476// Host Verifier 477// ------------------------------------------------------------------------------ 478 479genrule { 480 name: "generated_stub_builtin_function_map", 481 tool_files: ["host_builtin_map.py"], 482 out: ["generated_stub_builtin_function_map.h"], 483 srcs: [ 484 "builtins.cpp", 485 "check_builtins.cpp", 486 ], 487 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)", 488} 489 490cc_binary { 491 name: "host_init_verifier", 492 host_supported: true, 493 cflags: [ 494 "-Wall", 495 "-Wextra", 496 "-Wno-unused-parameter", 497 "-Werror", 498 ], 499 static_libs: [ 500 "libbase", 501 "libselinux", 502 "libpropertyinfoserializer", 503 "libpropertyinfoparser", 504 ], 505 whole_static_libs: ["libcap"], 506 shared_libs: [ 507 "libcutils", 508 "libhidl-gen-utils", 509 "libhidlmetadata", 510 "liblog", 511 "libprocessgroup", 512 "libprotobuf-cpp-lite", 513 ], 514 srcs: init_common_sources + init_host_sources, 515 proto: { 516 type: "lite", 517 }, 518 generated_headers: [ 519 "generated_stub_builtin_function_map", 520 "generated_android_ids", 521 ], 522 target: { 523 android: { 524 enabled: false, 525 }, 526 darwin: { 527 enabled: false, 528 }, 529 }, 530} 531