1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666
|
// Copyright (C) 2018 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package apex
import (
"fmt"
"path/filepath"
"sort"
"strings"
"github.com/google/blueprint"
"github.com/google/blueprint/bootstrap"
"github.com/google/blueprint/proptools"
"android/soong/android"
"android/soong/bpf"
"android/soong/cc"
prebuilt_etc "android/soong/etc"
"android/soong/java"
"android/soong/python"
"android/soong/sh"
)
const (
imageApexSuffix = ".apex"
zipApexSuffix = ".zipapex"
flattenedSuffix = ".flattened"
imageApexType = "image"
zipApexType = "zip"
flattenedApexType = "flattened"
ext4FsType = "ext4"
f2fsFsType = "f2fs"
)
type dependencyTag struct {
blueprint.BaseDependencyTag
name string
// determines if the dependent will be part of the APEX payload
payload bool
}
var (
sharedLibTag = dependencyTag{name: "sharedLib", payload: true}
jniLibTag = dependencyTag{name: "jniLib", payload: true}
executableTag = dependencyTag{name: "executable", payload: true}
javaLibTag = dependencyTag{name: "javaLib", payload: true}
prebuiltTag = dependencyTag{name: "prebuilt", payload: true}
testTag = dependencyTag{name: "test", payload: true}
keyTag = dependencyTag{name: "key"}
certificateTag = dependencyTag{name: "certificate"}
usesTag = dependencyTag{name: "uses"}
androidAppTag = dependencyTag{name: "androidApp", payload: true}
rroTag = dependencyTag{name: "rro", payload: true}
bpfTag = dependencyTag{name: "bpf", payload: true}
testForTag = dependencyTag{name: "test for"}
apexAvailBaseline = makeApexAvailableBaseline()
inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
)
// Transform the map of apex -> modules to module -> apexes.
func invertApexBaseline(m map[string][]string) map[string][]string {
r := make(map[string][]string)
for apex, modules := range m {
for _, module := range modules {
r[module] = append(r[module], apex)
}
}
return r
}
// Retrieve the baseline of apexes to which the supplied module belongs.
func BaselineApexAvailable(moduleName string) []string {
return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
}
// This is a map from apex to modules, which overrides the
// apex_available setting for that particular module to make
// it available for the apex regardless of its setting.
// TODO(b/147364041): remove this
func makeApexAvailableBaseline() map[string][]string {
// The "Module separator"s below are employed to minimize merge conflicts.
m := make(map[string][]string)
//
// Module separator
//
m["com.android.appsearch"] = []string{
"icing-java-proto-lite",
"libprotobuf-java-lite",
}
//
// Module separator
//
m["com.android.bluetooth.updatable"] = []string{
"android.hardware.audio.common@5.0",
"android.hardware.bluetooth.a2dp@1.0",
"android.hardware.bluetooth.audio@2.0",
"android.hardware.bluetooth@1.0",
"android.hardware.bluetooth@1.1",
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common@1.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
"android.hardware.media@1.0",
"android.hidl.safe_union@1.0",
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"avrcp-target-service",
"avrcp_headers",
"bluetooth-protos-lite",
"bluetooth.mapsapi",
"com.android.vcard",
"dnsresolver_aidl_interface-V2-java",
"ipmemorystore-aidl-interfaces-V5-java",
"ipmemorystore-aidl-interfaces-java",
"internal_include_headers",
"lib-bt-packets",
"lib-bt-packets-avrcp",
"lib-bt-packets-base",
"libFraunhoferAAC",
"libaudio-a2dp-hw-utils",
"libaudio-hearing-aid-hw-utils",
"libbinder_headers",
"libbluetooth",
"libbluetooth-types",
"libbluetooth-types-header",
"libbluetooth_gd",
"libbluetooth_headers",
"libbluetooth_jni",
"libbt-audio-hal-interface",
"libbt-bta",
"libbt-common",
"libbt-hci",
"libbt-platform-protos-lite",
"libbt-protos-lite",
"libbt-sbc-decoder",
"libbt-sbc-encoder",
"libbt-stack",
"libbt-utils",
"libbtcore",
"libbtdevice",
"libbte",
"libbtif",
"libchrome",
"libevent",
"libfmq",
"libg722codec",
"libgui_headers",
"libmedia_headers",
"libmodpb64",
"libosi",
"libstagefright_foundation_headers",
"libstagefright_headers",
"libstatslog",
"libstatssocket",
"libtinyxml2",
"libudrv-uipc",
"libz",
"media_plugin_headers",
"net-utils-services-common",
"netd_aidl_interface-unstable-java",
"netd_event_listener_interface-java",
"netlink-client",
"networkstack-client",
"sap-api-java-static",
"services.net",
}
//
// Module separator
//
m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"}
//
// Module separator
//
m["com.android.extservices"] = []string{
"error_prone_annotations",
"ExtServices-core",
"ExtServices",
"libtextclassifier-java",
"libz_current",
"textclassifier-statsd",
"TextClassifierNotificationLibNoManifest",
"TextClassifierServiceLibNoManifest",
}
//
// Module separator
//
m["com.android.neuralnetworks"] = []string{
"android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1",
"android.hardware.neuralnetworks@1.2",
"android.hardware.neuralnetworks@1.3",
"android.hidl.allocator@1.0",
"android.hidl.memory.token@1.0",
"android.hidl.memory@1.0",
"android.hidl.safe_union@1.0",
"libarect",
"libbuildversion",
"libmath",
"libprocpartition",
"libsync",
}
//
// Module separator
//
m["com.android.media"] = []string{
"android.frameworks.bufferhub@1.0",
"android.hardware.cas.native@1.0",
"android.hardware.cas@1.0",
"android.hardware.configstore-utils",
"android.hardware.configstore@1.0",
"android.hardware.configstore@1.1",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.allocator@3.0",
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common@1.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@3.0",
"android.hardware.media.omx@1.0",
"android.hardware.media@1.0",
"android.hidl.allocator@1.0",
"android.hidl.memory.token@1.0",
"android.hidl.memory@1.0",
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"bionic_libc_platform_headers",
"exoplayer2-extractor",
"exoplayer2-extractor-annotation-stubs",
"gl_headers",
"jsr305",
"libEGL",
"libEGL_blobCache",
"libEGL_getProcAddress",
"libFLAC",
"libFLAC-config",
"libFLAC-headers",
"libGLESv2",
"libaacextractor",
"libamrextractor",
"libarect",
"libaudio_system_headers",
"libaudioclient",
"libaudioclient_headers",
"libaudiofoundation",
"libaudiofoundation_headers",
"libaudiomanager",
"libaudiopolicy",
"libaudioutils",
"libaudioutils_fixedfft",
"libbinder_headers",
"libbluetooth-types-header",
"libbufferhub",
"libbufferhub_headers",
"libbufferhubqueue",
"libc_malloc_debug_backtrace",
"libcamera_client",
"libcamera_metadata",
"libdexfile_external_headers",
"libdexfile_support",
"libdvr_headers",
"libexpat",
"libfifo",
"libflacextractor",
"libgrallocusage",
"libgraphicsenv",
"libgui",
"libgui_headers",
"libhardware_headers",
"libinput",
"liblzma",
"libmath",
"libmedia",
"libmedia_codeclist",
"libmedia_headers",
"libmedia_helper",
"libmedia_helper_headers",
"libmedia_midiiowrapper",
"libmedia_omx",
"libmediautils",
"libmidiextractor",
"libmkvextractor",
"libmp3extractor",
"libmp4extractor",
"libmpeg2extractor",
"libnativebase_headers",
"libnativebridge-headers",
"libnativebridge_lazy",
"libnativeloader-headers",
"libnativeloader_lazy",
"libnativewindow_headers",
"libnblog",
"liboggextractor",
"libpackagelistparser",
"libpdx",
"libpdx_default_transport",
"libpdx_headers",
"libpdx_uds",
"libprocinfo",
"libspeexresampler",
"libspeexresampler",
"libstagefright_esds",
"libstagefright_flacdec",
"libstagefright_flacdec",
"libstagefright_foundation",
"libstagefright_foundation_headers",
"libstagefright_foundation_without_imemory",
"libstagefright_headers",
"libstagefright_id3",
"libstagefright_metadatautils",
"libstagefright_mpeg2extractor",
"libstagefright_mpeg2support",
"libsync",
"libui",
"libui_headers",
"libunwindstack",
"libvibrator",
"libvorbisidec",
"libwavextractor",
"libwebm",
"media_ndk_headers",
"media_plugin_headers",
"updatable-media",
}
//
// Module separator
//
m["com.android.media.swcodec"] = []string{
"android.frameworks.bufferhub@1.0",
"android.hardware.common-ndk_platform",
"android.hardware.configstore-utils",
"android.hardware.configstore@1.0",
"android.hardware.configstore@1.1",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.allocator@3.0",
"android.hardware.graphics.allocator@4.0",
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common-ndk_platform",
"android.hardware.graphics.common@1.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@3.0",
"android.hardware.graphics.mapper@4.0",
"android.hardware.media.bufferpool@2.0",
"android.hardware.media.c2@1.0",
"android.hardware.media.c2@1.1",
"android.hardware.media.omx@1.0",
"android.hardware.media@1.0",
"android.hardware.media@1.0",
"android.hidl.memory.token@1.0",
"android.hidl.memory@1.0",
"android.hidl.safe_union@1.0",
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"libEGL",
"libFLAC",
"libFLAC-config",
"libFLAC-headers",
"libFraunhoferAAC",
"libLibGuiProperties",
"libarect",
"libaudio_system_headers",
"libaudioutils",
"libaudioutils",
"libaudioutils_fixedfft",
"libavcdec",
"libavcenc",
"libavservices_minijail",
"libavservices_minijail",
"libbinder_headers",
"libbinderthreadstateutils",
"libbluetooth-types-header",
"libbufferhub_headers",
"libcodec2",
"libcodec2_headers",
"libcodec2_hidl@1.0",
"libcodec2_hidl@1.1",
"libcodec2_internal",
"libcodec2_soft_aacdec",
"libcodec2_soft_aacenc",
"libcodec2_soft_amrnbdec",
"libcodec2_soft_amrnbenc",
"libcodec2_soft_amrwbdec",
"libcodec2_soft_amrwbenc",
"libcodec2_soft_av1dec_gav1",
"libcodec2_soft_avcdec",
"libcodec2_soft_avcenc",
"libcodec2_soft_common",
"libcodec2_soft_flacdec",
"libcodec2_soft_flacenc",
"libcodec2_soft_g711alawdec",
"libcodec2_soft_g711mlawdec",
"libcodec2_soft_gsmdec",
"libcodec2_soft_h263dec",
"libcodec2_soft_h263enc",
"libcodec2_soft_hevcdec",
"libcodec2_soft_hevcenc",
"libcodec2_soft_mp3dec",
"libcodec2_soft_mpeg2dec",
"libcodec2_soft_mpeg4dec",
"libcodec2_soft_mpeg4enc",
"libcodec2_soft_opusdec",
"libcodec2_soft_opusenc",
"libcodec2_soft_rawdec",
"libcodec2_soft_vorbisdec",
"libcodec2_soft_vp8dec",
"libcodec2_soft_vp8enc",
"libcodec2_soft_vp9dec",
"libcodec2_soft_vp9enc",
"libcodec2_vndk",
"libdexfile_support",
"libdvr_headers",
"libfmq",
"libfmq",
"libgav1",
"libgralloctypes",
"libgrallocusage",
"libgraphicsenv",
"libgsm",
"libgui_bufferqueue_static",
"libgui_headers",
"libhardware",
"libhardware_headers",
"libhevcdec",
"libhevcenc",
"libion",
"libjpeg",
"liblzma",
"libmath",
"libmedia_codecserviceregistrant",
"libmedia_headers",
"libmpeg2dec",
"libnativebase_headers",
"libnativebridge_lazy",
"libnativeloader_lazy",
"libnativewindow_headers",
"libpdx_headers",
"libscudo_wrapper",
"libsfplugin_ccodec_utils",
"libspeexresampler",
"libstagefright_amrnb_common",
"libstagefright_amrnbdec",
"libstagefright_amrnbenc",
"libstagefright_amrwbdec",
"libstagefright_amrwbenc",
"libstagefright_bufferpool@2.0.1",
"libstagefright_bufferqueue_helper",
"libstagefright_enc_common",
"libstagefright_flacdec",
"libstagefright_foundation",
"libstagefright_foundation_headers",
"libstagefright_headers",
"libstagefright_m4vh263dec",
"libstagefright_m4vh263enc",
"libstagefright_mp3dec",
"libsync",
"libui",
"libui_headers",
"libunwindstack",
"libvorbisidec",
"libvpx",
"libyuv",
"libyuv_static",
"media_ndk_headers",
"media_plugin_headers",
"mediaswcodec",
}
//
// Module separator
//
m["com.android.mediaprovider"] = []string{
"MediaProvider",
"MediaProviderGoogle",
"fmtlib_ndk",
"libbase_ndk",
"libfuse",
"libfuse_jni",
}
//
// Module separator
//
m["com.android.permission"] = []string{
"car-ui-lib",
"iconloader",
"kotlin-annotations",
"kotlin-stdlib",
"kotlin-stdlib-jdk7",
"kotlin-stdlib-jdk8",
"kotlinx-coroutines-android",
"kotlinx-coroutines-android-nodeps",
"kotlinx-coroutines-core",
"kotlinx-coroutines-core-nodeps",
"permissioncontroller-statsd",
"GooglePermissionController",
"PermissionController",
"SettingsLibActionBarShadow",
"SettingsLibAppPreference",
"SettingsLibBarChartPreference",
"SettingsLibLayoutPreference",
"SettingsLibProgressBar",
"SettingsLibSearchWidget",
"SettingsLibSettingsTheme",
"SettingsLibRestrictedLockUtils",
"SettingsLibHelpUtils",
}
//
// Module separator
//
m["com.android.runtime"] = []string{
"bionic_libc_platform_headers",
"libarm-optimized-routines-math",
"libc_aeabi",
"libc_bionic",
"libc_bionic_ndk",
"libc_bootstrap",
"libc_common",
"libc_common_shared",
"libc_common_static",
"libc_dns",
"libc_dynamic_dispatch",
"libc_fortify",
"libc_freebsd",
"libc_freebsd_large_stack",
"libc_gdtoa",
"libc_init_dynamic",
"libc_init_static",
"libc_jemalloc_wrapper",
"libc_netbsd",
"libc_nomalloc",
"libc_nopthread",
"libc_openbsd",
"libc_openbsd_large_stack",
"libc_openbsd_ndk",
"libc_pthread",
"libc_static_dispatch",
"libc_syscalls",
"libc_tzcode",
"libc_unwind_static",
"libdebuggerd",
"libdebuggerd_common_headers",
"libdebuggerd_handler_core",
"libdebuggerd_handler_fallback",
"libdexfile_external_headers",
"libdexfile_support",
"libdl_static",
"libjemalloc5",
"liblinker_main",
"liblinker_malloc",
"liblz4",
"liblzma",
"libprocinfo",
"libpropertyinfoparser",
"libscudo",
"libstdc++",
"libsystemproperties",
"libtombstoned_client_static",
"libunwindstack",
"libz",
"libziparchive",
}
//
// Module separator
//
m["com.android.tethering"] = []string{
"android.hardware.tetheroffload.config-V1.0-java",
"android.hardware.tetheroffload.control-V1.0-java",
"android.hidl.base-V1.0-java",
"libcgrouprc",
"libcgrouprc_format",
"libtetherutilsjni",
"libvndksupport",
"net-utils-framework-common",
"netd_aidl_interface-V3-java",
"netlink-client",
"networkstack-aidl-interfaces-java",
"tethering-aidl-interfaces-java",
"TetheringApiCurrentLib",
}
//
// Module separator
//
m["com.android.wifi"] = []string{
"PlatformProperties",
"android.hardware.wifi-V1.0-java",
"android.hardware.wifi-V1.0-java-constants",
"android.hardware.wifi-V1.1-java",
"android.hardware.wifi-V1.2-java",
"android.hardware.wifi-V1.3-java",
"android.hardware.wifi-V1.4-java",
"android.hardware.wifi.hostapd-V1.0-java",
"android.hardware.wifi.hostapd-V1.1-java",
"android.hardware.wifi.hostapd-V1.2-java",
"android.hardware.wifi.supplicant-V1.0-java",
"android.hardware.wifi.supplicant-V1.1-java",
"android.hardware.wifi.supplicant-V1.2-java",
"android.hardware.wifi.supplicant-V1.3-java",
"android.hidl.base-V1.0-java",
"android.hidl.manager-V1.0-java",
"android.hidl.manager-V1.1-java",
"android.hidl.manager-V1.2-java",
"bouncycastle-unbundled",
"dnsresolver_aidl_interface-V2-java",
"error_prone_annotations",
"framework-wifi-pre-jarjar",
"framework-wifi-util-lib",
"ipmemorystore-aidl-interfaces-V3-java",
"ipmemorystore-aidl-interfaces-java",
"ksoap2",
"libnanohttpd",
"libwifi-jni",
"net-utils-services-common",
"netd_aidl_interface-V2-java",
"netd_aidl_interface-unstable-java",
"netd_event_listener_interface-java",
"netlink-client",
"networkstack-client",
"services.net",
"wifi-lite-protos",
"wifi-nano-protos",
"wifi-service-pre-jarjar",
"wifi-service-resources",
}
//
// Module separator
//
m["com.android.sdkext"] = []string{
"fmtlib_ndk",
"libbase_ndk",
"libprotobuf-cpp-lite-ndk",
}
//
// Module separator
//
m["com.android.os.statsd"] = []string{
"libstatssocket",
}
//
// Module separator
//
m[android.AvailableToAnyApex] = []string{
// TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
"androidx",
"androidx-constraintlayout_constraintlayout",
"androidx-constraintlayout_constraintlayout-nodeps",
"androidx-constraintlayout_constraintlayout-solver",
"androidx-constraintlayout_constraintlayout-solver-nodeps",
"com.google.android.material_material",
"com.google.android.material_material-nodeps",
"libatomic",
"libclang_rt",
"libgcc_stripped",
"libprofile-clang-extras",
"libprofile-clang-extras_ndk",
"libprofile-extras",
"libprofile-extras_ndk",
"libunwind_llvm",
}
return m
}
// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
// Adding code to the bootclasspath in new packages will cause issues on module update.
func qModulesPackages() map[string][]string {
return map[string][]string{
"com.android.conscrypt": []string{
"android.net.ssl",
"com.android.org.conscrypt",
},
"com.android.media": []string{
"android.media",
},
}
}
// DO NOT EDIT! These are the package prefixes that are exempted from being AOT'ed by ART.
// Adding code to the bootclasspath in new packages will cause issues on module update.
func rModulesPackages() map[string][]string {
return map[string][]string{
"com.android.mediaprovider": []string{
"android.provider",
},
"com.android.permission": []string{
"android.permission",
"android.app.role",
"com.android.permission",
"com.android.role",
},
"com.android.sdkext": []string{
"android.os.ext",
},
"com.android.os.statsd": []string{
"android.app",
"android.os",
"android.util",
"com.android.internal.statsd",
"com.android.server.stats",
},
"com.android.wifi": []string{
"com.android.server.wifi",
"com.android.wifi.x",
"android.hardware.wifi",
"android.net.wifi",
},
"com.android.tethering": []string{
"android.net",
},
}
}
func init() {
android.RegisterModuleType("apex", BundleFactory)
android.RegisterModuleType("apex_test", testApexBundleFactory)
android.RegisterModuleType("apex_vndk", vndkApexBundleFactory)
android.RegisterModuleType("apex_defaults", defaultsFactory)
android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
android.RegisterModuleType("override_apex", overrideApexFactory)
android.RegisterModuleType("apex_set", apexSetFactory)
android.PreDepsMutators(RegisterPreDepsMutators)
android.PostDepsMutators(RegisterPostDepsMutators)
android.AddNeverAllowRules(createApexPermittedPackagesRules(qModulesPackages())...)
android.AddNeverAllowRules(createApexPermittedPackagesRules(rModulesPackages())...)
}
func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
rules := make([]android.Rule, 0, len(modules_packages))
for module_name, module_packages := range modules_packages {
permitted_packages_rule := android.NeverAllow().
BootclasspathJar().
With("apex_available", module_name).
WithMatcher("permitted_packages", android.NotInList(module_packages)).
Because("jars that are part of the " + module_name +
" module may only allow these packages: " + strings.Join(module_packages, ",") +
". Please jarjar or move code around.")
rules = append(rules, permitted_packages_rule)
}
return rules
}
func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_vndk", apexVndkMutator).Parallel()
ctx.BottomUp("apex_vndk_deps", apexVndkDepsMutator).Parallel()
}
func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) {
ctx.TopDown("apex_deps", apexDepsMutator).Parallel()
ctx.BottomUp("apex_unique", apexUniqueVariationsMutator).Parallel()
ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator).Parallel()
ctx.BottomUp("apex_test_for", apexTestForMutator).Parallel()
ctx.BottomUp("apex", apexMutator).Parallel()
ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).Parallel()
ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel()
ctx.BottomUp("apex_uses", apexUsesMutator).Parallel()
ctx.BottomUp("mark_platform_availability", markPlatformAvailability).Parallel()
}
// Mark the direct and transitive dependencies of apex bundles so that they
// can be built for the apex bundles.
func apexDepsMutator(mctx android.TopDownMutatorContext) {
if !mctx.Module().Enabled() {
return
}
a, ok := mctx.Module().(*apexBundle)
if !ok || a.vndkApex {
return
}
useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable)
if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) {
mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
return
}
contents := make(map[string]android.ApexMembership)
continueApexDepsWalk := func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
return false
}
if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) {
return false
}
if excludeVndkLibs {
if c, ok := child.(*cc.Module); ok && c.IsVndk() {
return false
}
}
return true
}
mctx.WalkDeps(func(child, parent android.Module) bool {
if !continueApexDepsWalk(child, parent) {
return false
}
depName := mctx.OtherModuleName(child)
// If the parent is apexBundle, this child is directly depended.
_, directDep := parent.(*apexBundle)
contents[depName] = contents[depName].Add(directDep)
return true
})
apexContents := android.NewApexContents(mctx.ModuleName(), contents)
mctx.SetProvider(ApexBundleInfoProvider, ApexBundleInfo{
Contents: apexContents,
})
apexInfo := android.ApexInfo{
ApexVariationName: mctx.ModuleName(),
MinSdkVersionStr: a.minSdkVersion(mctx).String(),
RequiredSdks: a.RequiredSdks(),
Updatable: a.Updatable(),
InApexes: []string{mctx.ModuleName()},
ApexContents: []*android.ApexContents{apexContents},
}
mctx.WalkDeps(func(child, parent android.Module) bool {
if !continueApexDepsWalk(child, parent) {
return false
}
child.(android.ApexModule).BuildForApex(apexInfo)
return true
})
}
func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
// Check if any dependencies use unique apex variations. If so, use unique apex variations
// for this module.
android.UpdateUniqueApexVariationsForDeps(mctx, am)
}
}
func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
// Check if this module is a test for an apex. If so, add a dependency on the apex
// in order to retrieve its contents later.
if am, ok := mctx.Module().(android.ApexModule); ok {
if testFor := am.TestFor(); len(testFor) > 0 {
mctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "os", Variation: am.Target().OsVariation()},
{"arch", "common"},
}, testForTag, testFor...)
}
}
}
func apexTestForMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
if _, ok := mctx.Module().(android.ApexModule); ok {
var contents []*android.ApexContents
for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) {
abInfo := mctx.OtherModuleProvider(testFor, ApexBundleInfoProvider).(ApexBundleInfo)
contents = append(contents, abInfo.Contents)
}
mctx.SetProvider(android.ApexTestForInfoProvider, android.ApexTestForInfo{
ApexContents: contents,
})
}
}
// mark if a module cannot be available to platform. A module cannot be available
// to platform if 1) it is explicitly marked as not available (i.e. "//apex_available:platform"
// is absent) or 2) it depends on another module that isn't (or can't be) available to platform
func markPlatformAvailability(mctx android.BottomUpMutatorContext) {
// Host and recovery are not considered as platform
if mctx.Host() || mctx.Module().InstallInRecovery() {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
availableToPlatform := am.AvailableFor(android.AvailableToPlatform)
// If any of the dep is not available to platform, this module is also considered
// as being not available to platform even if it has "//apex_available:platform"
mctx.VisitDirectDeps(func(child android.Module) {
if !am.DepIsInSameApex(mctx, child) {
// if the dependency crosses apex boundary, don't consider it
return
}
if dep, ok := child.(android.ApexModule); ok && dep.NotAvailableForPlatform() {
availableToPlatform = false
// TODO(b/154889534) trigger an error when 'am' has "//apex_available:platform"
}
})
// Exception 1: stub libraries and native bridge libraries are always available to platform
if cc, ok := mctx.Module().(*cc.Module); ok &&
(cc.IsStubs() || cc.Target().NativeBridge == android.NativeBridgeEnabled) {
availableToPlatform = true
}
// Exception 2: bootstrap bionic libraries are also always available to platform
if cc.InstallToBootstrap(mctx.ModuleName(), mctx.Config()) {
availableToPlatform = true
}
if !availableToPlatform {
am.SetNotAvailableForPlatform()
}
}
}
// If a module in an APEX depends on a module from an SDK then it needs an APEX
// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator.
func inAnySdk(module android.Module) bool {
if sa, ok := module.(android.SdkAware); ok {
return sa.IsInAnySdk()
}
return false
}
// Create apex variations if a module is included in APEX(s).
func apexMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() {
android.CreateApexVariations(mctx, am)
} else if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex {
// apex bundle itself is mutated so that it and its modules have same
// apex variant.
apexBundleName := mctx.ModuleName()
mctx.CreateVariations(apexBundleName)
} else if o, ok := mctx.Module().(*OverrideApex); ok {
apexBundleName := o.GetOverriddenModuleName()
if apexBundleName == "" {
mctx.ModuleErrorf("base property is not set")
return
}
mctx.CreateVariations(apexBundleName)
}
}
func apexDirectlyInAnyMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
if am, ok := mctx.Module().(android.ApexModule); ok {
android.UpdateDirectlyInAnyApex(mctx, am)
}
}
func apexFlattenedMutator(mctx android.BottomUpMutatorContext) {
if !mctx.Module().Enabled() {
return
}
if ab, ok := mctx.Module().(*apexBundle); ok {
var variants []string
switch proptools.StringDefault(ab.properties.Payload_type, "image") {
case "image":
variants = append(variants, imageApexType, flattenedApexType)
case "zip":
variants = append(variants, zipApexType)
case "both":
variants = append(variants, imageApexType, zipApexType, flattenedApexType)
default:
mctx.PropertyErrorf("type", "%q is not one of \"image\", \"zip\", or \"both\".", *ab.properties.Payload_type)
return
}
modules := mctx.CreateLocalVariations(variants...)
for i, v := range variants {
switch v {
case imageApexType:
modules[i].(*apexBundle).properties.ApexType = imageApex
case zipApexType:
modules[i].(*apexBundle).properties.ApexType = zipApex
case flattenedApexType:
modules[i].(*apexBundle).properties.ApexType = flattenedApex
if !mctx.Config().FlattenApex() && ab.Platform() {
modules[i].(*apexBundle).MakeAsSystemExt()
}
}
}
} else if _, ok := mctx.Module().(*OverrideApex); ok {
mctx.CreateVariations(imageApexType, flattenedApexType)
}
}
func apexUsesMutator(mctx android.BottomUpMutatorContext) {
if ab, ok := mctx.Module().(*apexBundle); ok {
mctx.AddFarVariationDependencies(nil, usesTag, ab.properties.Uses...)
}
}
var (
useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
)
// useVendorAllowList returns the list of APEXes which are allowed to use_vendor.
// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
// which may cause compatibility issues. (e.g. libbinder)
// Even though libbinder restricts its availability via 'apex_available' property and relies on
// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
// to avoid similar problems.
func useVendorAllowList(config android.Config) []string {
return config.Once(useVendorAllowListKey, func() interface{} {
return []string{
// swcodec uses "vendor" variants for smaller size
"com.android.media.swcodec",
"test_com.android.media.swcodec",
}
}).([]string)
}
// setUseVendorAllowListForTest overrides useVendorAllowList and must be
// called before the first call to useVendorAllowList()
func setUseVendorAllowListForTest(config android.Config, allowList []string) {
config.Once(useVendorAllowListKey, func() interface{} {
return allowList
})
}
type ApexNativeDependencies struct {
// List of native libraries
Native_shared_libs []string
// List of JNI libraries
Jni_libs []string
// List of native executables
Binaries []string
// List of native tests
Tests []string
}
type apexMultilibProperties struct {
// Native dependencies whose compile_multilib is "first"
First ApexNativeDependencies
// Native dependencies whose compile_multilib is "both"
Both ApexNativeDependencies
// Native dependencies whose compile_multilib is "prefer32"
Prefer32 ApexNativeDependencies
// Native dependencies whose compile_multilib is "32"
Lib32 ApexNativeDependencies
// Native dependencies whose compile_multilib is "64"
Lib64 ApexNativeDependencies
}
type apexBundleProperties struct {
// Json manifest file describing meta info of this APEX bundle. Default:
// "apex_manifest.json"
Manifest *string `android:"path"`
// AndroidManifest.xml file used for the zip container of this APEX bundle.
// If unspecified, a default one is automatically generated.
AndroidManifest *string `android:"path"`
// Canonical name of the APEX bundle. Used to determine the path to the activated APEX on
// device (/apex/<apex_name>).
// If unspecified, defaults to the value of name.
Apex_name *string
// Determines the file contexts file for setting security context to each file in this APEX bundle.
// For platform APEXes, this should points to a file under /system/sepolicy
// Default: /system/sepolicy/apex/<module_name>_file_contexts.
File_contexts *string `android:"path"`
ApexNativeDependencies
// List of java libraries that are embedded inside this APEX bundle
Java_libs []string
// List of prebuilt files that are embedded inside this APEX bundle
Prebuilts []string
// List of BPF programs inside APEX
Bpfs []string
// Name of the apex_key module that provides the private key to sign APEX
Key *string
// The type of APEX to build. Controls what the APEX payload is. Either
// 'image', 'zip' or 'both'. Default: 'image'.
Payload_type *string
// The name of a certificate in the default certificate directory, blank to use the default product certificate,
// or an android_app_certificate module name in the form ":module".
Certificate *string
// Whether this APEX is installable to one of the partitions. Default: true.
Installable *bool
// For native libraries and binaries, use the vendor variant instead of the core (platform) variant.
// Default is false.
Use_vendor *bool
// For telling the apex to ignore special handling for system libraries such as bionic. Default is false.
Ignore_system_library_special_case *bool
Multilib apexMultilibProperties
// List of sanitizer names that this APEX is enabled for
SanitizerNames []string `blueprint:"mutated"`
PreventInstall bool `blueprint:"mutated"`
HideFromMake bool `blueprint:"mutated"`
// Indicates this APEX provides C++ shared libaries to other APEXes. Default: false.
Provide_cpp_shared_libs *bool
// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
Uses []string
// package format of this apex variant; could be non-flattened, flattened, or zip.
// imageApex, zipApex or flattened
ApexType apexPackaging `blueprint:"mutated"`
// List of SDKs that are used to build this APEX. A reference to an SDK should be either
// `name#version` or `name` which is an alias for `name#current`. If left empty, `platform#current`
// is implied. This value affects all modules included in this APEX. In other words, they are
// also built with the SDKs specified here.
Uses_sdks []string
// Whenever apex_payload.img of the APEX should include dm-verity hashtree.
// Should be only used in tests#.
Test_only_no_hashtree *bool
// Whenever apex_payload.img of the APEX should not be dm-verity signed.
// Should be only used in tests#.
Test_only_unsigned_payload *bool
IsCoverageVariant bool `blueprint:"mutated"`
// Whether this APEX is considered updatable or not. When set to true, this will enforce additional
// rules for making sure that the APEX is truly updatable.
// - To be updatable, min_sdk_version should be set as well
// This will also disable the size optimizations like symlinking to the system libs.
// Default is false.
Updatable *bool
// The minimum SDK version that this apex must be compatibile with.
Min_sdk_version *string
// If set true, VNDK libs are considered as stable libs and are not included in this apex.
// Should be only used in non-system apexes (e.g. vendor: true).
// Default is false.
Use_vndk_as_stable *bool
// The type of filesystem to use for an image apex. Either 'ext4' or 'f2fs'.
// Default 'ext4'.
Payload_fs_type *string
}
type ApexBundleInfo struct {
Contents *android.ApexContents
}
var ApexBundleInfoProvider = blueprint.NewMutatorProvider(ApexBundleInfo{}, "apex_deps")
type apexTargetBundleProperties struct {
Target struct {
// Multilib properties only for android.
Android struct {
Multilib apexMultilibProperties
}
// Multilib properties only for host.
Host struct {
Multilib apexMultilibProperties
}
// Multilib properties only for host linux_bionic.
Linux_bionic struct {
Multilib apexMultilibProperties
}
// Multilib properties only for host linux_glibc.
Linux_glibc struct {
Multilib apexMultilibProperties
}
}
}
type overridableProperties struct {
// List of APKs to package inside APEX
Apps []string
// List of runtime resource overlays (RROs) inside APEX
Rros []string
// Names of modules to be overridden. Listed modules can only be other binaries
// (in Make or Soong).
// This does not completely prevent installation of the overridden binaries, but if both
// binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed
// from PRODUCT_PACKAGES.
Overrides []string
// Logging Parent value
Logging_parent string
// Apex Container Package Name.
// Override value for attribute package:name in AndroidManifest.xml
Package_name string
// A txt file containing list of files that are allowed to be included in this APEX.
Allowed_files *string `android:"path"`
}
type apexPackaging int
const (
imageApex apexPackaging = iota
zipApex
flattenedApex
)
// The suffix for the output "file", not the module
func (a apexPackaging) suffix() string {
switch a {
case imageApex:
return imageApexSuffix
case zipApex:
return zipApexSuffix
default:
panic(fmt.Errorf("unknown APEX type %d", a))
}
}
func (a apexPackaging) name() string {
switch a {
case imageApex:
return imageApexType
case zipApex:
return zipApexType
default:
panic(fmt.Errorf("unknown APEX type %d", a))
}
}
type apexFileClass int
const (
etc apexFileClass = iota
nativeSharedLib
nativeExecutable
shBinary
pyBinary
goBinary
javaSharedLib
nativeTest
app
appSet
)
func (class apexFileClass) NameInMake() string {
switch class {
case etc:
return "ETC"
case nativeSharedLib:
return "SHARED_LIBRARIES"
case nativeExecutable, shBinary, pyBinary, goBinary:
return "EXECUTABLES"
case javaSharedLib:
return "JAVA_LIBRARIES"
case nativeTest:
return "NATIVE_TESTS"
case app, appSet:
// b/142537672 Why isn't this APP? We want to have full control over
// the paths and file names of the apk file under the flattend APEX.
// If this is set to APP, then the paths and file names are modified
// by the Make build system. For example, it is installed to
// /system/apex/<apexname>/app/<Appname>/<apexname>.<Appname>/ instead of
// /system/apex/<apexname>/app/<Appname> because the build system automatically
// appends module name (which is <apexname>.<Appname> to the path.
return "ETC"
default:
panic(fmt.Errorf("unknown class %d", class))
}
}
// apexFile represents a file in an APEX bundle
type apexFile struct {
builtFile android.Path
stem string
// Module name of `module` in AndroidMk. Note the generated AndroidMk module for
// apexFile is named something like <AndroidMk module name>.<apex name>[<apex suffix>]
androidMkModuleName string
installDir string
class apexFileClass
module android.Module
// list of symlinks that will be created in installDir that point to this apexFile
symlinks []string
dataPaths []android.DataPath
transitiveDep bool
moduleDir string
requiredModuleNames []string
targetRequiredModuleNames []string
hostRequiredModuleNames []string
jacocoReportClassesFile android.Path // only for javalibs and apps
lintDepSets java.LintDepSets // only for javalibs and apps
certificate java.Certificate // only for apps
overriddenPackageName string // only for apps
isJniLib bool
noticeFiles android.Paths
}
func newApexFile(ctx android.BaseModuleContext, builtFile android.Path, androidMkModuleName string, installDir string, class apexFileClass, module android.Module) apexFile {
ret := apexFile{
builtFile: builtFile,
androidMkModuleName: androidMkModuleName,
installDir: installDir,
class: class,
module: module,
}
if module != nil {
ret.moduleDir = ctx.OtherModuleDir(module)
ret.requiredModuleNames = module.RequiredModuleNames()
ret.targetRequiredModuleNames = module.TargetRequiredModuleNames()
ret.hostRequiredModuleNames = module.HostRequiredModuleNames()
ret.noticeFiles = module.NoticeFiles()
}
return ret
}
func (af *apexFile) Ok() bool {
return af.builtFile != nil && af.builtFile.String() != ""
}
func (af *apexFile) apexRelativePath(path string) string {
return filepath.Join(af.installDir, path)
}
// Path() returns path of this apex file relative to the APEX root
func (af *apexFile) Path() string {
return af.apexRelativePath(af.Stem())
}
func (af *apexFile) Stem() string {
if af.stem != "" {
return af.stem
}
return af.builtFile.Base()
}
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
func (af *apexFile) SymlinkPaths() []string {
var ret []string
for _, symlink := range af.symlinks {
ret = append(ret, af.apexRelativePath(symlink))
}
return ret
}
func (af *apexFile) AvailableToPlatform() bool {
if af.module == nil {
return false
}
if am, ok := af.module.(android.ApexModule); ok {
return am.AvailableFor(android.AvailableToPlatform)
}
return false
}
type fsType int
const (
ext4 fsType = iota
f2fs
)
func (f fsType) string() string {
switch f {
case ext4:
return ext4FsType
case f2fs:
return f2fsFsType
default:
panic(fmt.Errorf("unknown APEX payload type %d", f))
}
}
type apexBundle struct {
android.ModuleBase
android.DefaultableModuleBase
android.OverridableModuleBase
android.SdkBase
properties apexBundleProperties
targetProperties apexTargetBundleProperties
overridableProperties overridableProperties
// specific to apex_vndk modules
vndkProperties apexVndkProperties
bundleModuleFile android.WritablePath
outputFile android.WritablePath
installDir android.InstallPath
prebuiltFileToDelete string
public_key_file android.Path
private_key_file android.Path
container_certificate_file android.Path
container_private_key_file android.Path
fileContexts android.WritablePath
// list of files to be included in this apex
filesInfo []apexFile
// list of module names that should be installed along with this APEX
requiredDeps []string
// list of module names that this APEX is including (to be shown via *-deps-info target)
android.ApexBundleDepsInfo
testApex bool
vndkApex bool
artApex bool
primaryApexType bool
manifestJsonOut android.WritablePath
manifestPbOut android.WritablePath
// list of commands to create symlinks for backward compatibility.
// these commands will be attached as LOCAL_POST_INSTALL_CMD to
// apex package itself(for unflattened build) or apex_manifest(for flattened build)
// so that compat symlinks are always installed regardless of TARGET_FLATTEN_APEX setting.
compatSymlinks []string
// Suffix of module name in Android.mk
// ".flattened", ".apex", ".zipapex", or ""
suffix string
installedFilesFile android.WritablePath
// Whether to create symlink to the system file instead of having a file
// inside the apex or not
linkToSystemLib bool
// Struct holding the merged notice file paths in different formats
mergedNotices android.NoticeOutputs
// Optional list of lint report zip files for apexes that contain java or app modules
lintReports android.Paths
payloadFsType fsType
}
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,
nativeModules ApexNativeDependencies,
target android.Target, imageVariation string) {
// Use *FarVariation* to be able to depend on modules having
// conflicting variations with this module. This is required since
// arch variant of an APEX bundle is 'common' but it is 'arm' or 'arm64'
// for native shared libs.
binVariations := target.Variations()
libVariations := append(target.Variations(),
blueprint.Variation{Mutator: "link", Variation: "shared"})
if ctx.Device() {
binVariations = append(binVariations,
blueprint.Variation{Mutator: "image", Variation: imageVariation})
libVariations = append(libVariations,
blueprint.Variation{Mutator: "image", Variation: imageVariation},
blueprint.Variation{Mutator: "version", Variation: ""}) // "" is the non-stub variant
}
ctx.AddFarVariationDependencies(libVariations, sharedLibTag, nativeModules.Native_shared_libs...)
ctx.AddFarVariationDependencies(libVariations, jniLibTag, nativeModules.Jni_libs...)
ctx.AddFarVariationDependencies(binVariations, executableTag, nativeModules.Binaries...)
ctx.AddFarVariationDependencies(binVariations, testTag, nativeModules.Tests...)
}
func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
if ctx.Os().Class == android.Device {
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Android.Multilib, nil)
} else {
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Host.Multilib, nil)
if ctx.Os().Bionic() {
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_bionic.Multilib, nil)
} else {
proptools.AppendProperties(&a.properties.Multilib, &a.targetProperties.Target.Linux_glibc.Multilib, nil)
}
}
}
func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
}
targets := ctx.MultiTargets()
config := ctx.DeviceConfig()
imageVariation := a.getImageVariation(ctx)
a.combineProperties(ctx)
has32BitTarget := false
for _, target := range targets {
if target.Arch.ArchType.Multilib == "lib32" {
has32BitTarget = true
}
}
for i, target := range targets {
if target.HostCross {
// Don't include artifats for the host cross targets because there is no way
// for us to run those artifacts natively on host
continue
}
// When multilib.* is omitted for native_shared_libs/jni_libs/tests, it implies
// multilib.both
addDependenciesForNativeModules(ctx,
ApexNativeDependencies{
Native_shared_libs: a.properties.Native_shared_libs,
Tests: a.properties.Tests,
Jni_libs: a.properties.Jni_libs,
Binaries: nil,
},
target, imageVariation)
// Add native modules targetting both ABIs
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Both,
target,
imageVariation)
isPrimaryAbi := i == 0
if isPrimaryAbi {
// When multilib.* is omitted for binaries, it implies
// multilib.first
addDependenciesForNativeModules(ctx,
ApexNativeDependencies{
Native_shared_libs: nil,
Tests: nil,
Jni_libs: nil,
Binaries: a.properties.Binaries,
},
target, imageVariation)
// Add native modules targetting the first ABI
addDependenciesForNativeModules(ctx,
a.properties.Multilib.First,
target,
imageVariation)
}
switch target.Arch.ArchType.Multilib {
case "lib32":
// Add native modules targetting 32-bit ABI
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Lib32,
target,
imageVariation)
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Prefer32,
target,
imageVariation)
case "lib64":
// Add native modules targetting 64-bit ABI
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Lib64,
target,
imageVariation)
if !has32BitTarget {
addDependenciesForNativeModules(ctx,
a.properties.Multilib.Prefer32,
target,
imageVariation)
}
}
}
// For prebuilt_etc, use the first variant (64 on 64/32bit device,
// 32 on 32bit device) regardless of the TARGET_PREFER_* setting.
// b/144532908
archForPrebuiltEtc := config.Arches()[0]
for _, arch := range config.Arches() {
// Prefer 64-bit arch if there is any
if arch.ArchType.Multilib == "lib64" {
archForPrebuiltEtc = arch
break
}
}
ctx.AddFarVariationDependencies([]blueprint.Variation{
{Mutator: "os", Variation: ctx.Os().String()},
{Mutator: "arch", Variation: archForPrebuiltEtc.String()},
}, prebuiltTag, a.properties.Prebuilts...)
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
javaLibTag, a.properties.Java_libs...)
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
bpfTag, a.properties.Bpfs...)
// With EMMA_INSTRUMENT_FRAMEWORK=true the ART boot image includes jacoco library.
if a.artApex && ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
javaLibTag, "jacocoagent")
}
if String(a.properties.Key) == "" {
ctx.ModuleErrorf("key is missing")
return
}
ctx.AddDependency(ctx.Module(), keyTag, String(a.properties.Key))
cert := android.SrcIsModule(a.getCertString(ctx))
if cert != "" {
ctx.AddDependency(ctx.Module(), certificateTag, cert)
}
// TODO(jiyong): ensure that all apexes are with non-empty uses_sdks
if len(a.properties.Uses_sdks) > 0 {
sdkRefs := []android.SdkRef{}
for _, str := range a.properties.Uses_sdks {
parsed := android.ParseSdkRef(ctx, str, "uses_sdks")
sdkRefs = append(sdkRefs, parsed)
}
a.BuildWithSdks(sdkRefs)
}
}
func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutatorContext) {
if a.overridableProperties.Allowed_files != nil {
android.ExtractSourceDeps(ctx, a.overridableProperties.Allowed_files)
}
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
androidAppTag, a.overridableProperties.Apps...)
ctx.AddFarVariationDependencies(ctx.Config().AndroidCommonTarget.Variations(),
rroTag, a.overridableProperties.Rros...)
}
func (a *apexBundle) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool {
// direct deps of an APEX bundle are all part of the APEX bundle
return true
}
func (a *apexBundle) getCertString(ctx android.BaseModuleContext) string {
moduleName := ctx.ModuleName()
// VNDK APEXes share the same certificate. To avoid adding a new VNDK version to the OVERRIDE_* list,
// we check with the pseudo module name to see if its certificate is overridden.
if a.vndkApex {
moduleName = vndkApexName
}
certificate, overridden := ctx.DeviceConfig().OverrideCertificateFor(moduleName)
if overridden {
return ":" + certificate
}
return String(a.properties.Certificate)
}
func (a *apexBundle) OutputFiles(tag string) (android.Paths, error) {
switch tag {
case "":
return android.Paths{a.outputFile}, nil
default:
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
}
}
func (a *apexBundle) installable() bool {
return !a.properties.PreventInstall && (a.properties.Installable == nil || proptools.Bool(a.properties.Installable))
}
func (a *apexBundle) testOnlyShouldSkipHashtreeGeneration() bool {
return proptools.Bool(a.properties.Test_only_no_hashtree)
}
func (a *apexBundle) testOnlyShouldSkipPayloadSign() bool {
return proptools.Bool(a.properties.Test_only_unsigned_payload)
}
func (a *apexBundle) getImageVariation(ctx android.BottomUpMutatorContext) string {
deviceConfig := ctx.DeviceConfig()
if a.vndkApex {
return cc.VendorVariationPrefix + a.vndkVersion(deviceConfig)
}
var prefix string
var vndkVersion string
if deviceConfig.VndkVersion() != "" {
if proptools.Bool(a.properties.Use_vendor) {
prefix = cc.VendorVariationPrefix
vndkVersion = deviceConfig.PlatformVndkVersion()
} else if a.SocSpecific() || a.DeviceSpecific() {
prefix = cc.VendorVariationPrefix
vndkVersion = deviceConfig.VndkVersion()
} else if a.ProductSpecific() {
prefix = cc.ProductVariationPrefix
vndkVersion = deviceConfig.ProductVndkVersion()
}
}
if vndkVersion == "current" {
vndkVersion = deviceConfig.PlatformVndkVersion()
}
if vndkVersion != "" {
return prefix + vndkVersion
}
return android.CoreVariation
}
func (a *apexBundle) EnableSanitizer(sanitizerName string) {
if !android.InList(sanitizerName, a.properties.SanitizerNames) {
a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName)
}
}
func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool {
if android.InList(sanitizerName, a.properties.SanitizerNames) {
return true
}
// Then follow the global setting
globalSanitizerNames := []string{}
if a.Host() {
globalSanitizerNames = ctx.Config().SanitizeHost()
} else {
arches := ctx.Config().SanitizeDeviceArch()
if len(arches) == 0 || android.InList(a.Arch().ArchType.Name, arches) {
globalSanitizerNames = ctx.Config().SanitizeDevice()
}
}
return android.InList(sanitizerName, globalSanitizerNames)
}
func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
for _, target := range ctx.MultiTargets() {
if target.Arch.ArchType.Multilib == "lib64" {
ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
{Mutator: "image", Variation: a.getImageVariation(ctx)},
{Mutator: "link", Variation: "shared"},
{Mutator: "version", Variation: ""}, // "" is the non-stub variant
}...), sharedLibTag, "libclang_rt.hwasan-aarch64-android")
break
}
}
}
}
var _ cc.Coverage = (*apexBundle)(nil)
func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
return ctx.Device() && ctx.DeviceConfig().NativeCoverageEnabled()
}
func (a *apexBundle) PreventInstall() {
a.properties.PreventInstall = true
}
func (a *apexBundle) HideFromMake() {
a.properties.HideFromMake = true
}
func (a *apexBundle) MarkAsCoverageVariant(coverage bool) {
a.properties.IsCoverageVariant = coverage
}
func (a *apexBundle) EnableCoverageIfNeeded() {}
// TODO(jiyong) move apexFileFor* close to the apexFile type definition
func apexFileForNativeLibrary(ctx android.BaseModuleContext, ccMod *cc.Module, handleSpecialLibs bool) apexFile {
// Decide the APEX-local directory by the multilib of the library
// In the future, we may query this to the module.
var dirInApex string
switch ccMod.Arch().ArchType.Multilib {
case "lib32":
dirInApex = "lib"
case "lib64":
dirInApex = "lib64"
}
if ccMod.Target().NativeBridge == android.NativeBridgeEnabled {
dirInApex = filepath.Join(dirInApex, ccMod.Target().NativeBridgeRelativePath)
}
dirInApex = filepath.Join(dirInApex, ccMod.RelativeInstallPath())
if handleSpecialLibs && cc.InstallToBootstrap(ccMod.BaseModuleName(), ctx.Config()) {
// Special case for Bionic libs and other libs installed with them. This is
// to prevent those libs from being included in the search path
// /apex/com.android.runtime/${LIB}. This exclusion is required because
// those libs in the Runtime APEX are available via the legacy paths in
// /system/lib/. By the init process, the libs in the APEX are bind-mounted
// to the legacy paths and thus will be loaded into the default linker
// namespace (aka "platform" namespace). If the libs are directly in
// /apex/com.android.runtime/${LIB} then the same libs will be loaded again
// into the runtime linker namespace, which will result in double loading of
// them, which isn't supported.
dirInApex = filepath.Join(dirInApex, "bionic")
}
fileToCopy := ccMod.OutputFile().Path()
androidMkModuleName := ccMod.BaseModuleName() + ccMod.Properties.SubName
return newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeSharedLib, ccMod)
}
func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFile {
dirInApex := "bin"
if cc.Target().NativeBridge == android.NativeBridgeEnabled {
dirInApex = filepath.Join(dirInApex, cc.Target().NativeBridgeRelativePath)
}
dirInApex = filepath.Join(dirInApex, cc.RelativeInstallPath())
fileToCopy := cc.OutputFile().Path()
androidMkModuleName := cc.BaseModuleName() + cc.Properties.SubName
af := newApexFile(ctx, fileToCopy, androidMkModuleName, dirInApex, nativeExecutable, cc)
af.symlinks = cc.Symlinks()
af.dataPaths = cc.DataPaths()
return af
}
func apexFileForPyBinary(ctx android.BaseModuleContext, py *python.Module) apexFile {
dirInApex := "bin"
fileToCopy := py.HostToolPath().Path()
return newApexFile(ctx, fileToCopy, py.BaseModuleName(), dirInApex, pyBinary, py)
}
func apexFileForGoBinary(ctx android.BaseModuleContext, depName string, gb bootstrap.GoBinaryTool) apexFile {
dirInApex := "bin"
s, err := filepath.Rel(android.PathForOutput(ctx).String(), gb.InstallPath())
if err != nil {
ctx.ModuleErrorf("Unable to use compiled binary at %s", gb.InstallPath())
return apexFile{}
}
fileToCopy := android.PathForOutput(ctx, s)
// NB: Since go binaries are static we don't need the module for anything here, which is
// good since the go tool is a blueprint.Module not an android.Module like we would
// normally use.
return newApexFile(ctx, fileToCopy, depName, dirInApex, goBinary, nil)
}
func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFile {
dirInApex := filepath.Join("bin", sh.SubDir())
fileToCopy := sh.OutputFile()
af := newApexFile(ctx, fileToCopy, sh.BaseModuleName(), dirInApex, shBinary, sh)
af.symlinks = sh.Symlinks()
return af
}
type javaModule interface {
android.Module
BaseModuleName() string
DexJarBuildPath() android.Path
JacocoReportClassesFile() android.Path
LintDepSets() java.LintDepSets
Stem() string
}
var _ javaModule = (*java.Library)(nil)
var _ javaModule = (*java.SdkLibrary)(nil)
var _ javaModule = (*java.DexImport)(nil)
var _ javaModule = (*java.SdkLibraryImport)(nil)
func apexFileForJavaLibrary(ctx android.BaseModuleContext, module javaModule) apexFile {
dirInApex := "javalib"
fileToCopy := module.DexJarBuildPath()
af := newApexFile(ctx, fileToCopy, module.BaseModuleName(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = module.JacocoReportClassesFile()
af.lintDepSets = module.LintDepSets()
af.stem = module.Stem() + ".jar"
return af
}
func apexFileForPrebuiltEtc(ctx android.BaseModuleContext, prebuilt prebuilt_etc.PrebuiltEtcModule, depName string) apexFile {
dirInApex := filepath.Join(prebuilt.BaseDir(), prebuilt.SubDir())
fileToCopy := prebuilt.OutputFile()
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, prebuilt)
}
func apexFileForCompatConfig(ctx android.BaseModuleContext, config java.PlatformCompatConfigIntf, depName string) apexFile {
dirInApex := filepath.Join("etc", config.SubDir())
fileToCopy := config.CompatConfig()
return newApexFile(ctx, fileToCopy, depName, dirInApex, etc, config)
}
func apexFileForAndroidApp(ctx android.BaseModuleContext, aapp interface {
android.Module
Privileged() bool
InstallApkName() string
OutputFile() android.Path
JacocoReportClassesFile() android.Path
Certificate() java.Certificate
BaseModuleName() string
}) apexFile {
appDir := "app"
if aapp.Privileged() {
appDir = "priv-app"
}
dirInApex := filepath.Join(appDir, aapp.InstallApkName())
fileToCopy := aapp.OutputFile()
af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp)
af.jacocoReportClassesFile = aapp.JacocoReportClassesFile()
af.certificate = aapp.Certificate()
if app, ok := aapp.(interface {
OverriddenManifestPackageName() string
}); ok {
af.overriddenPackageName = app.OverriddenManifestPackageName()
}
return af
}
func apexFileForRuntimeResourceOverlay(ctx android.BaseModuleContext, rro java.RuntimeResourceOverlayModule) apexFile {
rroDir := "overlay"
dirInApex := filepath.Join(rroDir, rro.Theme())
fileToCopy := rro.OutputFile()
af := newApexFile(ctx, fileToCopy, rro.Name(), dirInApex, app, rro)
af.certificate = rro.Certificate()
if a, ok := rro.(interface {
OverriddenManifestPackageName() string
}); ok {
af.overriddenPackageName = a.OverriddenManifestPackageName()
}
return af
}
func apexFileForBpfProgram(ctx android.BaseModuleContext, builtFile android.Path, bpfProgram bpf.BpfModule) apexFile {
dirInApex := filepath.Join("etc", "bpf")
return newApexFile(ctx, builtFile, builtFile.Base(), dirInApex, etc, bpfProgram)
}
// Context "decorator", overriding the InstallBypassMake method to always reply `true`.
type flattenedApexContext struct {
android.ModuleContext
}
func (c *flattenedApexContext) InstallBypassMake() bool {
return true
}
// Visit dependencies that contributes to the payload of this APEX
func (a *apexBundle) WalkPayloadDeps(ctx android.ModuleContext, do android.PayloadDepsCallback) {
ctx.WalkDeps(func(child, parent android.Module) bool {
am, ok := child.(android.ApexModule)
if !ok || !am.CanHaveApexVariants() {
return false
}
childApexInfo := ctx.OtherModuleProvider(child, android.ApexInfoProvider).(android.ApexInfo)
dt := ctx.OtherModuleDependencyTag(child)
if _, ok := dt.(android.ExcludeFromApexContentsTag); ok {
return false
}
// Check for the direct dependencies that contribute to the payload
if adt, ok := dt.(dependencyTag); ok {
if adt.payload {
return do(ctx, parent, am, false /* externalDep */)
}
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
}
// Check for the indirect dependencies if it is considered as part of the APEX
if android.InList(ctx.ModuleName(), childApexInfo.InApexes) {
return do(ctx, parent, am, false /* externalDep */)
}
return do(ctx, parent, am, true /* externalDep */)
})
}
func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) android.ApiLevel {
ver := proptools.String(a.properties.Min_sdk_version)
if ver == "" {
return android.FutureApiLevel
}
apiLevel, err := android.ApiLevelFromUser(ctx, ver)
if err != nil {
ctx.PropertyErrorf("min_sdk_version", "%s", err.Error())
return android.NoneApiLevel
}
if apiLevel.IsPreview() {
// All codenames should build against "current".
return android.FutureApiLevel
}
return apiLevel
}
func (a *apexBundle) Updatable() bool {
return proptools.Bool(a.properties.Updatable)
}
var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
// Ensures that the dependencies are marked as available for this APEX
func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
// Let's be practical. Availability for test, host, and the VNDK apex isn't important
if ctx.Host() || a.testApex || a.vndkApex {
return
}
// Because APEXes targeting other than system/system_ext partitions
// can't set apex_available, we skip checks for these APEXes
if a.SocSpecific() || a.DeviceSpecific() ||
(a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
return
}
// Coverage build adds additional dependencies for the coverage-only runtime libraries.
// Requiring them and their transitive depencies with apex_available is not right
// because they just add noise.
if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) {
return
}
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
if externalDep {
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
}
apexName := ctx.ModuleName()
fromName := ctx.OtherModuleName(from)
toName := ctx.OtherModuleName(to)
// If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
// do any of its dependencies.
if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
}
if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
return true
}
ctx.ModuleErrorf("%q requires %q that is not available for the APEX. Dependency path:%s", fromName, toName, ctx.GetPathString(true))
// Visit this module's dependencies to check and report any issues with their availability.
return true
})
}
func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
if a.Updatable() {
if String(a.properties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
}
a.checkJavaStableSdkVersion(ctx)
}
}
func (a *apexBundle) checkMinSdkVersion(ctx android.ModuleContext) {
if a.testApex || a.vndkApex {
return
}
// Meaningless to check min_sdk_version when building use_vendor modules against non-Trebleized targets
if proptools.Bool(a.properties.Use_vendor) && ctx.DeviceConfig().VndkVersion() == "" {
return
}
// apexBundle::minSdkVersion reports its own errors.
minSdkVersion := a.minSdkVersion(ctx)
android.CheckMinSdkVersion(a, ctx, minSdkVersion)
}
// Ensures that a lib providing stub isn't statically linked
func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
// Practically, we only care about regular APEXes on the device.
if ctx.Host() || a.testApex || a.vndkApex {
return
}
abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
a.WalkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
if ccm, ok := to.(*cc.Module); ok {
apexName := ctx.ModuleName()
fromName := ctx.OtherModuleName(from)
toName := ctx.OtherModuleName(to)
// If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither
// do any of its dependencies.
if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) {
// As soon as the dependency graph crosses the APEX boundary, don't go further.
return false
}
// The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule.
// It can't make the static dependencies dynamic because it can't
// do the dynamic linking for itself.
if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") {
return false
}
isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName)
if isStubLibraryFromOtherApex && !externalDep {
ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
"It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
}
}
return true
})
}
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuildApps()
switch a.properties.ApexType {
case imageApex:
if buildFlattenedAsDefault {
a.suffix = imageApexSuffix
} else {
a.suffix = ""
a.primaryApexType = true
if ctx.Config().InstallExtraFlattenedApexes() {
a.requiredDeps = append(a.requiredDeps, a.Name()+flattenedSuffix)
}
}
case zipApex:
if proptools.String(a.properties.Payload_type) == "zip" {
a.suffix = ""
a.primaryApexType = true
} else {
a.suffix = zipApexSuffix
}
case flattenedApex:
if buildFlattenedAsDefault {
a.suffix = ""
a.primaryApexType = true
} else {
a.suffix = flattenedSuffix
}
}
if len(a.properties.Tests) > 0 && !a.testApex {
ctx.PropertyErrorf("tests", "property not allowed in apex module type")
return
}
a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
a.checkMinSdkVersion(ctx)
a.checkStaticLinkingToStubLibraries(ctx)
handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
// native lib dependencies
var provideNativeLibs []string
var requireNativeLibs []string
// Check if "uses" requirements are met with dependent apexBundles
var providedNativeSharedLibs []string
useVendor := proptools.Bool(a.properties.Use_vendor)
ctx.VisitDirectDepsBlueprint(func(m blueprint.Module) {
if ctx.OtherModuleDependencyTag(m) != usesTag {
return
}
otherName := ctx.OtherModuleName(m)
other, ok := m.(*apexBundle)
if !ok {
ctx.PropertyErrorf("uses", "%q is not a provider", otherName)
return
}
if proptools.Bool(other.properties.Use_vendor) != useVendor {
ctx.PropertyErrorf("use_vendor", "%q has different value of use_vendor", otherName)
return
}
if !proptools.Bool(other.properties.Provide_cpp_shared_libs) {
ctx.PropertyErrorf("uses", "%q does not provide native_shared_libs", otherName)
return
}
providedNativeSharedLibs = append(providedNativeSharedLibs, other.properties.Native_shared_libs...)
})
var filesInfo []apexFile
// TODO(jiyong) do this using WalkPayloadDeps
ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool {
depTag := ctx.OtherModuleDependencyTag(child)
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
return false
}
depName := ctx.OtherModuleName(child)
if _, isDirectDep := parent.(*apexBundle); isDirectDep {
switch depTag {
case sharedLibTag, jniLibTag:
isJniLib := depTag == jniLibTag
if c, ok := child.(*cc.Module); ok {
fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
fi.isJniLib = isJniLib
filesInfo = append(filesInfo, fi)
// Collect the list of stub-providing libs except:
// - VNDK libs are only for vendors
// - bootstrap bionic libs are treated as provided by system
if c.HasStubsVariants() && !a.vndkApex && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
provideNativeLibs = append(provideNativeLibs, fi.Stem())
}
return true // track transitive dependencies
} else {
propertyName := "native_shared_libs"
if isJniLib {
propertyName = "jni_libs"
}
ctx.PropertyErrorf(propertyName, "%q is not a cc_library or cc_library_shared module", depName)
}
case executableTag:
if cc, ok := child.(*cc.Module); ok {
filesInfo = append(filesInfo, apexFileForExecutable(ctx, cc))
return true // track transitive dependencies
} else if sh, ok := child.(*sh.ShBinary); ok {
filesInfo = append(filesInfo, apexFileForShBinary(ctx, sh))
} else if py, ok := child.(*python.Module); ok && py.HostToolPath().Valid() {
filesInfo = append(filesInfo, apexFileForPyBinary(ctx, py))
} else if gb, ok := child.(bootstrap.GoBinaryTool); ok && a.Host() {
filesInfo = append(filesInfo, apexFileForGoBinary(ctx, depName, gb))
} else {
ctx.PropertyErrorf("binaries", "%q is neither cc_binary, (embedded) py_binary, (host) blueprint_go_binary, (host) bootstrap_go_binary, nor sh_binary", depName)
}
case javaLibTag:
switch child.(type) {
case *java.Library, *java.SdkLibrary, *java.DexImport, *java.SdkLibraryImport:
af := apexFileForJavaLibrary(ctx, child.(javaModule))
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
return false
}
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
default:
ctx.PropertyErrorf("java_libs", "%q of type %q is not supported", depName, ctx.OtherModuleType(child))
}
case androidAppTag:
if ap, ok := child.(*java.AndroidApp); ok {
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
return true // track transitive dependencies
} else if ap, ok := child.(*java.AndroidAppImport); ok {
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
} else if ap, ok := child.(*java.AndroidTestHelperApp); ok {
filesInfo = append(filesInfo, apexFileForAndroidApp(ctx, ap))
} else if ap, ok := child.(*java.AndroidAppSet); ok {
appDir := "app"
if ap.Privileged() {
appDir = "priv-app"
}
af := newApexFile(ctx, ap.OutputFile(), ap.BaseModuleName(),
filepath.Join(appDir, ap.BaseModuleName()), appSet, ap)
af.certificate = java.PresignedCertificate
filesInfo = append(filesInfo, af)
} else {
ctx.PropertyErrorf("apps", "%q is not an android_app module", depName)
}
case rroTag:
if rro, ok := child.(java.RuntimeResourceOverlayModule); ok {
filesInfo = append(filesInfo, apexFileForRuntimeResourceOverlay(ctx, rro))
} else {
ctx.PropertyErrorf("rros", "%q is not an runtime_resource_overlay module", depName)
}
case bpfTag:
if bpfProgram, ok := child.(bpf.BpfModule); ok {
filesToCopy, _ := bpfProgram.OutputFiles("")
for _, bpfFile := range filesToCopy {
filesInfo = append(filesInfo, apexFileForBpfProgram(ctx, bpfFile, bpfProgram))
}
} else {
ctx.PropertyErrorf("bpfs", "%q is not a bpf module", depName)
}
case prebuiltTag:
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
} else if prebuilt, ok := child.(java.PlatformCompatConfigIntf); ok {
filesInfo = append(filesInfo, apexFileForCompatConfig(ctx, prebuilt, depName))
} else {
ctx.PropertyErrorf("prebuilts", "%q is not a prebuilt_etc and not a platform_compat_config module", depName)
}
case testTag:
if ccTest, ok := child.(*cc.Module); ok {
if ccTest.IsTestPerSrcAllTestsVariation() {
// Multiple-output test module (where `test_per_src: true`).
//
// `ccTest` is the "" ("all tests") variation of a `test_per_src` module.
// We do not add this variation to `filesInfo`, as it has no output;
// however, we do add the other variations of this module as indirect
// dependencies (see below).
} else {
// Single-output test module (where `test_per_src: false`).
af := apexFileForExecutable(ctx, ccTest)
af.class = nativeTest
filesInfo = append(filesInfo, af)
}
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("tests", "%q is not a cc module", depName)
}
case keyTag:
if key, ok := child.(*apexKey); ok {
a.private_key_file = key.private_key_file
a.public_key_file = key.public_key_file
} else {
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
}
return false
case certificateTag:
if dep, ok := child.(*java.AndroidAppCertificate); ok {
a.container_certificate_file = dep.Certificate.Pem
a.container_private_key_file = dep.Certificate.Key
} else {
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
}
case android.PrebuiltDepTag:
// If the prebuilt is force disabled, remember to delete the prebuilt file
// that might have been installed in the previous builds
if prebuilt, ok := child.(prebuilt); ok && prebuilt.isForceDisabled() {
a.prebuiltFileToDelete = prebuilt.InstallFilename()
}
}
} else if !a.vndkApex {
// indirect dependencies
if am, ok := child.(android.ApexModule); ok {
// We cannot use a switch statement on `depTag` here as the checked
// tags used below are private (e.g. `cc.sharedDepTag`).
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
if cc, ok := child.(*cc.Module); ok {
if android.InList(cc.Name(), providedNativeSharedLibs) {
// If we're using a shared library which is provided from other APEX,
// don't include it in this APEX
return false
}
if cc.UseVndk() && proptools.Bool(a.properties.Use_vndk_as_stable) && cc.IsVndk() {
requireNativeLibs = append(requireNativeLibs, ":vndk")
return false
}
af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
af.transitiveDep = true
abInfo := ctx.Provider(ApexBundleInfoProvider).(ApexBundleInfo)
if !a.Host() && !abInfo.Contents.DirectlyInApex(depName) && (cc.IsStubs() || cc.HasStubsVariants()) {
// If the dependency is a stubs lib, don't include it in this APEX,
// but make sure that the lib is installed on the device.
// In case no APEX is having the lib, the lib is installed to the system
// partition.
//
// Always include if we are a host-apex however since those won't have any
// system libraries.
if !am.DirectlyInAnyApex() {
// we need a module name for Make
name := cc.BaseModuleName() + cc.Properties.SubName
if proptools.Bool(a.properties.Use_vendor) {
// we don't use subName(.vendor) for a "use_vendor: true" apex
// which is supposed to be installed in /system
name = cc.BaseModuleName()
}
if !android.InList(name, a.requiredDeps) {
a.requiredDeps = append(a.requiredDeps, name)
}
}
requireNativeLibs = append(requireNativeLibs, af.Stem())
// Don't track further
return false
}
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
} else if cc.IsTestPerSrcDepTag(depTag) {
if cc, ok := child.(*cc.Module); ok {
af := apexFileForExecutable(ctx, cc)
// Handle modules created as `test_per_src` variations of a single test module:
// use the name of the generated test binary (`fileToCopy`) instead of the name
// of the original test module (`depName`, shared by all `test_per_src`
// variations of that module).
af.androidMkModuleName = filepath.Base(af.builtFile.String())
// these are not considered transitive dep
af.transitiveDep = false
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
} else if java.IsJniDepTag(depTag) {
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
return false
} else if java.IsXmlPermissionsFileDepTag(depTag) {
if prebuilt, ok := child.(prebuilt_etc.PrebuiltEtcModule); ok {
filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName))
}
} else if _, ok := depTag.(android.CopyDirectlyInAnyApexTag); ok {
// nothing
} else if am.CanHaveApexVariants() && am.IsInstallableToApex() {
ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
}
}
}
return false
})
// Specific to the ART apex: dexpreopt artifacts for libcore Java libraries.
// Build rules are generated by the dexpreopt singleton, and here we access build artifacts
// via the global boot image config.
if a.artApex {
for arch, files := range java.DexpreoptedArtApexJars(ctx) {
dirInApex := filepath.Join("javalib", arch.String())
for _, f := range files {
localModule := "javalib_" + arch.String() + "_" + filepath.Base(f.String())
af := newApexFile(ctx, f, localModule, dirInApex, etc, nil)
filesInfo = append(filesInfo, af)
}
}
}
if a.private_key_file == nil {
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
return
}
// remove duplicates in filesInfo
removeDup := func(filesInfo []apexFile) []apexFile {
encountered := make(map[string]apexFile)
for _, f := range filesInfo {
dest := filepath.Join(f.installDir, f.builtFile.Base())
if e, ok := encountered[dest]; !ok {
encountered[dest] = f
} else {
// If a module is directly included and also transitively depended on
// consider it as directly included.
e.transitiveDep = e.transitiveDep && f.transitiveDep
encountered[dest] = e
}
}
var result []apexFile
for _, v := range encountered {
result = append(result, v)
}
return result
}
filesInfo = removeDup(filesInfo)
// to have consistent build rules
sort.Slice(filesInfo, func(i, j int) bool {
return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String()
})
a.installDir = android.PathForModuleInstall(ctx, "apex")
a.filesInfo = filesInfo
switch proptools.StringDefault(a.properties.Payload_fs_type, ext4FsType) {
case ext4FsType:
a.payloadFsType = ext4
case f2fsFsType:
a.payloadFsType = f2fs
default:
ctx.PropertyErrorf("payload_fs_type", "%q is not a valid filesystem for apex [ext4, f2fs]", *a.properties.Payload_fs_type)
}
// Optimization. If we are building bundled APEX, for the files that are gathered due to the
// transitive dependencies, don't place them inside the APEX, but place a symlink pointing
// the same library in the system partition, thus effectively sharing the same libraries
// across the APEX boundary. For unbundled APEX, all the gathered files are actually placed
// in the APEX.
a.linkToSystemLib = !ctx.Config().UnbundledBuild() &&
a.installable() &&
!proptools.Bool(a.properties.Use_vendor)
// APEXes targeting other than system/system_ext partitions use vendor/product variants.
// So we can't link them to /system/lib libs which are core variants.
if a.SocSpecific() || a.DeviceSpecific() ||
(a.ProductSpecific() && ctx.Config().EnforceProductPartitionInterface()) {
a.linkToSystemLib = false
}
// We don't need the optimization for updatable APEXes, as it might give false signal
// to the system health when the APEXes are still bundled (b/149805758)
if a.Updatable() && a.properties.ApexType == imageApex {
a.linkToSystemLib = false
}
// We also don't want the optimization for host APEXes, because it doesn't make sense.
if ctx.Host() {
a.linkToSystemLib = false
}
// prepare apex_manifest.json
a.buildManifest(ctx, provideNativeLibs, requireNativeLibs)
a.buildFileContexts(ctx)
a.setCertificateAndPrivateKey(ctx)
if a.properties.ApexType == flattenedApex {
a.buildFlattenedApex(ctx)
} else {
a.buildUnflattenedApex(ctx)
}
a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx)
a.buildApexDependencyInfo(ctx)
a.buildLintReports(ctx)
}
// Enforce that Java deps of the apex are using stable SDKs to compile
func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
// Visit direct deps only. As long as we guarantee top-level deps are using
// stable SDKs, java's checkLinkType guarantees correct usage for transitive deps
ctx.VisitDirectDepsBlueprint(func(module blueprint.Module) {
tag := ctx.OtherModuleDependencyTag(module)
switch tag {
case javaLibTag, androidAppTag:
if m, ok := module.(interface{ CheckStableSdkVersion() error }); ok {
if err := m.CheckStableSdkVersion(); err != nil {
ctx.ModuleErrorf("cannot depend on \"%v\": %v", ctx.OtherModuleName(module), err)
}
}
}
})
}
func baselineApexAvailable(apex, moduleName string) bool {
key := apex
moduleName = normalizeModuleName(moduleName)
if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
return true
}
key = android.AvailableToAnyApex
if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
return true
}
return false
}
func normalizeModuleName(moduleName string) string {
// Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build
// system. Trim the prefix for the check since they are confusing
moduleName = strings.TrimPrefix(moduleName, "prebuilt_")
if strings.HasPrefix(moduleName, "libclang_rt.") {
// This module has many arch variants that depend on the product being built.
// We don't want to list them all
moduleName = "libclang_rt"
}
if strings.HasPrefix(moduleName, "androidx.") {
// TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
moduleName = "androidx"
}
return moduleName
}
func newApexBundle() *apexBundle {
module := &apexBundle{}
module.AddProperties(&module.properties)
module.AddProperties(&module.targetProperties)
module.AddProperties(&module.overridableProperties)
android.InitAndroidMultiTargetsArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
android.InitDefaultableModule(module)
android.InitSdkAwareModule(module)
android.InitOverridableModule(module, &module.overridableProperties.Overrides)
return module
}
func ApexBundleFactory(testApex bool, artApex bool) android.Module {
bundle := newApexBundle()
bundle.testApex = testApex
bundle.artApex = artApex
return bundle
}
// apex_test is an APEX for testing. The difference from the ordinary apex module type is that
// certain compatibility checks such as apex_available are not done for apex_test.
func testApexBundleFactory() android.Module {
bundle := newApexBundle()
bundle.testApex = true
return bundle
}
// apex packages other modules into an APEX file which is a packaging format for system-level
// components like binaries, shared libraries, etc.
func BundleFactory() android.Module {
return newApexBundle()
}
//
// Defaults
//
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
}
func defaultsFactory() android.Module {
return DefaultsFactory()
}
func DefaultsFactory(props ...interface{}) android.Module {
module := &Defaults{}
module.AddProperties(props...)
module.AddProperties(
&apexBundleProperties{},
&apexTargetBundleProperties{},
&overridableProperties{},
)
android.InitDefaultsModule(module)
return module
}
//
// OverrideApex
//
type OverrideApex struct {
android.ModuleBase
android.OverrideModuleBase
}
func (o *OverrideApex) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// All the overrides happen in the base module.
}
// override_apex is used to create an apex module based on another apex module
// by overriding some of its properties.
func overrideApexFactory() android.Module {
m := &OverrideApex{}
m.AddProperties(&overridableProperties{})
android.InitAndroidMultiTargetsArchModule(m, android.DeviceSupported, android.MultilibCommon)
android.InitOverrideModule(m)
return m
}
|