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