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 15filegroup { 16 name: "iorap-aidl", 17 srcs: [ 18 // note: using **/* doesn't work, so list each file one by one: 19 // see also b/70046217 20 21 // note: list only 'interface' aidl files, otherwise 22 // aidl generates an error "Refusing to generate code with unstructured parcelables." 23 "binder/com/google/android/startop/iorap/IIorap.aidl", 24 "binder/com/google/android/startop/iorap/ITaskListener.aidl", 25 ], 26 path: "binder", 27} 28 29cc_defaults { 30 name: "iorap-default-flags", 31 32 cflags: [ 33 "-Wall", 34 "-Werror", 35 "-Wextra", 36 "-Wno-missing-field-initializers", 37 "-Wno-unused-parameter", 38 "-Wno-unused-variable", 39 ], 40 41 local_include_dirs: [ 42 "include", 43 "src", 44 ], 45 // TODO: shouldn't need this but there's a soong/cmake generator bug. 46 export_include_dirs: [ 47 "include", 48 "src", 49 ], 50 51 /* 52 TODO: Header refactoring cleanup: 53 54 Option 1): Move src/$component/file_name.h to src/$component/include/$component/file_name.h 55 Option 2): Symlink src/$component/include/$component to src/$component 56 57 Set export_include_dirs to '$component/include' for that component. 58 59 Also delete the 'include' directory unless we have code other non-iorap 60 targets are allowed to reference. 61 */ 62 63 clang: true, 64 static_libs: ["libc++fs"], 65 shared_libs: ["libbase"], 66 67 // build all ioraps for host. 68 host_supported: true, 69} 70 71cc_defaults { 72 name: "iorap-default-dependencies", 73 74 static_libs: [ 75 "libiorap-binder", 76 "libplatformprotos", // android framework C++ protos. 77 ], 78 shared_libs: [ 79 "libbinder", 80 "libutils", 81 "libcutils", // tracing. 82 83 "libfruit", // dependency injection. 84 // TODO: remove these annoying dependencies by hiding them in the main library code. 85 86 // dependency for libplatformprotos 87 // "libprotobuf-cpp-lite", 88 89 // libplatformprotos has an indirect dependency on full, causing compilation/linking 90 // errors if we use lite 91 "libprotobuf-cpp-full", 92 93 // phenotype flags support 94 "server_configurable_flags", 95 ], 96 97 // srcs: [":libprotobuf-internal-protos"], 98 // commented out because it causes compilation errors 99 // TODO: can we use the lite library somehow? 100 101 header_libs: ["librxcpp"], 102} 103 104cc_library_static { 105 name: "libiorap-binder", 106 defaults: ["iorap-default-flags"], 107 108 srcs: [ 109 ":iorap-aidl", 110 "src/binder/iiorap_impl.cc", 111 "src/binder/package_change_observer.cc", 112 "src/binder/package_manager_remote.cc", 113 "src/binder/package_version_map.cc", 114 ], 115 shared_libs: [ 116 "libbinder", 117 "libutils", 118 "libcutils", // tracing. 119 ], 120 aidl: { 121 local_include_dirs: ["binder"], 122 include_dirs: ["frameworks/native/aidl/binder"], 123 export_aidl_headers: true, 124 }, 125 126 static_libs: [ 127 "libplatformprotos", // android framework C++ protos. 128 ], 129} 130 131cc_defaults { 132 name: "libiorap-manager-default-dependencies", 133 static_libs: [ 134 "libiorap-binder", 135 "libiorap-perfetto", 136 "libiorap-prefetcher", 137 "libiorap-db", 138 "libiorap-maintenance", 139 ], 140 defaults: [ 141 "libiorap-perfetto-default-dependencies", 142 "libiorap-prefetcher-default-dependencies", 143 "libiorap-db-default-dependencies", 144 ], 145 // Users of 'libiorap-manager' also need to include these defaults to avoid 146 // linking errors. 147} 148 149cc_library_static { 150 name: "libiorap-manager", 151 defaults: [ 152 "iorap-default-flags", 153 "iorap-default-dependencies", 154 "libiorap-manager-default-dependencies", 155 ], 156 157 srcs: [ 158 "src/manager/**/*.cc", 159 ], 160} 161 162cc_binary { 163 name: "iorapd", 164 defaults: [ 165 "iorap-default-flags", 166 "iorap-default-dependencies", 167 "libiorap-manager-default-dependencies", 168 ], 169 srcs: [ 170 "src/iorapd/main.cc", 171 ], 172 static_libs: [ 173 "libiorap-manager", 174 ], 175 init_rc: [ 176 "iorapd.rc", 177 ], 178 // iorapd fork+execs into iorap.prefetcherd and iorap.cmd.compiler 179 // maintenance used by tests 180 required: [ 181 "iorap.cmd.compiler", 182 "iorap.prefetcherd", 183 "iorap.cmd.maintenance", 184 ], 185} 186 187cc_library_static { 188 name: "libiorap-inode2filename", 189 defaults: [ 190 "iorap-default-flags", 191 "iorap-default-dependencies", 192 ], 193 194 srcs: [ 195 "src/inode2filename/**/*.cc", 196 ], 197} 198 199cc_binary { 200 name: "iorap.inode2filename", 201 defaults: [ 202 "iorap-default-flags", 203 "iorap-default-dependencies", 204 ], 205 srcs: [ 206 "src/inode2filename/**/*.cc", 207 ], 208 // Easier debugging. TODO: make a separate debug config. 209 // XX: Using -O0 seems to completely hide some errors. 210 cflags: ["-O2", "-UNDEBUG", "-DIORAP_INODE2FILENAME_MAIN=1"], 211 sanitize: { 212 undefined: true, 213 all_undefined: true, 214 // Pretty print when ubsan detects a problem. 215 // Otherwise it just calls abort(). 216 217/* 218 diag: { 219 undefined: true, 220 }, 221 */ // don't use the diag when you want it to crash. 222 }, 223} 224 225cc_test { 226 name: "iorapd-tests", 227 test_suites: ["device-tests"], 228 gtest: false, // we use gtest *and* gmock. 229 defaults: [ 230 "iorap-default-flags", 231 "iorap-default-dependencies", 232 "libiorap-compiler-default-dependencies", 233 ], 234 srcs: [ 235 "tests/src/binder/*.cc", 236 "tests/src/inode2filename/*.cc", 237 "tests/src/log/*.cc", 238 "tests/src/tmp/*.cc", 239 ], 240 data: [ 241 "tests/src/compiler/testdata/*", 242 ], 243 cflags: ["-O2", "-UNDEBUG"], 244 245 // TODO: we should probably have per-component tests. 246 static_libs: ["libgmock_main", "libgmock", "libgtest", "libiorap-inode2filename"], 247 248} 249 250 251cc_test_host { 252 name: "iorapd-host-tests", 253 gtest: false, // we use gtest *and* gmock. 254 defaults: [ 255 "iorap-default-flags", 256 "iorap-default-dependencies", 257 "libiorap-compiler-default-dependencies", 258 "libiorap-maintenance-default-dependencies", 259 ], 260 srcs: [ 261 "tests/src/compiler/*.cc", 262 "tests/src/db/*.cc", 263 "tests/src/maintenance/*.cc", 264 ], 265 data: [ 266 "tests/src/compiler/testdata/*", 267 "tests/src/maintenance/testdata/*", 268 ], 269 cflags: ["-O2", "-UNDEBUG"], 270 271 // TODO: we should probably have per-component tests. 272 static_libs: [ 273 "libgmock_main", 274 "libgmock", 275 "libgtest", 276 "libiorap-compiler", 277 "libiorap-maintenance", 278 ], 279} 280 281filegroup { 282 name: "libiorap-perfetto-protos", 283 srcs: [ 284 ], 285} 286 287// Static libraries cannot export their dependencies, 288// the current convention is to use an extra 'defaults' rule for statics 289// to bring in all the dependencies. 290cc_defaults { 291 name: "libiorap-perfetto-default-dependencies", 292 293 // Some of the libperfetto header typedefs leak out into iorap. 294 // Avoids compilation #include errors. 295 // TODO: clean this up, the headers should not leak out (maybe all we need is a PerfettoConsumer 296 // forward declaration?). 297 include_dirs: ["external/perfetto/include"], 298 // Various perfetto protos are used directly by iorap. 299 // 300 // Furthermore, we need this regardless to avoid linking errors when linking 301 // libiorap-perfetto.a into the main cc_binary rule. 302 static_libs: [ 303 "perfetto_trace_protos", 304 ], 305 306 shared_libs: [ 307 // Not part of true dependencies: Users of 'libiorap-perfetto' do not link against 308 // libperfetto. 309 // We only put this to avoid linking errors when building iorapd. 310 // TODO: can we split iorapd into libiorapd-main that doesn't link against libperfetto? 311 // only the last cc_binary should need the full transitive closure of the dependency graph. 312 "libperfetto", 313 ] 314} 315 316cc_library_static { 317 name: "libiorap-perfetto", 318 defaults: [ 319 "iorap-default-flags", 320 "iorap-default-dependencies", 321 "libiorap-perfetto-default-dependencies", 322 ], 323 324 srcs: [ 325 "src/perfetto/**/*.cc", 326 ], 327} 328 329cc_binary { 330 name: "iorap.cmd.perfetto", 331 defaults: [ 332 "iorap-default-flags", 333 "iorap-default-dependencies", 334 ], 335 shared_libs: ["libperfetto"], 336 include_dirs: ["external/perfetto/include"], 337 srcs: [ 338 "src/perfetto/**/*.cc", 339 ], 340 // Easier debugging. TODO: make a separate debug config. 341 // XX: Using -O0 seems to completely hide some errors. 342 cflags: ["-O2", "-UNDEBUG", "-DIORAP_PERFETTO_MAIN=1"], 343 sanitize: { 344 undefined: true, 345 all_undefined: true, 346 // Pretty print when ubsan detects a problem. 347 // Otherwise it just calls abort(). 348 349/* 350 diag: { 351 undefined: true, 352 }, 353 */ // don't use the diag when you want it to crash. 354 }, 355 356 static_libs: [ 357 "perfetto_trace_protos", 358 ], 359} 360 361// Static libraries cannot export their dependencies, 362// the current convention is to use an extra 'defaults' rule for statics 363// to bring in all the dependencies. 364cc_defaults { 365 name: "libiorap-compiler-default-dependencies", 366 367 defaults: [ 368 // use the perfetto namespace 369 "libiorap-perfetto-default-dependencies", 370 // use the inode2filename namespace 371 "libiorap-serialize-default-dependencies", // uses but does not re-export serialize. 372 ], 373 374 // Some of the libperfetto header typedefs leak out into iorap. 375 // Avoids compilation #include errors. 376 // TODO: clean this up, the headers should not leak out (maybe all we need is a PerfettoConsumer 377 // forward declaration?). 378 include_dirs: [], 379 // Various perfetto protos are used directly by iorap. 380 // 381 // Furthermore, we need this regardless to avoid linking errors when linking 382 // libiorap-compiler.a into the main cc_binary rule. 383 static_libs: [ 384 "libiorap-perfetto", 385 // "perfetto_trace_protos", 386 "libiorap-inode2filename", 387 "libiorap-serialize", 388 ], 389 390 shared_libs: [ 391 // Not part of true dependencies: Users of 'libiorap-compiler' do not link against 392 // libperfetto. 393 // We only put this to avoid linking errors when building iorapd. 394 // TODO: can we split iorapd into libiorapd-main that doesn't link against libperfetto? 395 // only the last cc_binary should need the full transitive closure of the dependency graph. 396 ] 397} 398 399cc_library_static { 400 name: "libiorap-compiler", 401 defaults: [ 402 "iorap-default-flags", 403 "iorap-default-dependencies", 404 "libiorap-compiler-default-dependencies", 405 ], 406 407 srcs: [ 408 "src/compiler/**/*.cc", 409 ], 410} 411 412cc_binary { 413 name: "iorap.cmd.compiler", 414 defaults: [ 415 "iorap-default-flags", 416 "iorap-default-dependencies", 417 "libiorap-compiler-default-dependencies", 418 ], 419 shared_libs: [], 420 include_dirs: [], 421 srcs: [ 422 "src/compiler/**/*.cc", 423 ], 424 // Easier debugging. TODO: make a separate debug config. 425 // XX: Using -O0 seems to completely hide some errors. 426 cflags: ["-O2", "-UNDEBUG", "-DIORAP_COMPILER_MAIN=1"], 427 sanitize: { 428 undefined: true, 429 all_undefined: true, 430 // Pretty print when ubsan detects a problem. 431 // Otherwise it just calls abort(). 432 433/* 434 diag: { 435 undefined: true, 436 }, 437 */ // don't use the diag when you want it to crash. 438 }, 439 440 static_libs: [ 441 ], 442 required: [ 443 "iorap.inode2filename", 444 ], 445} 446 447// Static libraries cannot export their dependencies, 448// the current convention is to use an extra 'defaults' rule for statics 449// to bring in all the dependencies. 450cc_defaults { 451 name: "libiorap-serialize-default-dependencies", 452 453 defaults: [ 454 ], 455 456 include_dirs: [], 457 static_libs: [ 458 ], 459 shared_libs: [ 460 ], 461 // Above intentionally left empty. 462 srcs: [ 463 "src/serialize/**/*.proto", 464 ], 465} 466 467cc_library_static { 468 name: "libiorap-serialize", 469 defaults: [ 470 "iorap-default-flags", 471 "iorap-default-dependencies", 472 "libiorap-serialize-default-dependencies", 473 ], 474 475 srcs: [ 476 "src/serialize/**/*.cc", 477 ], 478} 479 480 481// Static libraries cannot export their dependencies, 482// the current convention is to use an extra 'defaults' rule for statics 483// to bring in all the dependencies. 484cc_defaults { 485 name: "libiorap-prefetcher-default-dependencies", 486 487 defaults: [ 488 ], 489 490 include_dirs: [], 491 static_libs: [ 492 "libiorap-serialize", 493 ], 494 shared_libs: [ 495 "libminijail", 496 ], 497 498 // disable mac builds because libminijail doesn't work there 499 target: { 500 darwin: { 501 enabled: false, 502 }, 503 }, 504} 505 506cc_library_static { 507 name: "libiorap-prefetcher", 508 defaults: [ 509 "iorap-default-flags", 510 "iorap-default-dependencies", 511 "libiorap-prefetcher-default-dependencies", 512 "libiorap-serialize-default-dependencies", 513 ], 514 515 srcs: [ 516 "src/prefetcher/**/*.cc", 517 ], 518} 519 520cc_binary { 521 name: "iorap.prefetcherd", 522 defaults: [ 523 "iorap-default-flags", 524 "iorap-default-dependencies", 525 "libiorap-prefetcher-default-dependencies", 526 "libiorap-serialize-default-dependencies", 527 ], 528 shared_libs: [], 529 include_dirs: [], 530 srcs: [ 531 "src/prefetcher/**/*.cc", 532 ], 533 // Easier debugging. TODO: make a separate debug config. 534 // XX: Using -O0 seems to completely hide some errors. 535 cflags: ["-O2", "-UNDEBUG", "-DIORAP_PREFETCHER_MAIN=1"], 536 sanitize: { 537 undefined: true, 538 all_undefined: true, 539 // Pretty print when ubsan detects a problem. 540 // Otherwise it just calls abort(). 541 542/* 543 diag: { 544 undefined: true, 545 }, 546 */ // don't use the diag when you want it to crash. 547 }, 548 549 static_libs: [ 550 ], 551} 552 553cc_binary { 554 name: "iorap.cmd.prefetcher.client", 555 defaults: [ 556 "iorap-default-flags", 557 "iorap-default-dependencies", 558 "libiorap-prefetcher-default-dependencies", 559 "libiorap-serialize-default-dependencies", 560 ], 561 shared_libs: [], 562 include_dirs: [], 563 srcs: [ 564 "src/prefetcher/**/*.cc", 565 ], 566 // Easier debugging. TODO: make a separate debug config. 567 // XX: Using -O0 seems to completely hide some errors. 568 cflags: ["-O2", "-UNDEBUG", "-DIORAP_PREFETCHER_MAIN_CLIENT=1"], 569 sanitize: { 570 undefined: true, 571 all_undefined: true, 572 // Pretty print when ubsan detects a problem. 573 // Otherwise it just calls abort(). 574 575/* 576 diag: { 577 undefined: true, 578 }, 579 */ // don't use the diag when you want it to crash. 580 }, 581 582 static_libs: [ 583 ], 584} 585 586prebuilt_etc { 587 name: "iorap.prefetcherd.policy", 588 sub_dir: "seccomp_policy", 589 arch: { 590 arm: { 591 src: "seccomp_policy/prefetcherd.arm.policy" 592 }, 593 arm64: { 594 src: "seccomp_policy/prefetcherd.arm64.policy" 595 }, 596 x86: { 597 src: "seccomp_policy/prefetcherd.x86.policy" 598 }, 599 x86_64: { 600 src: "seccomp_policy/prefetcherd.x86_64.policy" 601 }, 602 }, 603 required: [ 604 "crash_dump.policy", 605 ], 606} 607 608// Static libraries cannot export their dependencies, 609// the current convention is to use an extra 'defaults' rule for statics 610// to bring in all the dependencies. 611cc_defaults { 612 name: "libiorap-db-default-dependencies", 613 614 defaults: [ 615 ], 616 617 include_dirs: [], 618 static_libs: [ 619 ], 620 shared_libs: [ 621 "libsqlite", 622 ], 623} 624 625cc_library_static { 626 name: "libiorap-db", 627 defaults: [ 628 "iorap-default-flags", 629 "iorap-default-dependencies", 630 "libiorap-db-default-dependencies", 631 ], 632 633 srcs: [ 634 "src/db/**/*.cc", 635 ], 636} 637 638cc_binary { 639 name: "iorap.cmd.db", 640 defaults: [ 641 "iorap-default-flags", 642 "iorap-default-dependencies", 643 "libiorap-db-default-dependencies", 644 ], 645 shared_libs: [], 646 include_dirs: [], 647 srcs: [ 648 "src/db/**/*.cc", 649 ], 650 // Easier debugging. TODO: make a separate debug config. 651 // XX: Using -O0 seems to completely hide some errors. 652 cflags: ["-O2", "-UNDEBUG", "-DIORAP_DB_MAIN=1"], 653 sanitize: { 654 undefined: true, 655 all_undefined: true, 656 // Pretty print when ubsan detects a problem. 657 // Otherwise it just calls abort(). 658 659/* 660 diag: { 661 undefined: true, 662 }, 663 */ // don't use the diag when you want it to crash. 664 }, 665 666 static_libs: [ 667 ], 668} 669 670cc_defaults { 671 name: "libiorap-maintenance-default-dependencies", 672 673 defaults: [ 674 "libiorap-compiler-default-dependencies", 675 "libiorap-db-default-dependencies", 676 "libiorap-prefetcher-default-dependencies", 677 ], 678 679 include_dirs: [], 680 681 static_libs: [ 682 "libiorap-binder", 683 "libiorap-compiler", 684 "libiorap-db", 685 "libiorap-prefetcher", 686 ], 687 688 shared_libs: [] 689} 690 691cc_library_static { 692 name: "libiorap-maintenance", 693 defaults: [ 694 "iorap-default-flags", 695 "iorap-default-dependencies", 696 "libiorap-maintenance-default-dependencies", 697 ], 698 699 srcs: [ 700 "src/maintenance/*.cc", 701 ], 702} 703 704cc_binary { 705 name: "iorap.cmd.maintenance", 706 defaults: [ 707 "iorap-default-flags", 708 "iorap-default-dependencies", 709 "libiorap-maintenance-default-dependencies", 710 ], 711 shared_libs: [], 712 include_dirs: [], 713 srcs: [ 714 "src/maintenance/*.cc", 715 ], 716 cflags: ["-O2", "-UNDEBUG", "-DIORAP_MAINTENANCE_MAIN=1"], 717 sanitize: { 718 undefined: true, 719 all_undefined: true, 720 721 diag: { 722 undefined: true, 723 }, 724 }, 725 726 static_libs: [], 727} 728