blob: 17e4adf04632049a53f3ea5099c41f8210556390 [file] [log] [blame]
Tom Cherry14fc0132017-05-09 17:11:57 -07001//
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
Tom Cherry66196492020-02-06 11:56:58 -080017init_common_sources = [
18 "action.cpp",
19 "action_manager.cpp",
20 "action_parser.cpp",
21 "capabilities.cpp",
22 "epoll.cpp",
23 "import_parser.cpp",
24 "interface_utils.cpp",
25 "keychords.cpp",
26 "parser.cpp",
27 "property_type.cpp",
28 "rlimit_parser.cpp",
29 "service.cpp",
30 "service_list.cpp",
31 "service_parser.cpp",
32 "service_utils.cpp",
33 "subcontext.cpp",
34 "subcontext.proto",
35 "tokenizer.cpp",
36 "util.cpp",
37]
38init_device_sources = [
David Anderson41175592020-03-20 19:38:28 -070039 "block_dev_initializer.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080040 "bootchart.cpp",
41 "builtins.cpp",
42 "devices.cpp",
43 "firmware_handler.cpp",
44 "first_stage_init.cpp",
45 "first_stage_mount.cpp",
46 "fscrypt_init_extensions.cpp",
47 "init.cpp",
48 "lmkd_service.cpp",
49 "modalias_handler.cpp",
50 "mount_handler.cpp",
51 "mount_namespace.cpp",
52 "persistent_properties.cpp",
53 "persistent_properties.proto",
54 "property_service.cpp",
55 "property_service.proto",
56 "reboot.cpp",
57 "reboot_utils.cpp",
58 "security.cpp",
59 "selabel.cpp",
60 "selinux.cpp",
61 "sigchld_handler.cpp",
62 "switch_root.cpp",
63 "uevent_listener.cpp",
64 "ueventd.cpp",
65 "ueventd_parser.cpp",
66]
67init_host_sources = [
68 "check_builtins.cpp",
69 "host_import_parser.cpp",
70 "host_init_verifier.cpp",
71]
72
Tom Cherry14fc0132017-05-09 17:11:57 -070073cc_defaults {
74 name: "init_defaults",
75 cpp_std: "experimental",
76 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -070077 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -070078 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -070079 cflags: [
Tom Cherry14fc0132017-05-09 17:11:57 -070080 "-DLOG_UEVENTS=0",
81 "-Wall",
82 "-Wextra",
83 "-Wno-unused-parameter",
84 "-Werror",
Tom Cherry802864c2020-03-12 14:29:25 -070085 "-Wthread-safety",
Steve Muckled75f30a2019-05-21 15:50:39 -070086 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -070087 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
88 "-DALLOW_PERMISSIVE_SELINUX=0",
89 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
90 "-DWORLD_WRITABLE_KMSG=0",
91 "-DDUMP_ON_UMOUNT_FAILURE=0",
92 "-DSHUTDOWN_ZERO_TIMEOUT=0",
Tom Cherrya2f91362020-02-20 10:50:00 -080093 "-DINIT_FULL_SOURCES",
Tom Cherry14fc0132017-05-09 17:11:57 -070094 ],
95 product_variables: {
96 debuggable: {
97 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -070098 "-UALLOW_FIRST_STAGE_CONSOLE",
99 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700100 "-UALLOW_LOCAL_PROP_OVERRIDE",
101 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
102 "-UALLOW_PERMISSIVE_SELINUX",
103 "-DALLOW_PERMISSIVE_SELINUX=1",
104 "-UREBOOT_BOOTLOADER_ON_PANIC",
105 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
106 "-UWORLD_WRITABLE_KMSG",
107 "-DWORLD_WRITABLE_KMSG=1",
108 "-UDUMP_ON_UMOUNT_FAILURE",
109 "-DDUMP_ON_UMOUNT_FAILURE=1",
110 ],
111 },
112 eng: {
113 cppflags: [
114 "-USHUTDOWN_ZERO_TIMEOUT",
115 "-DSHUTDOWN_ZERO_TIMEOUT=1",
116 ],
117 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700118 uml: {
119 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800120 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700121 },
Tom Cherry618d3102018-01-19 14:25:48 -0800122 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800123 "libavb",
Bowgo Tsai30afda72019-04-11 23:57:24 +0800124 "libc++fs",
Yifan Hongd8ce1fb2019-03-22 17:21:58 -0700125 "libcgrouprc_format",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700126 "liblmkd_utils",
Steve Muckle18b981e2019-04-15 17:43:02 -0700127 "libmodprobe",
Tom Cherry618d3102018-01-19 14:25:48 -0800128 "libprotobuf-cpp-lite",
129 "libpropertyinfoserializer",
130 "libpropertyinfoparser",
David Andersondfe6d072019-10-09 16:24:03 -0700131 "libsnapshot_init",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900132 "lib_apex_manifest_proto_lite",
Jiyong Park787322c2018-06-01 19:26:42 +0900133 ],
134 shared_libs: [
Tom Cherry59656fb2019-05-28 10:19:44 -0700135 "libbacktrace",
Jiyong Park787322c2018-06-01 19:26:42 +0900136 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700137 "libbootloader_message",
138 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900139 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700140 "libext4_utils",
141 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800142 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700143 "libhidl-gen-utils",
144 "libkeyutils",
145 "liblog",
146 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800147 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800148 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800149 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900150 "libselinux",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200151 "libutils",
Tom Cherry618d3102018-01-19 14:25:48 -0800152 ],
Jiyong Park93318d42018-12-26 17:34:39 +0900153 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700154 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700155}
156
157cc_library_static {
158 name: "libinit",
Tom Cherry31438482018-07-20 14:57:00 -0700159 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700160 defaults: [
161 "init_defaults",
162 "selinux_policy_version",
163 ],
Tom Cherry66196492020-02-06 11:56:58 -0800164 srcs: init_common_sources + init_device_sources,
Daniel Norman8082ba22019-07-23 10:26:15 -0700165 whole_static_libs: [
166 "libcap",
167 "com.android.sysprop.apex",
Nikita Ioffe23dbd6d2019-11-14 01:21:24 +0000168 "com.android.sysprop.init",
Daniel Norman8082ba22019-07-23 10:26:15 -0700169 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700170 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700171 proto: {
172 type: "lite",
173 export_proto_headers: true,
174 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200175
176 target: {
177 recovery: {
178 cflags: ["-DRECOVERY"],
Daniel Norman8082ba22019-07-23 10:26:15 -0700179 exclude_shared_libs: [
180 "libbinder",
181 "libutils",
182 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200183 },
184 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700185}
186
Steven Morelandceb36d02019-07-15 15:12:56 -0700187phony {
188 name: "init",
189 required: [
190 "init_second_stage",
191 ],
192}
193
Tom Cherry14fc0132017-05-09 17:11:57 -0700194cc_binary {
Tom Cherry31438482018-07-20 14:57:00 -0700195 name: "init_second_stage",
196 recovery_available: true,
197 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700198 defaults: ["init_defaults"],
Tom Cherry31438482018-07-20 14:57:00 -0700199 static_libs: ["libinit"],
Jin Qian00456972017-07-06 11:43:45 -0700200 required: [
201 "e2fsdroid",
Tom Cherryc9f53532019-11-04 10:30:36 -0800202 "init.rc",
Jin Qian00456972017-07-06 11:43:45 -0700203 "mke2fs",
Jaegeuk Kim899ad552017-11-28 19:26:34 -0800204 "sload_f2fs",
205 "make_f2fs",
Tom Cherryc9f53532019-11-04 10:30:36 -0800206 "ueventd.rc",
Jin Qian00456972017-07-06 11:43:45 -0700207 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800208 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700209 symlinks: ["ueventd"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200210 target: {
211 recovery: {
212 cflags: ["-DRECOVERY"],
Daniel Norman8082ba22019-07-23 10:26:15 -0700213 exclude_shared_libs: [
214 "libbinder",
215 "libutils",
216 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200217 },
218 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700219}
Tom Cherry14fc0132017-05-09 17:11:57 -0700220
221// Tests
222// ------------------------------------------------------------------------------
223
224cc_test {
Tom Cherry17b2be02019-08-20 10:43:48 -0700225 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700226 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700227 require_root: true,
228
Tom Cherry17b2be02019-08-20 10:43:48 -0700229 compile_multilib: "both",
230 multilib: {
231 lib32: {
232 suffix: "32",
233 },
234 lib64: {
235 suffix: "64",
236 },
237 },
238
Tom Cherry14fc0132017-05-09 17:11:57 -0700239 srcs: [
240 "devices_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700241 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700242 "init_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700243 "keychords_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700244 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700245 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800246 "property_type_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700247 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700248 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700249 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700250 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700251 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700252 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700253 "util_test.cpp",
254 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800255 static_libs: ["libinit"],
Tom Cherry17b2be02019-08-20 10:43:48 -0700256
257 test_suites: [
258 "cts",
259 "device-tests",
260 "vts",
261 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700262}
263
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700264cc_benchmark {
265 name: "init_benchmarks",
266 defaults: ["init_defaults"],
267 srcs: [
268 "subcontext_benchmark.cpp",
269 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800270 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700271}
272
Tom Cherrya2f91362020-02-20 10:50:00 -0800273cc_defaults {
274 name: "libinit_test_utils_libraries_defaults",
275 shared_libs: [
276 "libbase",
277 "libcutils",
278 "libselinux",
279 "libhidl-gen-utils",
280 "liblog",
281 "libprocessgroup",
282 "libprotobuf-cpp-lite",
283 ],
284}
285
286cc_library_static {
287 name: "libinit_test_utils",
288 defaults: ["libinit_test_utils_libraries_defaults"],
289 cflags: [
290 "-Wall",
291 "-Wextra",
292 "-Wno-unused-parameter",
293 "-Werror",
294 ],
295 srcs: init_common_sources + [
296 "test_utils/service_utils.cpp",
297 ],
298 whole_static_libs: [
299 "libcap",
300 ],
301 export_include_dirs: ["test_utils/include"], // for tests
302}
303
Tom Cherryde6bd502018-02-13 16:50:08 -0800304// Host Verifier
305// ------------------------------------------------------------------------------
306
307genrule {
308 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700309 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800310 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700311 srcs: [
312 "builtins.cpp",
313 "check_builtins.cpp",
314 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700315 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800316}
317
318cc_binary {
319 name: "host_init_verifier",
320 host_supported: true,
321 cpp_std: "experimental",
322 cflags: [
323 "-Wall",
324 "-Wextra",
325 "-Wno-unused-parameter",
326 "-Werror",
327 ],
328 static_libs: [
329 "libbase",
330 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800331 "libpropertyinfoserializer",
332 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800333 ],
334 whole_static_libs: ["libcap"],
335 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800336 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700337 "libhidl-gen-utils",
Steven Moreland422a7582019-10-15 14:53:19 -0700338 "libhidlmetadata",
Daniel Norman3f42a762019-07-09 11:00:53 -0700339 "liblog",
340 "libprocessgroup",
341 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800342 ],
Tom Cherry66196492020-02-06 11:56:58 -0800343 srcs: init_common_sources + init_host_sources,
Tom Cherryde6bd502018-02-13 16:50:08 -0800344 proto: {
345 type: "lite",
346 },
Yifan Hong3c4aa112018-06-20 22:49:48 +0000347 generated_headers: [
348 "generated_stub_builtin_function_map",
Daniel Norman8082ba22019-07-23 10:26:15 -0700349 "generated_android_ids",
Yifan Hong3c4aa112018-06-20 22:49:48 +0000350 ],
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800351 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800352 android: {
353 enabled: false,
354 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800355 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000356 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800357 },
358 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800359}