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