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 17cc_defaults { 18 name: "init_defaults", 19 cpp_std: "experimental", 20 sanitize: { 21 misc_undefined: ["signed-integer-overflow"], 22 }, 23 cflags: [ 24 "-DLOG_UEVENTS=0", 25 "-Wall", 26 "-Wextra", 27 "-Wno-unused-parameter", 28 "-Werror", 29 "-DALLOW_LOCAL_PROP_OVERRIDE=0", 30 "-DALLOW_PERMISSIVE_SELINUX=0", 31 "-DREBOOT_BOOTLOADER_ON_PANIC=0", 32 "-DWORLD_WRITABLE_KMSG=0", 33 "-DDUMP_ON_UMOUNT_FAILURE=0", 34 "-DSHUTDOWN_ZERO_TIMEOUT=0", 35 ], 36 product_variables: { 37 debuggable: { 38 cppflags: [ 39 "-UALLOW_LOCAL_PROP_OVERRIDE", 40 "-DALLOW_LOCAL_PROP_OVERRIDE=1", 41 "-UALLOW_PERMISSIVE_SELINUX", 42 "-DALLOW_PERMISSIVE_SELINUX=1", 43 "-UREBOOT_BOOTLOADER_ON_PANIC", 44 "-DREBOOT_BOOTLOADER_ON_PANIC=1", 45 "-UWORLD_WRITABLE_KMSG", 46 "-DWORLD_WRITABLE_KMSG=1", 47 "-UDUMP_ON_UMOUNT_FAILURE", 48 "-DDUMP_ON_UMOUNT_FAILURE=1", 49 ], 50 }, 51 eng: { 52 cppflags: [ 53 "-USHUTDOWN_ZERO_TIMEOUT", 54 "-DSHUTDOWN_ZERO_TIMEOUT=1", 55 ], 56 }, 57 uml: { 58 cppflags: ["-DUSER_MODE_LINUX"], 59 }, 60 }, 61 static_libs: [ 62 "libseccomp_policy", 63 "libavb", 64 "libc++fs", 65 "libcgrouprc_format", 66 "libprotobuf-cpp-lite", 67 "libpropertyinfoserializer", 68 "libpropertyinfoparser", 69 ], 70 shared_libs: [ 71 "libbacktrace", 72 "libbase", 73 "libbinder", 74 "libbootloader_message", 75 "libcutils", 76 "libcrypto", 77 "libdl", 78 "libext4_utils", 79 "libfs_mgr", 80 "libfscrypt", 81 "libgsi", 82 "libhidl-gen-utils", 83 "libkeyutils", 84 "liblog", 85 "liblogwrap", 86 "liblp", 87 "libprocessgroup", 88 "libprocessgroup_setup", 89 "libselinux", 90 "libutils", 91 ], 92 bootstrap: true, 93} 94 95cc_library_static { 96 name: "libinit", 97 recovery_available: true, 98 defaults: ["init_defaults", "selinux_policy_version"], 99 srcs: [ 100 "action.cpp", 101 "action_manager.cpp", 102 "action_parser.cpp", 103 "boringssl_self_test.cpp", 104 "bootchart.cpp", 105 "builtins.cpp", 106 "capabilities.cpp", 107 "descriptors.cpp", 108 "devices.cpp", 109 "epoll.cpp", 110 "firmware_handler.cpp", 111 "first_stage_init.cpp", 112 "first_stage_mount.cpp", 113 "import_parser.cpp", 114 "init.cpp", 115 "keychords.cpp", 116 "modalias_handler.cpp", 117 "mount_handler.cpp", 118 "mount_namespace.cpp", 119 "parser.cpp", 120 "persistent_properties.cpp", 121 "persistent_properties.proto", 122 "property_service.cpp", 123 "property_type.cpp", 124 "reboot.cpp", 125 "reboot_utils.cpp", 126 "security.cpp", 127 "selinux.cpp", 128 "service.cpp", 129 "sigchld_handler.cpp", 130 "subcontext.cpp", 131 "subcontext.proto", 132 "switch_root.cpp", 133 "rlimit_parser.cpp", 134 "tokenizer.cpp", 135 "uevent_listener.cpp", 136 "ueventd.cpp", 137 "ueventd_parser.cpp", 138 "util.cpp", 139 ], 140 whole_static_libs: ["libcap", "com.android.sysprop.apex"], 141 header_libs: ["bootimg_headers"], 142 proto: { 143 type: "lite", 144 export_proto_headers: true, 145 }, 146 147 target: { 148 recovery: { 149 cflags: ["-DRECOVERY"], 150 exclude_shared_libs: ["libbinder", "libutils"], 151 }, 152 }, 153} 154 155cc_binary { 156 name: "init_second_stage", 157 recovery_available: true, 158 stem: "init", 159 defaults: ["init_defaults"], 160 static_libs: ["libinit"], 161 required: [ 162 "e2fsdroid", 163 "mke2fs", 164 "sload_f2fs", 165 "make_f2fs", 166 ], 167 srcs: ["main.cpp"], 168 symlinks: ["ueventd"], 169 target: { 170 recovery: { 171 cflags: ["-DRECOVERY"], 172 exclude_shared_libs: ["libbinder", "libutils"], 173 }, 174 }, 175 ldflags: ["-Wl,--rpath,/system/${LIB}/bootstrap"], 176} 177 178// Tests 179// ------------------------------------------------------------------------------ 180 181cc_test { 182 name: "init_tests", 183 defaults: ["init_defaults"], 184 compile_multilib: "first", 185 srcs: [ 186 "devices_test.cpp", 187 "init_test.cpp", 188 "keychords_test.cpp", 189 "persistent_properties_test.cpp", 190 "property_service_test.cpp", 191 "property_type_test.cpp", 192 "result_test.cpp", 193 "rlimit_parser_test.cpp", 194 "service_test.cpp", 195 "subcontext_test.cpp", 196 "tokenizer_test.cpp", 197 "ueventd_parser_test.cpp", 198 "ueventd_test.cpp", 199 "util_test.cpp", 200 ], 201 static_libs: ["libinit"], 202 test_suites: ["device-tests"], 203} 204 205cc_benchmark { 206 name: "init_benchmarks", 207 defaults: ["init_defaults"], 208 srcs: [ 209 "subcontext_benchmark.cpp", 210 ], 211 static_libs: ["libinit"], 212} 213 214// Host Verifier 215// ------------------------------------------------------------------------------ 216 217genrule { 218 name: "generated_stub_builtin_function_map", 219 out: ["generated_stub_builtin_function_map.h"], 220 srcs: ["builtins.cpp"], 221 cmd: "sed -n '/Builtin-function-map start/{:a;n;/Builtin-function-map end/q;p;ba}' $(in) | sed -e 's/do_[^}]*/do_stub/g' > $(out)", 222} 223 224cc_binary { 225 name: "host_init_verifier", 226 host_supported: true, 227 cpp_std: "experimental", 228 cflags: [ 229 "-Wall", 230 "-Wextra", 231 "-Wno-unused-parameter", 232 "-Werror", 233 ], 234 static_libs: [ 235 "libbase", 236 "libselinux", 237 ], 238 whole_static_libs: ["libcap"], 239 shared_libs: [ 240 "libprotobuf-cpp-lite", 241 "libhidl-gen-utils", 242 "libprocessgroup", 243 "liblog", 244 "libcutils", 245 ], 246 srcs: [ 247 "action.cpp", 248 "action_manager.cpp", 249 "action_parser.cpp", 250 "capabilities.cpp", 251 "descriptors.cpp", 252 "epoll.cpp", 253 "keychords.cpp", 254 "import_parser.cpp", 255 "host_import_parser.cpp", 256 "host_init_verifier.cpp", 257 "host_init_stubs.cpp", 258 "parser.cpp", 259 "rlimit_parser.cpp", 260 "tokenizer.cpp", 261 "service.cpp", 262 "subcontext.cpp", 263 "subcontext.proto", 264 "util.cpp", 265 ], 266 proto: { 267 type: "lite", 268 }, 269 generated_headers: [ 270 "generated_stub_builtin_function_map", 271 "generated_android_ids" 272 ], 273 target: { 274 android: { 275 enabled: false, 276 }, 277 darwin: { 278 enabled: false, 279 }, 280 }, 281} 282 283subdirs = ["*"] 284