blob: 3bb08db6c88d5cce763a32a6cb8f7c5ca62b57a7 [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 = [
39 "bootchart.cpp",
40 "builtins.cpp",
41 "devices.cpp",
42 "firmware_handler.cpp",
43 "first_stage_init.cpp",
44 "first_stage_mount.cpp",
45 "fscrypt_init_extensions.cpp",
46 "init.cpp",
47 "lmkd_service.cpp",
48 "modalias_handler.cpp",
49 "mount_handler.cpp",
50 "mount_namespace.cpp",
51 "persistent_properties.cpp",
52 "persistent_properties.proto",
53 "property_service.cpp",
54 "property_service.proto",
55 "reboot.cpp",
56 "reboot_utils.cpp",
57 "security.cpp",
58 "selabel.cpp",
59 "selinux.cpp",
60 "sigchld_handler.cpp",
61 "switch_root.cpp",
62 "uevent_listener.cpp",
63 "ueventd.cpp",
64 "ueventd_parser.cpp",
65]
66init_host_sources = [
67 "check_builtins.cpp",
68 "host_import_parser.cpp",
69 "host_init_verifier.cpp",
70]
71
Tom Cherry14fc0132017-05-09 17:11:57 -070072cc_defaults {
73 name: "init_defaults",
74 cpp_std: "experimental",
75 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -070076 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -070077 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -070078 cflags: [
Tom Cherry14fc0132017-05-09 17:11:57 -070079 "-DLOG_UEVENTS=0",
80 "-Wall",
81 "-Wextra",
82 "-Wno-unused-parameter",
83 "-Werror",
Steve Muckled75f30a2019-05-21 15:50:39 -070084 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -070085 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
86 "-DALLOW_PERMISSIVE_SELINUX=0",
87 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
88 "-DWORLD_WRITABLE_KMSG=0",
89 "-DDUMP_ON_UMOUNT_FAILURE=0",
90 "-DSHUTDOWN_ZERO_TIMEOUT=0",
Tom Cherrya2f91362020-02-20 10:50:00 -080091 "-DINIT_FULL_SOURCES",
Tom Cherry14fc0132017-05-09 17:11:57 -070092 ],
93 product_variables: {
94 debuggable: {
95 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -070096 "-UALLOW_FIRST_STAGE_CONSOLE",
97 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -070098 "-UALLOW_LOCAL_PROP_OVERRIDE",
99 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
100 "-UALLOW_PERMISSIVE_SELINUX",
101 "-DALLOW_PERMISSIVE_SELINUX=1",
102 "-UREBOOT_BOOTLOADER_ON_PANIC",
103 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
104 "-UWORLD_WRITABLE_KMSG",
105 "-DWORLD_WRITABLE_KMSG=1",
106 "-UDUMP_ON_UMOUNT_FAILURE",
107 "-DDUMP_ON_UMOUNT_FAILURE=1",
108 ],
109 },
110 eng: {
111 cppflags: [
112 "-USHUTDOWN_ZERO_TIMEOUT",
113 "-DSHUTDOWN_ZERO_TIMEOUT=1",
114 ],
115 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700116 uml: {
117 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800118 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700119 },
Tom Cherry618d3102018-01-19 14:25:48 -0800120 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800121 "libavb",
Bowgo Tsai30afda72019-04-11 23:57:24 +0800122 "libc++fs",
Yifan Hongd8ce1fb2019-03-22 17:21:58 -0700123 "libcgrouprc_format",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700124 "liblmkd_utils",
Steve Muckle18b981e2019-04-15 17:43:02 -0700125 "libmodprobe",
Tom Cherry618d3102018-01-19 14:25:48 -0800126 "libprotobuf-cpp-lite",
127 "libpropertyinfoserializer",
128 "libpropertyinfoparser",
David Andersondfe6d072019-10-09 16:24:03 -0700129 "libsnapshot_init",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900130 "lib_apex_manifest_proto_lite",
Jiyong Park787322c2018-06-01 19:26:42 +0900131 ],
132 shared_libs: [
Tom Cherry59656fb2019-05-28 10:19:44 -0700133 "libbacktrace",
Jiyong Park787322c2018-06-01 19:26:42 +0900134 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700135 "libbootloader_message",
136 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900137 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700138 "libext4_utils",
139 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800140 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700141 "libhidl-gen-utils",
142 "libkeyutils",
143 "liblog",
144 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800145 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800146 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800147 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900148 "libselinux",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200149 "libutils",
Tom Cherry618d3102018-01-19 14:25:48 -0800150 ],
Jiyong Park93318d42018-12-26 17:34:39 +0900151 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700152 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700153}
154
155cc_library_static {
156 name: "libinit",
Tom Cherry31438482018-07-20 14:57:00 -0700157 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700158 defaults: [
159 "init_defaults",
160 "selinux_policy_version",
161 ],
Tom Cherry66196492020-02-06 11:56:58 -0800162 srcs: init_common_sources + init_device_sources,
Daniel Norman8082ba22019-07-23 10:26:15 -0700163 whole_static_libs: [
164 "libcap",
165 "com.android.sysprop.apex",
Nikita Ioffe23dbd6d2019-11-14 01:21:24 +0000166 "com.android.sysprop.init",
Daniel Norman8082ba22019-07-23 10:26:15 -0700167 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700168 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700169 proto: {
170 type: "lite",
171 export_proto_headers: true,
172 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200173
174 target: {
175 recovery: {
176 cflags: ["-DRECOVERY"],
Daniel Norman8082ba22019-07-23 10:26:15 -0700177 exclude_shared_libs: [
178 "libbinder",
179 "libutils",
180 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200181 },
182 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700183}
184
Steven Morelandceb36d02019-07-15 15:12:56 -0700185phony {
186 name: "init",
187 required: [
188 "init_second_stage",
189 ],
190}
191
Tom Cherry14fc0132017-05-09 17:11:57 -0700192cc_binary {
Tom Cherry31438482018-07-20 14:57:00 -0700193 name: "init_second_stage",
194 recovery_available: true,
195 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700196 defaults: ["init_defaults"],
Tom Cherry31438482018-07-20 14:57:00 -0700197 static_libs: ["libinit"],
Jin Qian00456972017-07-06 11:43:45 -0700198 required: [
199 "e2fsdroid",
Tom Cherryc9f53532019-11-04 10:30:36 -0800200 "init.rc",
Jin Qian00456972017-07-06 11:43:45 -0700201 "mke2fs",
Jaegeuk Kim899ad552017-11-28 19:26:34 -0800202 "sload_f2fs",
203 "make_f2fs",
Tom Cherryc9f53532019-11-04 10:30:36 -0800204 "ueventd.rc",
Jin Qian00456972017-07-06 11:43:45 -0700205 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800206 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700207 symlinks: ["ueventd"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200208 target: {
209 recovery: {
210 cflags: ["-DRECOVERY"],
Daniel Norman8082ba22019-07-23 10:26:15 -0700211 exclude_shared_libs: [
212 "libbinder",
213 "libutils",
214 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200215 },
216 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700217}
Tom Cherry14fc0132017-05-09 17:11:57 -0700218
219// Tests
220// ------------------------------------------------------------------------------
221
222cc_test {
Tom Cherry17b2be02019-08-20 10:43:48 -0700223 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700224 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700225 require_root: true,
226
Tom Cherry17b2be02019-08-20 10:43:48 -0700227 compile_multilib: "both",
228 multilib: {
229 lib32: {
230 suffix: "32",
231 },
232 lib64: {
233 suffix: "64",
234 },
235 },
236
Tom Cherry14fc0132017-05-09 17:11:57 -0700237 srcs: [
238 "devices_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700239 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700240 "init_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700241 "keychords_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700242 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700243 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800244 "property_type_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700245 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700246 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700247 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700248 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700249 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700250 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700251 "util_test.cpp",
252 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800253 static_libs: ["libinit"],
Tom Cherry17b2be02019-08-20 10:43:48 -0700254
255 test_suites: [
256 "cts",
257 "device-tests",
258 "vts",
259 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700260}
261
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700262cc_benchmark {
263 name: "init_benchmarks",
264 defaults: ["init_defaults"],
265 srcs: [
266 "subcontext_benchmark.cpp",
267 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800268 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700269}
270
Tom Cherrya2f91362020-02-20 10:50:00 -0800271cc_defaults {
272 name: "libinit_test_utils_libraries_defaults",
273 shared_libs: [
274 "libbase",
275 "libcutils",
276 "libselinux",
277 "libhidl-gen-utils",
278 "liblog",
279 "libprocessgroup",
280 "libprotobuf-cpp-lite",
281 ],
282}
283
284cc_library_static {
285 name: "libinit_test_utils",
286 defaults: ["libinit_test_utils_libraries_defaults"],
287 cflags: [
288 "-Wall",
289 "-Wextra",
290 "-Wno-unused-parameter",
291 "-Werror",
292 ],
293 srcs: init_common_sources + [
294 "test_utils/service_utils.cpp",
295 ],
296 whole_static_libs: [
297 "libcap",
298 ],
299 export_include_dirs: ["test_utils/include"], // for tests
300}
301
Tom Cherryde6bd502018-02-13 16:50:08 -0800302// Host Verifier
303// ------------------------------------------------------------------------------
304
305genrule {
306 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700307 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800308 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700309 srcs: [
310 "builtins.cpp",
311 "check_builtins.cpp",
312 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700313 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800314}
315
316cc_binary {
317 name: "host_init_verifier",
318 host_supported: true,
319 cpp_std: "experimental",
320 cflags: [
321 "-Wall",
322 "-Wextra",
323 "-Wno-unused-parameter",
324 "-Werror",
325 ],
326 static_libs: [
327 "libbase",
328 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800329 "libpropertyinfoserializer",
330 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800331 ],
332 whole_static_libs: ["libcap"],
333 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800334 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700335 "libhidl-gen-utils",
Steven Moreland422a7582019-10-15 14:53:19 -0700336 "libhidlmetadata",
Daniel Norman3f42a762019-07-09 11:00:53 -0700337 "liblog",
338 "libprocessgroup",
339 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800340 ],
Tom Cherry66196492020-02-06 11:56:58 -0800341 srcs: init_common_sources + init_host_sources,
Tom Cherryde6bd502018-02-13 16:50:08 -0800342 proto: {
343 type: "lite",
344 },
Yifan Hong3c4aa112018-06-20 22:49:48 +0000345 generated_headers: [
346 "generated_stub_builtin_function_map",
Daniel Norman8082ba22019-07-23 10:26:15 -0700347 "generated_android_ids",
Yifan Hong3c4aa112018-06-20 22:49:48 +0000348 ],
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800349 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800350 android: {
351 enabled: false,
352 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800353 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000354 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800355 },
356 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800357}