Android.bp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. cc_defaults {
  17. name: "init_defaults",
  18. cpp_std: "experimental",
  19. sanitize: {
  20. misc_undefined: ["signed-integer-overflow"],
  21. },
  22. cflags: [
  23. "-DLOG_UEVENTS=0",
  24. "-Wall",
  25. "-Wextra",
  26. "-Wno-unused-parameter",
  27. "-Werror",
  28. "-DALLOW_LOCAL_PROP_OVERRIDE=0",
  29. "-DALLOW_PERMISSIVE_SELINUX=0",
  30. "-DREBOOT_BOOTLOADER_ON_PANIC=0",
  31. "-DWORLD_WRITABLE_KMSG=0",
  32. "-DDUMP_ON_UMOUNT_FAILURE=0",
  33. "-DSHUTDOWN_ZERO_TIMEOUT=0",
  34. ],
  35. product_variables: {
  36. debuggable: {
  37. cppflags: [
  38. "-UALLOW_LOCAL_PROP_OVERRIDE",
  39. "-DALLOW_LOCAL_PROP_OVERRIDE=1",
  40. "-UALLOW_PERMISSIVE_SELINUX",
  41. "-DALLOW_PERMISSIVE_SELINUX=1",
  42. "-UREBOOT_BOOTLOADER_ON_PANIC",
  43. "-DREBOOT_BOOTLOADER_ON_PANIC=1",
  44. "-UWORLD_WRITABLE_KMSG",
  45. "-DWORLD_WRITABLE_KMSG=1",
  46. "-UDUMP_ON_UMOUNT_FAILURE",
  47. "-DDUMP_ON_UMOUNT_FAILURE=1",
  48. ],
  49. },
  50. eng: {
  51. cppflags: [
  52. "-USHUTDOWN_ZERO_TIMEOUT",
  53. "-DSHUTDOWN_ZERO_TIMEOUT=1",
  54. ],
  55. },
  56. uml: {
  57. cppflags: ["-DUSER_MODE_LINUX"],
  58. },
  59. },
  60. static_libs: [
  61. "libseccomp_policy",
  62. "libavb",
  63. "libc++fs",
  64. "libcgrouprc_format",
  65. "libprotobuf-cpp-lite",
  66. "libpropertyinfoserializer",
  67. "libpropertyinfoparser",
  68. ],
  69. shared_libs: [
  70. "libbacktrace",
  71. "libbase",
  72. "libbinder",
  73. "libbootloader_message",
  74. "libcutils",
  75. "libcrypto",
  76. "libdl",
  77. "libext4_utils",
  78. "libfs_mgr",
  79. "libfscrypt",
  80. "libgsi",
  81. "libhidl-gen-utils",
  82. "libkeyutils",
  83. "liblog",
  84. "liblogwrap",
  85. "liblp",
  86. "libprocessgroup",
  87. "libprocessgroup_setup",
  88. "libselinux",
  89. "libutils",
  90. ],
  91. bootstrap: true,
  92. }
  93. cc_library_static {
  94. name: "libinit",
  95. recovery_available: true,
  96. defaults: ["init_defaults", "selinux_policy_version"],
  97. srcs: [
  98. "action.cpp",
  99. "action_manager.cpp",
  100. "action_parser.cpp",
  101. "boringssl_self_test.cpp",
  102. "bootchart.cpp",
  103. "builtins.cpp",
  104. "capabilities.cpp",
  105. "descriptors.cpp",
  106. "devices.cpp",
  107. "epoll.cpp",
  108. "firmware_handler.cpp",
  109. "first_stage_init.cpp",
  110. "first_stage_mount.cpp",
  111. "import_parser.cpp",
  112. "init.cpp",
  113. "keychords.cpp",
  114. "modalias_handler.cpp",
  115. "mount_handler.cpp",
  116. "mount_namespace.cpp",
  117. "parser.cpp",
  118. "persistent_properties.cpp",
  119. "persistent_properties.proto",
  120. "property_service.cpp",
  121. "property_type.cpp",
  122. "reboot.cpp",
  123. "reboot_utils.cpp",
  124. "security.cpp",
  125. "selinux.cpp",
  126. "service.cpp",
  127. "sigchld_handler.cpp",
  128. "subcontext.cpp",
  129. "subcontext.proto",
  130. "switch_root.cpp",
  131. "rlimit_parser.cpp",
  132. "tokenizer.cpp",
  133. "uevent_listener.cpp",
  134. "ueventd.cpp",
  135. "ueventd_parser.cpp",
  136. "util.cpp",
  137. ],
  138. whole_static_libs: ["libcap", "com.android.sysprop.apex"],
  139. header_libs: ["bootimg_headers"],
  140. proto: {
  141. type: "lite",
  142. export_proto_headers: true,
  143. },
  144. target: {
  145. recovery: {
  146. cflags: ["-DRECOVERY"],
  147. exclude_shared_libs: ["libbinder", "libutils"],
  148. },
  149. },
  150. }
  151. cc_binary {
  152. name: "init_second_stage",
  153. recovery_available: true,
  154. stem: "init",
  155. defaults: ["init_defaults"],
  156. static_libs: ["libinit"],
  157. required: [
  158. "e2fsdroid",
  159. "mke2fs",
  160. "sload_f2fs",
  161. "make_f2fs",
  162. ],
  163. srcs: ["main.cpp"],
  164. symlinks: ["ueventd"],
  165. target: {
  166. recovery: {
  167. cflags: ["-DRECOVERY"],
  168. exclude_shared_libs: ["libbinder", "libutils"],
  169. },
  170. },
  171. ldflags: ["-Wl,--rpath,/system/${LIB}/bootstrap"],
  172. }
  173. // Tests
  174. // ------------------------------------------------------------------------------
  175. cc_test {
  176. name: "init_tests",
  177. defaults: ["init_defaults"],
  178. compile_multilib: "first",
  179. srcs: [
  180. "devices_test.cpp",
  181. "init_test.cpp",
  182. "keychords_test.cpp",
  183. "persistent_properties_test.cpp",
  184. "property_service_test.cpp",
  185. "property_type_test.cpp",
  186. "result_test.cpp",
  187. "rlimit_parser_test.cpp",
  188. "service_test.cpp",
  189. "subcontext_test.cpp",
  190. "tokenizer_test.cpp",
  191. "ueventd_parser_test.cpp",
  192. "ueventd_test.cpp",
  193. "util_test.cpp",
  194. ],
  195. static_libs: ["libinit"],
  196. test_suites: ["device-tests"],
  197. }
  198. cc_benchmark {
  199. name: "init_benchmarks",
  200. defaults: ["init_defaults"],
  201. srcs: [
  202. "subcontext_benchmark.cpp",
  203. ],
  204. static_libs: ["libinit"],
  205. }
  206. // Host Verifier
  207. // ------------------------------------------------------------------------------
  208. genrule {
  209. name: "generated_stub_builtin_function_map",
  210. out: ["generated_stub_builtin_function_map.h"],
  211. srcs: ["builtins.cpp"],
  212. 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)",
  213. }
  214. cc_binary {
  215. name: "host_init_verifier",
  216. host_supported: true,
  217. cpp_std: "experimental",
  218. cflags: [
  219. "-Wall",
  220. "-Wextra",
  221. "-Wno-unused-parameter",
  222. "-Werror",
  223. ],
  224. static_libs: [
  225. "libbase",
  226. "libselinux",
  227. ],
  228. whole_static_libs: ["libcap"],
  229. shared_libs: [
  230. "libprotobuf-cpp-lite",
  231. "libhidl-gen-utils",
  232. "libprocessgroup",
  233. "liblog",
  234. "libcutils",
  235. ],
  236. srcs: [
  237. "action.cpp",
  238. "action_manager.cpp",
  239. "action_parser.cpp",
  240. "capabilities.cpp",
  241. "descriptors.cpp",
  242. "epoll.cpp",
  243. "keychords.cpp",
  244. "import_parser.cpp",
  245. "host_import_parser.cpp",
  246. "host_init_verifier.cpp",
  247. "host_init_stubs.cpp",
  248. "parser.cpp",
  249. "rlimit_parser.cpp",
  250. "tokenizer.cpp",
  251. "service.cpp",
  252. "subcontext.cpp",
  253. "subcontext.proto",
  254. "util.cpp",
  255. ],
  256. proto: {
  257. type: "lite",
  258. },
  259. generated_headers: [
  260. "generated_stub_builtin_function_map",
  261. "generated_android_ids"
  262. ],
  263. target: {
  264. android: {
  265. enabled: false,
  266. },
  267. darwin: {
  268. enabled: false,
  269. },
  270. },
  271. }
  272. subdirs = ["*"]