Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 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 | |
| 17 | cc_defaults { |
| 18 | name: "init_defaults", |
| 19 | cpp_std: "experimental", |
| 20 | sanitize: { |
Tom Cherry | 2ffd65e | 2017-07-26 14:17:09 -0700 | [diff] [blame] | 21 | misc_undefined: ["signed-integer-overflow"], |
Tom Cherry | f8315f0 | 2018-12-05 13:37:26 -0800 | [diff] [blame] | 22 | address: false, // TODO(b/120561310): Fix ASAN to work without /proc mounted and re-enable. |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 23 | }, |
Chih-Hung Hsieh | 122352d | 2017-10-02 15:20:07 -0700 | [diff] [blame] | 24 | cflags: [ |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 25 | "-DLOG_UEVENTS=0", |
| 26 | "-Wall", |
| 27 | "-Wextra", |
| 28 | "-Wno-unused-parameter", |
| 29 | "-Werror", |
| 30 | "-DALLOW_LOCAL_PROP_OVERRIDE=0", |
| 31 | "-DALLOW_PERMISSIVE_SELINUX=0", |
| 32 | "-DREBOOT_BOOTLOADER_ON_PANIC=0", |
| 33 | "-DWORLD_WRITABLE_KMSG=0", |
| 34 | "-DDUMP_ON_UMOUNT_FAILURE=0", |
| 35 | "-DSHUTDOWN_ZERO_TIMEOUT=0", |
| 36 | ], |
| 37 | product_variables: { |
| 38 | debuggable: { |
| 39 | cppflags: [ |
| 40 | "-UALLOW_LOCAL_PROP_OVERRIDE", |
| 41 | "-DALLOW_LOCAL_PROP_OVERRIDE=1", |
| 42 | "-UALLOW_PERMISSIVE_SELINUX", |
| 43 | "-DALLOW_PERMISSIVE_SELINUX=1", |
| 44 | "-UREBOOT_BOOTLOADER_ON_PANIC", |
| 45 | "-DREBOOT_BOOTLOADER_ON_PANIC=1", |
| 46 | "-UWORLD_WRITABLE_KMSG", |
| 47 | "-DWORLD_WRITABLE_KMSG=1", |
| 48 | "-UDUMP_ON_UMOUNT_FAILURE", |
| 49 | "-DDUMP_ON_UMOUNT_FAILURE=1", |
| 50 | ], |
| 51 | }, |
| 52 | eng: { |
| 53 | cppflags: [ |
| 54 | "-USHUTDOWN_ZERO_TIMEOUT", |
| 55 | "-DSHUTDOWN_ZERO_TIMEOUT=1", |
| 56 | ], |
| 57 | }, |
Dmitry Shmidt | c3bc509 | 2017-08-23 14:57:07 -0700 | [diff] [blame] | 58 | uml: { |
| 59 | cppflags: ["-DUSER_MODE_LINUX"], |
Elliott Hughes | dc699a2 | 2018-02-16 17:58:14 -0800 | [diff] [blame] | 60 | }, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 61 | }, |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 62 | static_libs: [ |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 63 | "libseccomp_policy", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 64 | "libprocessgroup", |
| 65 | "libavb", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 66 | "libprotobuf-cpp-lite", |
| 67 | "libpropertyinfoserializer", |
| 68 | "libpropertyinfoparser", |
Jiyong Park | 787322c | 2018-06-01 19:26:42 +0900 | [diff] [blame] | 69 | ], |
| 70 | shared_libs: [ |
Jiyong Park | 787322c | 2018-06-01 19:26:42 +0900 | [diff] [blame] | 71 | "libbase", |
Martijn Coenen | 62e985a | 2018-09-04 06:29:14 +0200 | [diff] [blame] | 72 | "libbinder", |
Tao Bao | 66209ca | 2018-07-25 22:35:45 -0700 | [diff] [blame] | 73 | "libbootloader_message", |
| 74 | "libcutils", |
Branden Archer | d052118 | 2018-11-15 08:43:48 -0800 | [diff] [blame] | 75 | "libcrypto", |
Jiyong Park | 787322c | 2018-06-01 19:26:42 +0900 | [diff] [blame] | 76 | "libdl", |
Tao Bao | 66209ca | 2018-07-25 22:35:45 -0700 | [diff] [blame] | 77 | "libext4_utils", |
| 78 | "libfs_mgr", |
Eric Biggers | f05da4a | 2018-10-23 13:10:33 -0700 | [diff] [blame] | 79 | "libfscrypt", |
Tao Bao | 66209ca | 2018-07-25 22:35:45 -0700 | [diff] [blame] | 80 | "libhidl-gen-utils", |
| 81 | "libkeyutils", |
| 82 | "liblog", |
| 83 | "liblogwrap", |
Tom Cherry | 7bfea3d | 2018-11-06 14:12:05 -0800 | [diff] [blame] | 84 | "liblp", |
Jiyong Park | 012171d | 2018-06-19 16:55:05 +0900 | [diff] [blame] | 85 | "libselinux", |
Martijn Coenen | 62e985a | 2018-09-04 06:29:14 +0200 | [diff] [blame] | 86 | "libutils", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 87 | ], |
Jiyong Park | 93318d4 | 2018-12-26 17:34:39 +0900 | [diff] [blame^] | 88 | bootstrap: true, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | cc_library_static { |
| 92 | name: "libinit", |
Tom Cherry | 3143848 | 2018-07-20 14:57:00 -0700 | [diff] [blame] | 93 | recovery_available: true, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 94 | defaults: ["init_defaults"], |
| 95 | srcs: [ |
| 96 | "action.cpp", |
Tom Cherry | 7fd3bc2 | 2018-02-13 15:36:14 -0800 | [diff] [blame] | 97 | "action_manager.cpp", |
Tom Cherry | 0f6417f | 2018-02-13 15:25:29 -0800 | [diff] [blame] | 98 | "action_parser.cpp", |
Branden Archer | d052118 | 2018-11-15 08:43:48 -0800 | [diff] [blame] | 99 | "boringssl_self_test.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 100 | "bootchart.cpp", |
| 101 | "builtins.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 102 | "capabilities.cpp", |
| 103 | "descriptors.cpp", |
| 104 | "devices.cpp", |
Mark Salyzyn | 6c6ec72 | 2015-10-24 16:20:18 -0700 | [diff] [blame] | 105 | "epoll.cpp", |
Tom Cherry | ed506f7 | 2017-05-25 15:58:59 -0700 | [diff] [blame] | 106 | "firmware_handler.cpp", |
Tom Cherry | 7bfea3d | 2018-11-06 14:12:05 -0800 | [diff] [blame] | 107 | "first_stage_init.cpp", |
Tom Cherry | 38a11cc | 2018-07-20 15:18:04 -0700 | [diff] [blame] | 108 | "first_stage_mount.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 109 | "import_parser.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 110 | "init.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 111 | "keychords.cpp", |
Andrew F. Davis | 9963847 | 2018-07-09 13:12:00 -0500 | [diff] [blame] | 112 | "modalias_handler.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 113 | "parser.cpp", |
Tom Cherry | 16fad42 | 2017-08-04 15:59:03 -0700 | [diff] [blame] | 114 | "persistent_properties.cpp", |
Tom Cherry | a97faba | 2017-09-15 15:44:04 -0700 | [diff] [blame] | 115 | "persistent_properties.proto", |
Tom Cherry | 2a978d3 | 2017-08-09 17:13:21 -0700 | [diff] [blame] | 116 | "property_service.cpp", |
Tom Cherry | 927c5d5 | 2017-12-11 01:40:07 -0800 | [diff] [blame] | 117 | "property_type.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 118 | "reboot.cpp", |
Tom Cherry | 44aceed | 2018-08-03 13:36:18 -0700 | [diff] [blame] | 119 | "reboot_utils.cpp", |
Tom Cherry | 0c8d6d2 | 2017-08-10 12:22:44 -0700 | [diff] [blame] | 120 | "security.cpp", |
| 121 | "selinux.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 122 | "service.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 123 | "sigchld_handler.cpp", |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 124 | "subcontext.cpp", |
| 125 | "subcontext.proto", |
Tom Cherry | 7bfea3d | 2018-11-06 14:12:05 -0800 | [diff] [blame] | 126 | "switch_root.cpp", |
Tom Cherry | 7ac013d | 2017-08-25 10:39:25 -0700 | [diff] [blame] | 127 | "rlimit_parser.cpp", |
Tom Cherry | 67dee62 | 2017-07-27 12:54:48 -0700 | [diff] [blame] | 128 | "tokenizer.cpp", |
Tom Cherry | ed506f7 | 2017-05-25 15:58:59 -0700 | [diff] [blame] | 129 | "uevent_listener.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 130 | "ueventd.cpp", |
Tom Cherry | ed506f7 | 2017-05-25 15:58:59 -0700 | [diff] [blame] | 131 | "ueventd_parser.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 132 | "util.cpp", |
| 133 | ], |
| 134 | whole_static_libs: ["libcap"], |
Jayant Chowdhary | 478c7c1 | 2018-03-28 18:45:35 -0700 | [diff] [blame] | 135 | header_libs: ["bootimg_headers"], |
Tom Cherry | a97faba | 2017-09-15 15:44:04 -0700 | [diff] [blame] | 136 | proto: { |
| 137 | type: "lite", |
| 138 | export_proto_headers: true, |
| 139 | }, |
Martijn Coenen | 62e985a | 2018-09-04 06:29:14 +0200 | [diff] [blame] | 140 | |
| 141 | target: { |
| 142 | recovery: { |
| 143 | cflags: ["-DRECOVERY"], |
| 144 | exclude_shared_libs: ["libbinder", "libutils"], |
| 145 | }, |
| 146 | }, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 149 | cc_binary { |
Tom Cherry | 3143848 | 2018-07-20 14:57:00 -0700 | [diff] [blame] | 150 | name: "init_second_stage", |
| 151 | recovery_available: true, |
| 152 | stem: "init", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 153 | defaults: ["init_defaults"], |
Tom Cherry | 3143848 | 2018-07-20 14:57:00 -0700 | [diff] [blame] | 154 | static_libs: ["libinit"], |
Jin Qian | 0045697 | 2017-07-06 11:43:45 -0700 | [diff] [blame] | 155 | required: [ |
| 156 | "e2fsdroid", |
| 157 | "mke2fs", |
Jaegeuk Kim | 899ad55 | 2017-11-28 19:26:34 -0800 | [diff] [blame] | 158 | "sload_f2fs", |
| 159 | "make_f2fs", |
Jin Qian | 0045697 | 2017-07-06 11:43:45 -0700 | [diff] [blame] | 160 | ], |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 161 | srcs: ["main.cpp"], |
Tom Cherry | 3143848 | 2018-07-20 14:57:00 -0700 | [diff] [blame] | 162 | symlinks: ["ueventd"], |
Martijn Coenen | 62e985a | 2018-09-04 06:29:14 +0200 | [diff] [blame] | 163 | target: { |
| 164 | recovery: { |
| 165 | cflags: ["-DRECOVERY"], |
| 166 | exclude_shared_libs: ["libbinder", "libutils"], |
| 167 | }, |
| 168 | }, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 169 | } |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 170 | |
| 171 | // Tests |
| 172 | // ------------------------------------------------------------------------------ |
| 173 | |
| 174 | cc_test { |
| 175 | name: "init_tests", |
| 176 | defaults: ["init_defaults"], |
Tao Bao | a3d36a8 | 2018-08-24 09:40:04 -0700 | [diff] [blame] | 177 | compile_multilib: "first", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 178 | srcs: [ |
| 179 | "devices_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 180 | "init_test.cpp", |
Mark Salyzyn | 75b901d | 2018-05-15 11:19:43 -0700 | [diff] [blame] | 181 | "keychords_test.cpp", |
Tom Cherry | 16fad42 | 2017-08-04 15:59:03 -0700 | [diff] [blame] | 182 | "persistent_properties_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 183 | "property_service_test.cpp", |
Tom Cherry | 927c5d5 | 2017-12-11 01:40:07 -0800 | [diff] [blame] | 184 | "property_type_test.cpp", |
Tom Cherry | 11a3aee | 2017-08-03 12:54:07 -0700 | [diff] [blame] | 185 | "result_test.cpp", |
Tom Cherry | 7ac013d | 2017-08-25 10:39:25 -0700 | [diff] [blame] | 186 | "rlimit_parser_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 187 | "service_test.cpp", |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 188 | "subcontext_test.cpp", |
Tom Cherry | 2a5a4e7 | 2018-06-26 13:56:34 -0700 | [diff] [blame] | 189 | "tokenizer_test.cpp", |
Tom Cherry | 5f0198b | 2018-07-17 15:28:16 -0700 | [diff] [blame] | 190 | "ueventd_parser_test.cpp", |
Tom Cherry | c2e181c | 2017-07-14 16:29:23 -0700 | [diff] [blame] | 191 | "ueventd_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 192 | "util_test.cpp", |
| 193 | ], |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 194 | static_libs: ["libinit"], |
Elliott Hughes | 40fdf3f | 2018-04-27 16:12:06 -0700 | [diff] [blame] | 195 | test_suites: ["device-tests"], |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 198 | cc_benchmark { |
| 199 | name: "init_benchmarks", |
| 200 | defaults: ["init_defaults"], |
| 201 | srcs: [ |
| 202 | "subcontext_benchmark.cpp", |
| 203 | ], |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 204 | static_libs: ["libinit"], |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 205 | } |
| 206 | |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 207 | // Host Verifier |
| 208 | // ------------------------------------------------------------------------------ |
| 209 | |
| 210 | genrule { |
| 211 | name: "generated_stub_builtin_function_map", |
| 212 | out: ["generated_stub_builtin_function_map.h"], |
| 213 | srcs: ["builtins.cpp"], |
Tom Cherry | 547f731 | 2018-02-28 21:40:46 -0800 | [diff] [blame] | 214 | 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)", |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | cc_binary { |
| 218 | name: "host_init_verifier", |
| 219 | host_supported: true, |
| 220 | cpp_std: "experimental", |
| 221 | cflags: [ |
| 222 | "-Wall", |
| 223 | "-Wextra", |
| 224 | "-Wno-unused-parameter", |
| 225 | "-Werror", |
| 226 | ], |
| 227 | static_libs: [ |
| 228 | "libbase", |
| 229 | "libselinux", |
| 230 | ], |
| 231 | whole_static_libs: ["libcap"], |
| 232 | shared_libs: [ |
| 233 | "libprotobuf-cpp-lite", |
| 234 | "libhidl-gen-utils", |
| 235 | "libprocessgroup", |
| 236 | "liblog", |
| 237 | "libcutils", |
| 238 | ], |
Yifan Hong | 3c4aa11 | 2018-06-20 22:49:48 +0000 | [diff] [blame] | 239 | srcs: [ |
| 240 | "action.cpp", |
| 241 | "action_manager.cpp", |
| 242 | "action_parser.cpp", |
| 243 | "capabilities.cpp", |
| 244 | "descriptors.cpp", |
| 245 | "epoll.cpp", |
| 246 | "keychords.cpp", |
| 247 | "import_parser.cpp", |
| 248 | "host_import_parser.cpp", |
| 249 | "host_init_verifier.cpp", |
| 250 | "host_init_stubs.cpp", |
| 251 | "parser.cpp", |
| 252 | "rlimit_parser.cpp", |
| 253 | "tokenizer.cpp", |
| 254 | "service.cpp", |
| 255 | "subcontext.cpp", |
| 256 | "subcontext.proto", |
| 257 | "util.cpp", |
| 258 | ], |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 259 | proto: { |
| 260 | type: "lite", |
| 261 | }, |
Yifan Hong | 3c4aa11 | 2018-06-20 22:49:48 +0000 | [diff] [blame] | 262 | generated_headers: [ |
| 263 | "generated_stub_builtin_function_map", |
| 264 | "generated_android_ids" |
| 265 | ], |
Tom Cherry | 96ff0fe | 2018-02-28 17:20:27 -0800 | [diff] [blame] | 266 | target: { |
Tom Cherry | 547f731 | 2018-02-28 21:40:46 -0800 | [diff] [blame] | 267 | android: { |
| 268 | enabled: false, |
| 269 | }, |
Tom Cherry | 96ff0fe | 2018-02-28 17:20:27 -0800 | [diff] [blame] | 270 | darwin: { |
Yifan Hong | 3c4aa11 | 2018-06-20 22:49:48 +0000 | [diff] [blame] | 271 | enabled: false, |
Tom Cherry | 96ff0fe | 2018-02-28 17:20:27 -0800 | [diff] [blame] | 272 | }, |
| 273 | }, |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 276 | subdirs = ["*"] |