blob: 1efbdc00314bfb1c802480520934607a24ee7dd4 [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",
Steve Mucklea4bf2ce2019-11-01 13:58:02 -070044 "first_stage_console.cpp",
Tom Cherry66196492020-02-06 11:56:58 -080045 "first_stage_init.cpp",
46 "first_stage_mount.cpp",
47 "fscrypt_init_extensions.cpp",
48 "init.cpp",
49 "lmkd_service.cpp",
50 "modalias_handler.cpp",
51 "mount_handler.cpp",
52 "mount_namespace.cpp",
53 "persistent_properties.cpp",
54 "persistent_properties.proto",
55 "property_service.cpp",
56 "property_service.proto",
57 "reboot.cpp",
58 "reboot_utils.cpp",
59 "security.cpp",
60 "selabel.cpp",
61 "selinux.cpp",
62 "sigchld_handler.cpp",
63 "switch_root.cpp",
64 "uevent_listener.cpp",
65 "ueventd.cpp",
66 "ueventd_parser.cpp",
67]
68init_host_sources = [
69 "check_builtins.cpp",
70 "host_import_parser.cpp",
71 "host_init_verifier.cpp",
72]
73
Tom Cherry14fc0132017-05-09 17:11:57 -070074cc_defaults {
75 name: "init_defaults",
76 cpp_std: "experimental",
77 sanitize: {
Tom Cherry2ffd65e2017-07-26 14:17:09 -070078 misc_undefined: ["signed-integer-overflow"],
Tom Cherry14fc0132017-05-09 17:11:57 -070079 },
Chih-Hung Hsieh122352d2017-10-02 15:20:07 -070080 cflags: [
Tom Cherry14fc0132017-05-09 17:11:57 -070081 "-DLOG_UEVENTS=0",
82 "-Wall",
83 "-Wextra",
84 "-Wno-unused-parameter",
85 "-Werror",
Tom Cherry802864c2020-03-12 14:29:25 -070086 "-Wthread-safety",
Steve Muckled75f30a2019-05-21 15:50:39 -070087 "-DALLOW_FIRST_STAGE_CONSOLE=0",
Tom Cherry14fc0132017-05-09 17:11:57 -070088 "-DALLOW_LOCAL_PROP_OVERRIDE=0",
89 "-DALLOW_PERMISSIVE_SELINUX=0",
90 "-DREBOOT_BOOTLOADER_ON_PANIC=0",
91 "-DWORLD_WRITABLE_KMSG=0",
92 "-DDUMP_ON_UMOUNT_FAILURE=0",
93 "-DSHUTDOWN_ZERO_TIMEOUT=0",
Tom Cherrya2f91362020-02-20 10:50:00 -080094 "-DINIT_FULL_SOURCES",
Tom Cherry14fc0132017-05-09 17:11:57 -070095 ],
96 product_variables: {
97 debuggable: {
98 cppflags: [
Steve Muckled75f30a2019-05-21 15:50:39 -070099 "-UALLOW_FIRST_STAGE_CONSOLE",
100 "-DALLOW_FIRST_STAGE_CONSOLE=1",
Tom Cherry14fc0132017-05-09 17:11:57 -0700101 "-UALLOW_LOCAL_PROP_OVERRIDE",
102 "-DALLOW_LOCAL_PROP_OVERRIDE=1",
103 "-UALLOW_PERMISSIVE_SELINUX",
104 "-DALLOW_PERMISSIVE_SELINUX=1",
105 "-UREBOOT_BOOTLOADER_ON_PANIC",
106 "-DREBOOT_BOOTLOADER_ON_PANIC=1",
107 "-UWORLD_WRITABLE_KMSG",
108 "-DWORLD_WRITABLE_KMSG=1",
109 "-UDUMP_ON_UMOUNT_FAILURE",
110 "-DDUMP_ON_UMOUNT_FAILURE=1",
111 ],
112 },
113 eng: {
114 cppflags: [
115 "-USHUTDOWN_ZERO_TIMEOUT",
116 "-DSHUTDOWN_ZERO_TIMEOUT=1",
117 ],
118 },
Dmitry Shmidtc3bc5092017-08-23 14:57:07 -0700119 uml: {
120 cppflags: ["-DUSER_MODE_LINUX"],
Elliott Hughesdc699a22018-02-16 17:58:14 -0800121 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700122 },
Tom Cherry618d3102018-01-19 14:25:48 -0800123 static_libs: [
Tom Cherry618d3102018-01-19 14:25:48 -0800124 "libavb",
Bowgo Tsai30afda72019-04-11 23:57:24 +0800125 "libc++fs",
Yifan Hongd8ce1fb2019-03-22 17:21:58 -0700126 "libcgrouprc_format",
Suren Baghdasaryanc29c2ba2019-10-22 17:18:42 -0700127 "liblmkd_utils",
Steve Muckle18b981e2019-04-15 17:43:02 -0700128 "libmodprobe",
Tom Cherry618d3102018-01-19 14:25:48 -0800129 "libprotobuf-cpp-lite",
130 "libpropertyinfoserializer",
131 "libpropertyinfoparser",
David Andersonaca0bea2020-09-21 16:34:25 -0700132 "libsnapshot_cow",
David Andersondfe6d072019-10-09 16:24:03 -0700133 "libsnapshot_init",
Jooyung Han1d951b72020-07-05 03:33:36 +0900134 "libxml2",
Jiyong Park648ae3a2019-12-08 00:25:15 +0900135 "lib_apex_manifest_proto_lite",
Yifan Hong66f01152020-04-16 11:05:16 -0700136 "update_metadata-protos",
Jiyong Park787322c2018-06-01 19:26:42 +0900137 ],
138 shared_libs: [
Tom Cherry59656fb2019-05-28 10:19:44 -0700139 "libbacktrace",
Jiyong Park787322c2018-06-01 19:26:42 +0900140 "libbase",
Tao Bao66209ca2018-07-25 22:35:45 -0700141 "libbootloader_message",
142 "libcutils",
Jiyong Park787322c2018-06-01 19:26:42 +0900143 "libdl",
Tao Bao66209ca2018-07-25 22:35:45 -0700144 "libext4_utils",
145 "libfs_mgr",
David Anderson0e330f12019-01-03 18:16:56 -0800146 "libgsi",
Tao Bao66209ca2018-07-25 22:35:45 -0700147 "libhidl-gen-utils",
148 "libkeyutils",
149 "liblog",
150 "liblogwrap",
Tom Cherry7bfea3d2018-11-06 14:12:05 -0800151 "liblp",
Suren Baghdasaryan82b72a52018-12-21 11:41:50 -0800152 "libprocessgroup",
Yifan Hong6f9ce2e2019-03-05 15:47:16 -0800153 "libprocessgroup_setup",
Jiyong Park012171d2018-06-19 16:55:05 +0900154 "libselinux",
Martijn Coenen62e985a2018-09-04 06:29:14 +0200155 "libutils",
Tom Cherry618d3102018-01-19 14:25:48 -0800156 ],
Jiyong Park93318d42018-12-26 17:34:39 +0900157 bootstrap: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700158 visibility: [":__subpackages__"],
Tom Cherry14fc0132017-05-09 17:11:57 -0700159}
160
161cc_library_static {
162 name: "libinit",
Tom Cherry31438482018-07-20 14:57:00 -0700163 recovery_available: true,
Daniel Norman8082ba22019-07-23 10:26:15 -0700164 defaults: [
165 "init_defaults",
166 "selinux_policy_version",
167 ],
Tom Cherry66196492020-02-06 11:56:58 -0800168 srcs: init_common_sources + init_device_sources,
Jooyung Han1d951b72020-07-05 03:33:36 +0900169 generated_sources: [
170 "apex-info-list",
171 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700172 whole_static_libs: [
173 "libcap",
174 "com.android.sysprop.apex",
Nikita Ioffe23dbd6d2019-11-14 01:21:24 +0000175 "com.android.sysprop.init",
Daniel Norman8082ba22019-07-23 10:26:15 -0700176 ],
Jayant Chowdhary478c7c12018-03-28 18:45:35 -0700177 header_libs: ["bootimg_headers"],
Tom Cherrya97faba2017-09-15 15:44:04 -0700178 proto: {
179 type: "lite",
180 export_proto_headers: true,
181 },
Martijn Coenen62e985a2018-09-04 06:29:14 +0200182
183 target: {
184 recovery: {
185 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900186 exclude_static_libs: [
187 "libxml2",
188 ],
189 exclude_generated_sources: [
190 "apex-info-list",
191 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700192 exclude_shared_libs: [
193 "libbinder",
194 "libutils",
195 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200196 },
197 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700198}
199
Steven Morelandceb36d02019-07-15 15:12:56 -0700200phony {
201 name: "init",
202 required: [
203 "init_second_stage",
204 ],
205}
206
Tom Cherry14fc0132017-05-09 17:11:57 -0700207cc_binary {
Tom Cherry31438482018-07-20 14:57:00 -0700208 name: "init_second_stage",
209 recovery_available: true,
210 stem: "init",
Tom Cherry14fc0132017-05-09 17:11:57 -0700211 defaults: ["init_defaults"],
Tom Cherry31438482018-07-20 14:57:00 -0700212 static_libs: ["libinit"],
Jin Qian00456972017-07-06 11:43:45 -0700213 required: [
214 "e2fsdroid",
Tom Cherryc9f53532019-11-04 10:30:36 -0800215 "init.rc",
Jin Qian00456972017-07-06 11:43:45 -0700216 "mke2fs",
Jaegeuk Kim899ad552017-11-28 19:26:34 -0800217 "sload_f2fs",
218 "make_f2fs",
Tom Cherryc9f53532019-11-04 10:30:36 -0800219 "ueventd.rc",
Jin Qian00456972017-07-06 11:43:45 -0700220 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800221 srcs: ["main.cpp"],
Tom Cherry31438482018-07-20 14:57:00 -0700222 symlinks: ["ueventd"],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200223 target: {
224 recovery: {
225 cflags: ["-DRECOVERY"],
Jooyung Han1d951b72020-07-05 03:33:36 +0900226 exclude_static_libs: [
227 "libxml2",
228 ],
Daniel Norman8082ba22019-07-23 10:26:15 -0700229 exclude_shared_libs: [
230 "libbinder",
231 "libutils",
232 ],
Martijn Coenen62e985a2018-09-04 06:29:14 +0200233 },
234 },
Tom Cherry14fc0132017-05-09 17:11:57 -0700235}
Tom Cherry14fc0132017-05-09 17:11:57 -0700236
237// Tests
238// ------------------------------------------------------------------------------
239
240cc_test {
Tom Cherry17b2be02019-08-20 10:43:48 -0700241 name: "CtsInitTestCases",
Tom Cherry14fc0132017-05-09 17:11:57 -0700242 defaults: ["init_defaults"],
Josh Gao6cad1392019-08-27 16:02:38 -0700243 require_root: true,
244
Tom Cherry17b2be02019-08-20 10:43:48 -0700245 compile_multilib: "both",
246 multilib: {
247 lib32: {
248 suffix: "32",
249 },
250 lib64: {
251 suffix: "64",
252 },
253 },
254
Tom Cherry14fc0132017-05-09 17:11:57 -0700255 srcs: [
256 "devices_test.cpp",
Tom Cherrydcb3d152019-08-07 16:02:28 -0700257 "firmware_handler_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700258 "init_test.cpp",
Mark Salyzyn75b901d2018-05-15 11:19:43 -0700259 "keychords_test.cpp",
Tom Cherrybdbf5042020-03-04 10:52:08 -0800260 "oneshot_on_test.cpp",
Tom Cherry16fad422017-08-04 15:59:03 -0700261 "persistent_properties_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700262 "property_service_test.cpp",
Tom Cherry927c5d52017-12-11 01:40:07 -0800263 "property_type_test.cpp",
Nikita Ioffe660ffde2020-12-10 16:52:35 +0000264 "reboot_test.cpp",
Tom Cherry7ac013d2017-08-25 10:39:25 -0700265 "rlimit_parser_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700266 "service_test.cpp",
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700267 "subcontext_test.cpp",
Tom Cherry2a5a4e72018-06-26 13:56:34 -0700268 "tokenizer_test.cpp",
Tom Cherry5f0198b2018-07-17 15:28:16 -0700269 "ueventd_parser_test.cpp",
Tom Cherryc2e181c2017-07-14 16:29:23 -0700270 "ueventd_test.cpp",
Tom Cherry14fc0132017-05-09 17:11:57 -0700271 "util_test.cpp",
272 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800273 static_libs: ["libinit"],
Tom Cherry17b2be02019-08-20 10:43:48 -0700274
275 test_suites: [
276 "cts",
277 "device-tests",
Tom Cherry17b2be02019-08-20 10:43:48 -0700278 ],
Tom Cherry14fc0132017-05-09 17:11:57 -0700279}
280
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700281cc_benchmark {
282 name: "init_benchmarks",
283 defaults: ["init_defaults"],
284 srcs: [
285 "subcontext_benchmark.cpp",
286 ],
Tom Cherry618d3102018-01-19 14:25:48 -0800287 static_libs: ["libinit"],
Tom Cherrycb0f9bb2017-09-12 15:58:47 -0700288}
289
Tom Cherrya2f91362020-02-20 10:50:00 -0800290cc_defaults {
291 name: "libinit_test_utils_libraries_defaults",
292 shared_libs: [
293 "libbase",
294 "libcutils",
295 "libselinux",
296 "libhidl-gen-utils",
297 "liblog",
298 "libprocessgroup",
299 "libprotobuf-cpp-lite",
300 ],
301}
302
303cc_library_static {
304 name: "libinit_test_utils",
305 defaults: ["libinit_test_utils_libraries_defaults"],
306 cflags: [
307 "-Wall",
308 "-Wextra",
309 "-Wno-unused-parameter",
310 "-Werror",
311 ],
312 srcs: init_common_sources + [
313 "test_utils/service_utils.cpp",
314 ],
315 whole_static_libs: [
316 "libcap",
317 ],
318 export_include_dirs: ["test_utils/include"], // for tests
319}
320
Tom Cherryde6bd502018-02-13 16:50:08 -0800321// Host Verifier
322// ------------------------------------------------------------------------------
323
324genrule {
325 name: "generated_stub_builtin_function_map",
Tom Cherry4772f1d2019-07-30 09:34:41 -0700326 tool_files: ["host_builtin_map.py"],
Tom Cherryde6bd502018-02-13 16:50:08 -0800327 out: ["generated_stub_builtin_function_map.h"],
Daniel Normand2533c32019-08-02 15:13:50 -0700328 srcs: [
329 "builtins.cpp",
330 "check_builtins.cpp",
331 ],
Tom Cherry4772f1d2019-07-30 09:34:41 -0700332 cmd: "$(location host_builtin_map.py) --builtins $(location builtins.cpp) --check_builtins $(location check_builtins.cpp) > $(out)",
Tom Cherryde6bd502018-02-13 16:50:08 -0800333}
334
335cc_binary {
336 name: "host_init_verifier",
337 host_supported: true,
338 cpp_std: "experimental",
339 cflags: [
340 "-Wall",
341 "-Wextra",
342 "-Wno-unused-parameter",
343 "-Werror",
344 ],
345 static_libs: [
346 "libbase",
347 "libselinux",
Tom Cherryb5f2ec02019-11-08 17:54:27 -0800348 "libpropertyinfoserializer",
349 "libpropertyinfoparser",
Tom Cherryde6bd502018-02-13 16:50:08 -0800350 ],
351 whole_static_libs: ["libcap"],
352 shared_libs: [
Tom Cherryde6bd502018-02-13 16:50:08 -0800353 "libcutils",
Daniel Norman3f42a762019-07-09 11:00:53 -0700354 "libhidl-gen-utils",
Steven Moreland422a7582019-10-15 14:53:19 -0700355 "libhidlmetadata",
Daniel Norman3f42a762019-07-09 11:00:53 -0700356 "liblog",
357 "libprocessgroup",
358 "libprotobuf-cpp-lite",
Tom Cherryde6bd502018-02-13 16:50:08 -0800359 ],
Tom Cherry66196492020-02-06 11:56:58 -0800360 srcs: init_common_sources + init_host_sources,
Tom Cherryde6bd502018-02-13 16:50:08 -0800361 proto: {
362 type: "lite",
363 },
Yifan Hong3c4aa112018-06-20 22:49:48 +0000364 generated_headers: [
365 "generated_stub_builtin_function_map",
Daniel Norman8082ba22019-07-23 10:26:15 -0700366 "generated_android_ids",
Yifan Hong3c4aa112018-06-20 22:49:48 +0000367 ],
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800368 target: {
Tom Cherry547f7312018-02-28 21:40:46 -0800369 android: {
370 enabled: false,
371 },
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800372 darwin: {
Yifan Hong3c4aa112018-06-20 22:49:48 +0000373 enabled: false,
Tom Cherry96ff0fe2018-02-28 17:20:27 -0800374 },
375 },
Tom Cherryde6bd502018-02-13 16:50:08 -0800376}