Skip to content

Commit

Permalink
Prepare for release 0.7.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
plecesne committed Nov 19, 2018
1 parent 2f29336 commit 1146d79
Show file tree
Hide file tree
Showing 72 changed files with 3,310 additions and 787 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Read more about the App Bundle format and Bundletool's usage at

## Releases

Latest release: [0.7.0](https://github.com/google/bundletool/releases)
Latest release: [0.7.1](https://github.com/google/bundletool/releases)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
release_version = 0.7.0
release_version = 0.7.1
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ public static CommandHelp help() {
FlagDescription.builder()
.setFlagName(DEVICE_SPEC_FLAG.getName())
.setExampleValue("device-spec.json")
.setOptional(true)
.setDescription(
"Path to the device spec file generated by the '%s' command. If present, "
+ "it will generate an APK Set optimized for the specified device spec.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import com.android.bundle.Config.BundleConfig;
import com.android.bundle.Config.Bundletool;
import com.android.bundle.Files.ApexImages;
import com.android.bundle.Files.Assets;
import com.android.bundle.Files.NativeLibraries;
import com.android.tools.build.bundletool.commands.CommandHelp.CommandDescription;
Expand Down Expand Up @@ -177,8 +178,10 @@ public void execute() {
ZipBuilder bundleBuilder = new ZipBuilder();

try (Closer closer = Closer.create()) {
EntryOption[] compression =
getUncompressedBundle() ? new EntryOption[] {EntryOption.UNCOMPRESSED} : new EntryOption[0];
EntryOption[] compression =
getUncompressedBundle()
? new EntryOption[] {EntryOption.UNCOMPRESSED}
: new EntryOption[0];

// Merge in all the modules, each module into its own sub-directory.
for (Path module : getModulesPaths()) {
Expand All @@ -189,17 +192,23 @@ public void execute() {
bundleBuilder.copyAllContentsFromZip(moduleDir, moduleZipFile, compression);

Optional<Assets> assetsTargeting = generateAssetsTargeting(moduleZipFile);
if (assetsTargeting.isPresent()) {
bundleBuilder.addFileWithProtoContent(
moduleDir.resolve("assets.pb"), assetsTargeting.get(), compression);
}
assetsTargeting.ifPresent(
targeting ->
bundleBuilder.addFileWithProtoContent(
moduleDir.resolve("assets.pb"), targeting, compression));

Optional<NativeLibraries> nativeLibrariesTargeting =
generateNativeLibrariesTargeting(moduleZipFile);
if (nativeLibrariesTargeting.isPresent()) {
bundleBuilder.addFileWithProtoContent(
moduleDir.resolve("native.pb"), nativeLibrariesTargeting.get(), compression);
}
nativeLibrariesTargeting.ifPresent(
targeting ->
bundleBuilder.addFileWithProtoContent(
moduleDir.resolve("native.pb"), targeting, compression));

Optional<ApexImages> apexImagesTargeting = generateApexImagesTargeting(moduleZipFile);
apexImagesTargeting.ifPresent(
targeting ->
bundleBuilder.addFileWithProtoContent(
moduleDir.resolve("apex.pb"), targeting, compression));
} catch (ZipException e) {
throw CommandExecutionException.builder()
.withCause(e)
Expand Down Expand Up @@ -261,7 +270,8 @@ private void validateInput() {

private Optional<Assets> generateAssetsTargeting(ZipFile module) {
ImmutableList<ZipPath> assetDirectories =
ZipUtils.getFilesWithPathPrefix(module, BundleModule.ASSETS_DIRECTORY)
ZipUtils.allFileEntriesPaths(module)
.filter(path -> path.startsWith(BundleModule.ASSETS_DIRECTORY))
.filter(path -> path.getNameCount() > 1)
.map(ZipPath::getParent)
.distinct()
Expand All @@ -278,7 +288,8 @@ private Optional<NativeLibraries> generateNativeLibrariesTargeting(ZipFile modul
// Validation ensures that files under "lib/" conform to pattern "lib/<abi-dir>/file.so".
// We extract the distinct "lib/<abi-dir>" directories.
ImmutableList<String> libAbiDirs =
ZipUtils.getFilesWithPathPrefix(module, BundleModule.LIB_DIRECTORY)
ZipUtils.allFileEntriesPaths(module)
.filter(path -> path.startsWith(BundleModule.LIB_DIRECTORY))
.filter(path -> path.getNameCount() > 2)
.map(path -> path.subpath(0, 2))
.map(ZipPath::toString)
Expand All @@ -292,6 +303,21 @@ private Optional<NativeLibraries> generateNativeLibrariesTargeting(ZipFile modul
return Optional.of(new TargetingGenerator().generateTargetingForNativeLibraries(libAbiDirs));
}

private Optional<ApexImages> generateApexImagesTargeting(ZipFile module) {
// Validation ensures that files under "apex/" conform to the pattern
// "apex/<abi1>.<abi2>...<abiN>.img".
ImmutableList<ZipPath> apexImageFiles =
ZipUtils.allFileEntriesPaths(module)
.filter(path -> path.startsWith(BundleModule.APEX_DIRECTORY))
.collect(toImmutableList());

if (apexImageFiles.isEmpty()) {
return Optional.empty();
}

return Optional.of(new TargetingGenerator().generateTargetingForApexImages(apexImageFiles));
}

private static BundleConfig parseBundleConfigJson(Path bundleConfigJsonPath) {
BundleConfig.Builder bundleConfig = BundleConfig.newBuilder();
try (Reader bundleConfigReader = BufferedIo.reader(bundleConfigJsonPath)) {
Expand Down
Loading

0 comments on commit 1146d79

Please sign in to comment.