* Package up an asset directory and associated application files. */
| 1875 | * Package up an asset directory and associated application files. |
| 1876 | */ |
| 1877 | int doPackage(Bundle* bundle) |
| 1878 | { |
| 1879 | const char* outputAPKFile; |
| 1880 | int retVal = 1; |
| 1881 | status_t err; |
| 1882 | sp<AaptAssets> assets; |
| 1883 | int N; |
| 1884 | FILE* fp; |
| 1885 | String8 dependencyFile; |
| 1886 | |
| 1887 | // -c zz_ZZ means do pseudolocalization |
| 1888 | ResourceFilter filter; |
| 1889 | err = filter.parse(bundle->getConfigurations()); |
| 1890 | if (err != NO_ERROR) { |
| 1891 | goto bail; |
| 1892 | } |
| 1893 | if (filter.containsPseudo()) { |
| 1894 | bundle->setPseudolocalize(true); |
| 1895 | } |
| 1896 | |
| 1897 | N = bundle->getFileSpecCount(); |
| 1898 | if (N < 1 && bundle->getResourceSourceDirs().size() == 0 && bundle->getJarFiles().size() == 0 |
| 1899 | && bundle->getAndroidManifestFile() == NULL && bundle->getAssetSourceDir() == NULL) { |
| 1900 | fprintf(stderr, "ERROR: no input files\n"); |
| 1901 | goto bail; |
| 1902 | } |
| 1903 | |
| 1904 | outputAPKFile = bundle->getOutputAPKFile(); |
| 1905 | |
| 1906 | // Make sure the filenames provided exist and are of the appropriate type. |
| 1907 | if (outputAPKFile) { |
| 1908 | FileType type; |
| 1909 | type = getFileType(outputAPKFile); |
| 1910 | if (type != kFileTypeNonexistent && type != kFileTypeRegular) { |
| 1911 | fprintf(stderr, |
| 1912 | "ERROR: output file '%s' exists but is not regular file\n", |
| 1913 | outputAPKFile); |
| 1914 | goto bail; |
| 1915 | } |
| 1916 | } |
| 1917 | |
| 1918 | // Load the assets. |
| 1919 | assets = new AaptAssets(); |
| 1920 | |
| 1921 | // Set up the resource gathering in assets if we're going to generate |
| 1922 | // dependency files. Every time we encounter a resource while slurping |
| 1923 | // the tree, we'll add it to these stores so we have full resource paths |
| 1924 | // to write to a dependency file. |
| 1925 | if (bundle->getGenDependencies()) { |
| 1926 | sp<FilePathStore> resPathStore = new FilePathStore; |
| 1927 | assets->setFullResPaths(resPathStore); |
| 1928 | sp<FilePathStore> assetPathStore = new FilePathStore; |
| 1929 | assets->setFullAssetPaths(assetPathStore); |
| 1930 | } |
| 1931 | |
| 1932 | err = assets->slurpFromArgs(bundle); |
| 1933 | if (err < 0) { |
| 1934 | goto bail; |
no test coverage detected