Android.bp 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. // Copyright (C) 2018 The Android Open Source Project
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. filegroup {
  15. name: "iorap-aidl",
  16. srcs: [
  17. // note: using **/* doesn't work, so list each file one by one:
  18. // see also b/70046217
  19. // note: list only 'interface' aidl files, otherwise
  20. // aidl generates an error "Refusing to generate code with unstructured parcelables."
  21. "binder/com/google/android/startop/iorap/IIorap.aidl",
  22. "binder/com/google/android/startop/iorap/ITaskListener.aidl",
  23. ],
  24. }
  25. cc_defaults {
  26. name: "iorap-default-flags",
  27. cflags: [
  28. "-Wall",
  29. "-Werror",
  30. "-Wextra",
  31. "-Wno-missing-field-initializers",
  32. "-Wno-unused-parameter",
  33. "-Wno-unused-variable",
  34. ],
  35. local_include_dirs: [
  36. "include",
  37. "src",
  38. ],
  39. // TODO: shouldn't need this but there's a soong/cmake generator bug.
  40. export_include_dirs: [
  41. "include",
  42. "src",
  43. ],
  44. /*
  45. TODO: Header refactoring cleanup:
  46. Option 1): Move src/$component/file_name.h to src/$component/include/$component/file_name.h
  47. Option 2): Symlink src/$component/include/$component to src/$component
  48. Set export_include_dirs to '$component/include' for that component.
  49. Also delete the 'include' directory unless we have code other non-iorap
  50. targets are allowed to reference.
  51. */
  52. clang: true,
  53. shared_libs: ["libbase"],
  54. }
  55. cc_defaults {
  56. name: "iorap-default-dependencies",
  57. static_libs: [
  58. "libiorap-binder",
  59. "libplatformprotos", // android framework C++ protos.
  60. ],
  61. shared_libs: [
  62. "libbinder",
  63. "libutils",
  64. "libcutils", // tracing.
  65. "libfruit", // dependency injection.
  66. // TODO: remove these annoying dependencies by hiding them in the main library code.
  67. // dependency for libplatformprotos
  68. // "libprotobuf-cpp-lite",
  69. // libplatformprotos has an indirect dependency on full, causing compilation/linking
  70. // errors if we use lite
  71. "libprotobuf-cpp-full",
  72. ],
  73. // srcs: [":libprotobuf-internal-protos"],
  74. // commented out because it causes compilation errors
  75. // TODO: can we use the lite library somehow?
  76. header_libs: ["librxcpp"],
  77. }
  78. cc_library_static {
  79. name: "libiorap-binder",
  80. defaults: ["iorap-default-flags"],
  81. srcs: [
  82. ":iorap-aidl",
  83. "src/binder/iiorap_impl.cc",
  84. ],
  85. shared_libs: [
  86. "libbinder",
  87. "libutils",
  88. "libcutils", // tracing.
  89. ],
  90. aidl: {
  91. local_include_dirs: ["binder"],
  92. include_dirs: ["frameworks/native/aidl/binder"],
  93. export_aidl_headers: true,
  94. },
  95. static_libs: [
  96. "libplatformprotos", // android framework C++ protos.
  97. ],
  98. }
  99. cc_defaults {
  100. name: "libiorap-manager-default-dependencies",
  101. static_libs: [
  102. "libiorap-perfetto",
  103. ],
  104. defaults: [
  105. "libiorap-perfetto-default-dependencies",
  106. ],
  107. // Users of 'libiorap-manager' also need to include these defaults to avoid
  108. // linking errors.
  109. }
  110. cc_library_static {
  111. name: "libiorap-manager",
  112. defaults: [
  113. "iorap-default-flags",
  114. "iorap-default-dependencies",
  115. "libiorap-manager-default-dependencies",
  116. ],
  117. srcs: [
  118. "src/manager/**/*.cc",
  119. ],
  120. }
  121. cc_binary {
  122. name: "iorapd",
  123. defaults: [
  124. "iorap-default-flags",
  125. "iorap-default-dependencies",
  126. "libiorap-manager-default-dependencies",
  127. ],
  128. srcs: [
  129. "src/iorapd/main.cc",
  130. ],
  131. static_libs: [
  132. "libiorap-manager",
  133. ],
  134. init_rc: [
  135. "iorapd.rc",
  136. ],
  137. }
  138. cc_library_static {
  139. name: "libiorap-inode2filename",
  140. defaults: [
  141. "iorap-default-flags",
  142. "iorap-default-dependencies",
  143. ],
  144. srcs: [
  145. "src/inode2filename/**/*.cc",
  146. ],
  147. }
  148. cc_binary {
  149. name: "iorap.inode2filename",
  150. defaults: [
  151. "iorap-default-flags",
  152. "iorap-default-dependencies",
  153. ],
  154. srcs: [
  155. "src/inode2filename/**/*.cc",
  156. ],
  157. // Easier debugging. TODO: make a separate debug config.
  158. // XX: Using -O0 seems to completely hide some errors.
  159. cflags: ["-O2", "-UNDEBUG", "-DIORAP_INODE2FILENAME_MAIN=1"],
  160. sanitize: {
  161. undefined: true,
  162. all_undefined: true,
  163. // Pretty print when ubsan detects a problem.
  164. // Otherwise it just calls abort().
  165. /*
  166. diag: {
  167. undefined: true,
  168. },
  169. */ // don't use the diag when you want it to crash.
  170. },
  171. }
  172. cc_test {
  173. name: "iorapd-tests",
  174. test_suites: ["device-tests"],
  175. gtest: false, // we use gtest *and* gmock.
  176. defaults: [
  177. "iorap-default-flags",
  178. "iorap-default-dependencies",
  179. ],
  180. srcs: [
  181. "tests/src/**/*.cc",
  182. ],
  183. cflags: ["-O2", "-UNDEBUG"],
  184. // TODO: we should probably have per-component tests.
  185. static_libs: ["libgmock_main", "libgmock", "libgtest", "libiorap-inode2filename"],
  186. }
  187. filegroup {
  188. name: "libiorap-perfetto-protos",
  189. srcs: [
  190. ],
  191. }
  192. // Static libraries cannot export their dependencies,
  193. // the current convention is to use an extra 'defaults' rule for statics
  194. // to bring in all the dependencies.
  195. cc_defaults {
  196. name: "libiorap-perfetto-default-dependencies",
  197. // Some of the libperfetto header typedefs leak out into iorap.
  198. // Avoids compilation #include errors.
  199. // TODO: clean this up, the headers should not leak out (maybe all we need is a PerfettoConsumer
  200. // forward declaration?).
  201. include_dirs: ["external/perfetto/include"],
  202. // Various perfetto protos are used directly by iorap.
  203. //
  204. // Furthermore, we need this regardless to avoid linking errors when linking
  205. // libiorap-perfetto.a into the main cc_binary rule.
  206. static_libs: [
  207. "perfetto_trace_protos",
  208. ],
  209. shared_libs: [
  210. // Not part of true dependencies: Users of 'libiorap-perfetto' do not link against
  211. // libperfetto.
  212. // We only put this to avoid linking errors when building iorapd.
  213. // TODO: can we split iorapd into libiorapd-main that doesn't link against libperfetto?
  214. // only the last cc_binary should need the full transitive closure of the dependency graph.
  215. "libperfetto",
  216. ]
  217. }
  218. cc_library_static {
  219. name: "libiorap-perfetto",
  220. defaults: [
  221. "iorap-default-flags",
  222. "iorap-default-dependencies",
  223. "libiorap-perfetto-default-dependencies",
  224. ],
  225. srcs: [
  226. "src/perfetto/**/*.cc",
  227. ],
  228. }
  229. cc_binary {
  230. name: "iorap.cmd.perfetto",
  231. defaults: [
  232. "iorap-default-flags",
  233. "iorap-default-dependencies",
  234. ],
  235. shared_libs: ["libperfetto"],
  236. include_dirs: ["external/perfetto/include"],
  237. srcs: [
  238. "src/perfetto/**/*.cc",
  239. ],
  240. // Easier debugging. TODO: make a separate debug config.
  241. // XX: Using -O0 seems to completely hide some errors.
  242. cflags: ["-O2", "-UNDEBUG", "-DIORAP_PERFETTO_MAIN=1"],
  243. sanitize: {
  244. undefined: true,
  245. all_undefined: true,
  246. // Pretty print when ubsan detects a problem.
  247. // Otherwise it just calls abort().
  248. /*
  249. diag: {
  250. undefined: true,
  251. },
  252. */ // don't use the diag when you want it to crash.
  253. },
  254. static_libs: [
  255. "perfetto_trace_protos",
  256. ],
  257. }