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: [ |
| 62 | "libbootloader_message", |
| 63 | "libfs_mgr", |
| 64 | "libfec", |
| 65 | "libfec_rs", |
| 66 | "libhidl-gen-utils", |
| 67 | "libsquashfs_utils", |
| 68 | "liblogwrap", |
| 69 | "libext4_utils", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 70 | "libseccomp_policy", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 71 | "libcrypto_utils", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 72 | "libsparse", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 73 | "libprocessgroup", |
| 74 | "libavb", |
| 75 | "libkeyutils", |
| 76 | "libprotobuf-cpp-lite", |
| 77 | "libpropertyinfoserializer", |
| 78 | "libpropertyinfoparser", |
Jiyong Park | 787322c | 2018-06-01 19:26:42 +0900 | [diff] [blame] | 79 | ], |
| 80 | shared_libs: [ |
| 81 | "libcutils", |
| 82 | "libbase", |
| 83 | "libc", |
| 84 | "liblog", |
| 85 | "libcrypto", |
| 86 | "libc++", |
| 87 | "libdl", |
| 88 | "libz", |
Jiyong Park | 012171d | 2018-06-19 16:55:05 +0900 | [diff] [blame^] | 89 | "libselinux", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 90 | ], |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | cc_library_static { |
| 94 | name: "libinit", |
| 95 | defaults: ["init_defaults"], |
| 96 | srcs: [ |
| 97 | "action.cpp", |
Tom Cherry | 7fd3bc2 | 2018-02-13 15:36:14 -0800 | [diff] [blame] | 98 | "action_manager.cpp", |
Tom Cherry | 0f6417f | 2018-02-13 15:25:29 -0800 | [diff] [blame] | 99 | "action_parser.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 | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 107 | "import_parser.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 108 | "init.cpp", |
| 109 | "init_first_stage.cpp", |
| 110 | "keychords.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 111 | "log.cpp", |
| 112 | "parser.cpp", |
Tom Cherry | 16fad42 | 2017-08-04 15:59:03 -0700 | [diff] [blame] | 113 | "persistent_properties.cpp", |
Tom Cherry | a97faba | 2017-09-15 15:44:04 -0700 | [diff] [blame] | 114 | "persistent_properties.proto", |
Tom Cherry | 2a978d3 | 2017-08-09 17:13:21 -0700 | [diff] [blame] | 115 | "property_service.cpp", |
Tom Cherry | 927c5d5 | 2017-12-11 01:40:07 -0800 | [diff] [blame] | 116 | "property_type.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 117 | "reboot.cpp", |
Tom Cherry | 0c8d6d2 | 2017-08-10 12:22:44 -0700 | [diff] [blame] | 118 | "security.cpp", |
| 119 | "selinux.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 120 | "service.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 121 | "sigchld_handler.cpp", |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 122 | "subcontext.cpp", |
| 123 | "subcontext.proto", |
Tom Cherry | 7ac013d | 2017-08-25 10:39:25 -0700 | [diff] [blame] | 124 | "rlimit_parser.cpp", |
Tom Cherry | 67dee62 | 2017-07-27 12:54:48 -0700 | [diff] [blame] | 125 | "tokenizer.cpp", |
Tom Cherry | ed506f7 | 2017-05-25 15:58:59 -0700 | [diff] [blame] | 126 | "uevent_listener.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 127 | "ueventd.cpp", |
Tom Cherry | ed506f7 | 2017-05-25 15:58:59 -0700 | [diff] [blame] | 128 | "ueventd_parser.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 129 | "util.cpp", |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 130 | "watchdogd.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 131 | ], |
| 132 | whole_static_libs: ["libcap"], |
Jayant Chowdhary | 478c7c1 | 2018-03-28 18:45:35 -0700 | [diff] [blame] | 133 | header_libs: ["bootimg_headers"], |
Tom Cherry | a97faba | 2017-09-15 15:44:04 -0700 | [diff] [blame] | 134 | proto: { |
| 135 | type: "lite", |
| 136 | export_proto_headers: true, |
| 137 | }, |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | /* |
| 141 | This is not yet ready, see the below TODOs for what is missing |
| 142 | |
| 143 | cc_binary { |
| 144 | // TODO: Missing, |
| 145 | //LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT) |
| 146 | //LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_UNSTRIPPED) |
| 147 | |
| 148 | name: "init", |
| 149 | defaults: ["init_defaults"], |
Jin Qian | 0045697 | 2017-07-06 11:43:45 -0700 | [diff] [blame] | 150 | required: [ |
| 151 | "e2fsdroid", |
| 152 | "mke2fs", |
Jaegeuk Kim | 899ad55 | 2017-11-28 19:26:34 -0800 | [diff] [blame] | 153 | "sload_f2fs", |
| 154 | "make_f2fs", |
Jin Qian | 0045697 | 2017-07-06 11:43:45 -0700 | [diff] [blame] | 155 | ], |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 156 | static_executable: true, |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 157 | srcs: ["main.cpp"], |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 158 | symlinks: [ |
| 159 | "sbin/ueventd", |
| 160 | "sbin/watchdogd", |
| 161 | ], |
| 162 | } |
| 163 | */ |
| 164 | |
| 165 | // Tests |
| 166 | // ------------------------------------------------------------------------------ |
| 167 | |
| 168 | cc_test { |
| 169 | name: "init_tests", |
| 170 | defaults: ["init_defaults"], |
| 171 | srcs: [ |
| 172 | "devices_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 173 | "init_test.cpp", |
Mark Salyzyn | 75b901d | 2018-05-15 11:19:43 -0700 | [diff] [blame] | 174 | "keychords_test.cpp", |
Tom Cherry | 16fad42 | 2017-08-04 15:59:03 -0700 | [diff] [blame] | 175 | "persistent_properties_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 176 | "property_service_test.cpp", |
Tom Cherry | 927c5d5 | 2017-12-11 01:40:07 -0800 | [diff] [blame] | 177 | "property_type_test.cpp", |
Tom Cherry | 11a3aee | 2017-08-03 12:54:07 -0700 | [diff] [blame] | 178 | "result_test.cpp", |
Tom Cherry | 7ac013d | 2017-08-25 10:39:25 -0700 | [diff] [blame] | 179 | "rlimit_parser_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 180 | "service_test.cpp", |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 181 | "subcontext_test.cpp", |
Tom Cherry | c2e181c | 2017-07-14 16:29:23 -0700 | [diff] [blame] | 182 | "ueventd_test.cpp", |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 183 | "util_test.cpp", |
| 184 | ], |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 185 | static_libs: ["libinit"], |
Elliott Hughes | 40fdf3f | 2018-04-27 16:12:06 -0700 | [diff] [blame] | 186 | test_suites: ["device-tests"], |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 189 | cc_benchmark { |
| 190 | name: "init_benchmarks", |
| 191 | defaults: ["init_defaults"], |
| 192 | srcs: [ |
| 193 | "subcontext_benchmark.cpp", |
| 194 | ], |
Tom Cherry | 618d310 | 2018-01-19 14:25:48 -0800 | [diff] [blame] | 195 | static_libs: ["libinit"], |
Tom Cherry | cb0f9bb | 2017-09-12 15:58:47 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 198 | // Host Verifier |
| 199 | // ------------------------------------------------------------------------------ |
| 200 | |
| 201 | genrule { |
| 202 | name: "generated_stub_builtin_function_map", |
| 203 | out: ["generated_stub_builtin_function_map.h"], |
| 204 | srcs: ["builtins.cpp"], |
Tom Cherry | 547f731 | 2018-02-28 21:40:46 -0800 | [diff] [blame] | 205 | 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] | 206 | } |
| 207 | |
| 208 | cc_binary { |
| 209 | name: "host_init_verifier", |
| 210 | host_supported: true, |
| 211 | cpp_std: "experimental", |
| 212 | cflags: [ |
| 213 | "-Wall", |
| 214 | "-Wextra", |
| 215 | "-Wno-unused-parameter", |
| 216 | "-Werror", |
| 217 | ], |
| 218 | static_libs: [ |
| 219 | "libbase", |
| 220 | "libselinux", |
| 221 | ], |
| 222 | whole_static_libs: ["libcap"], |
| 223 | shared_libs: [ |
| 224 | "libprotobuf-cpp-lite", |
| 225 | "libhidl-gen-utils", |
| 226 | "libprocessgroup", |
| 227 | "liblog", |
| 228 | "libcutils", |
| 229 | ], |
| 230 | srcs: [ |
| 231 | "action.cpp", |
| 232 | "action_manager.cpp", |
| 233 | "action_parser.cpp", |
| 234 | "capabilities.cpp", |
| 235 | "descriptors.cpp", |
Mark Salyzyn | eca2507 | 2018-05-16 15:10:24 -0700 | [diff] [blame] | 236 | "epoll.cpp", |
| 237 | "keychords.cpp", |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 238 | "import_parser.cpp", |
Tom Cherry | 194b5d1 | 2018-05-09 17:38:30 -0700 | [diff] [blame] | 239 | "host_import_parser.cpp", |
| 240 | "host_init_verifier.cpp", |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 241 | "host_init_stubs.cpp", |
| 242 | "parser.cpp", |
| 243 | "rlimit_parser.cpp", |
| 244 | "tokenizer.cpp", |
| 245 | "service.cpp", |
| 246 | "subcontext.cpp", |
| 247 | "subcontext.proto", |
| 248 | "util.cpp", |
| 249 | ], |
| 250 | proto: { |
| 251 | type: "lite", |
| 252 | }, |
Tom Cherry | 31525f5 | 2018-05-09 18:33:31 -0700 | [diff] [blame] | 253 | generated_headers: [ |
| 254 | "generated_stub_builtin_function_map", |
| 255 | "generated_android_ids" |
| 256 | ], |
Tom Cherry | 96ff0fe | 2018-02-28 17:20:27 -0800 | [diff] [blame] | 257 | target: { |
Tom Cherry | 547f731 | 2018-02-28 21:40:46 -0800 | [diff] [blame] | 258 | android: { |
| 259 | enabled: false, |
| 260 | }, |
Tom Cherry | 96ff0fe | 2018-02-28 17:20:27 -0800 | [diff] [blame] | 261 | darwin: { |
| 262 | enabled: false, |
| 263 | }, |
| 264 | }, |
Tom Cherry | de6bd50 | 2018-02-13 16:50:08 -0800 | [diff] [blame] | 265 | } |
| 266 | |
Tom Cherry | 14fc013 | 2017-05-09 17:11:57 -0700 | [diff] [blame] | 267 | subdirs = ["*"] |