Skip to content

Commit

Permalink
Prepare for release 0.4.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
plecesne committed May 21, 2018
1 parent 8feb7e3 commit b6d7036
Show file tree
Hide file tree
Showing 35 changed files with 443 additions and 176 deletions.
60 changes: 30 additions & 30 deletions .github/ISSUE_TEMPLATE/Bug_report.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Bundletool version(s) affected**
Version: [e.g. 0.3.3]

**Stacktrace**
Copy all of the output of the command, including the stacktrace if visible.

**To Reproduce**
Steps to reproduce the behavior.
Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Known workaround**
If you have found a workaround, please specify what it is.

**Environment:**
OS: [e.g. iOS 10.3.3]

**Additional context**
Add any other context about the problem here.
---
name: Bug report
about: Create a report to help us improve

---

**Describe the bug**
A clear and concise description of what the bug is.

**Bundletool version(s) affected**
Version: [e.g. 0.3.3]

**Stacktrace**
Copy all of the output of the command, including the stacktrace if visible.

**To Reproduce**
Steps to reproduce the behavior.
Include the full command being run as well as, if possible, artifacts the bug can be reproduced with.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Known workaround**
If you have found a workaround, please specify what it is.

**Environment:**
OS: [e.g. iOS 10.3.3]

**Additional context**
Add any other context about the problem here.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/Custom.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Custom issue
about: Give some feedback that's not a bug or a feature request

---


---
name: Custom issue
about: Give some feedback that's not a bug or a feature request

---


34 changes: 17 additions & 17 deletions .github/ISSUE_TEMPLATE/Feature_request.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. It's very inconvenient to have to do [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. It's very inconvenient to have to do [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ Read more about the App Bundle format and Bundletool's usage at

## Releases

Latest release: [0.3.3](https://github.com/google/bundletool/releases)
Latest release: [0.4.0](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.3.3
release_version = 0.4.0
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
import com.android.tools.build.bundletool.utils.flags.Flag.Password;
import com.android.tools.build.bundletool.utils.flags.ParsedFlags;
import com.android.tools.build.bundletool.validation.AppBundleValidator;
import com.android.tools.build.bundletool.version.BundleToolVersion;
import com.android.tools.build.bundletool.version.Version;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand Down Expand Up @@ -88,8 +90,8 @@ public abstract class BuildApksCommand {

private static final Flag<Path> BUNDLE_LOCATION_FLAG = Flag.path("bundle");
private static final Flag<Path> OUTPUT_FILE_FLAG = Flag.path("output");
private static final Flag<ImmutableList<OptimizationDimension>> OPTIMIZE_FOR_FLAG =
Flag.enumList("optimize-for", OptimizationDimension.class);
private static final Flag<ImmutableSet<OptimizationDimension>> OPTIMIZE_FOR_FLAG =
Flag.enumSet("optimize-for", OptimizationDimension.class);
private static final Flag<Path> AAPT2_PATH_FLAG = Flag.path("aapt2");
private static final Flag<Boolean> GENERATE_UNIVERSAL_APK_FLAG = Flag.booleanFlag("universal");
private static final Flag<Integer> MAX_THREADS_FLAG = Flag.positiveInteger("max-threads");
Expand Down Expand Up @@ -211,10 +213,7 @@ static BuildApksCommand fromFlags(ParsedFlags flags, PrintStream out) {
.ifPresent(
maxThreads ->
buildApksCommand.setExecutorService(createInternalExecutorService(maxThreads)));
OPTIMIZE_FOR_FLAG
.getValue(flags)
.ifPresent(
values -> buildApksCommand.setOptimizationDimensions(ImmutableSet.copyOf(values)));
OPTIMIZE_FOR_FLAG.getValue(flags).ifPresent(buildApksCommand::setOptimizationDimensions);

// Signing-related arguments.
Optional<Path> keystorePath = KEYSTORE_FLAG.getValue(flags);
Expand Down Expand Up @@ -258,6 +257,7 @@ private Path executeWithTempDir(Path tempDir) {
bundleValidator.validate(appBundle);

BundleConfig bundleConfig = appBundle.getBundleConfig();
Version bundleVersion = BundleToolVersion.getVersionFromBundleConfig(bundleConfig);

ImmutableList<BundleModule> allModules =
ImmutableList.copyOf(appBundle.getModules().values());
Expand All @@ -270,7 +270,7 @@ private Path executeWithTempDir(Path tempDir) {
getGenerateOnlyUniversalApk()
? ApkOptimizations.getOptimizationsForUniversalApk()
: new OptimizationsMerger()
.mergeWithDefaults(appBundle.getBundleConfig(), getOptimizationDimensions());
.mergeWithDefaults(bundleConfig, getOptimizationDimensions());

// Generate APK variants.
ImmutableList<Variant> splitApkVariants = ImmutableList.of();
Expand All @@ -280,7 +280,8 @@ private Path executeWithTempDir(Path tempDir) {
boolean generateStandaloneApks = getGenerateOnlyUniversalApk() || targetsPreL(appBundle);

if (generateSplitApks) {
splitApkVariants = generateSplitApkVariants(allModules, apkSetBuilder, apkOptimizations);
splitApkVariants =
generateSplitApkVariants(allModules, apkSetBuilder, apkOptimizations, bundleVersion);
}
if (generateStandaloneApks) {
// Note: Universal APK is a special type of standalone, with no optimization dimensions.
Expand All @@ -293,7 +294,8 @@ private Path executeWithTempDir(Path tempDir) {
getGenerateOnlyUniversalApk(),
tempDir,
apkSetBuilder,
apkOptimizations);
apkOptimizations,
bundleVersion);
}

// Populate alternative targeting based on targeting of all variants.
Expand Down Expand Up @@ -349,12 +351,13 @@ private void validateInput() {
private ImmutableList<Variant> generateSplitApkVariants(
ImmutableList<BundleModule> modules,
ApkSetBuilder apkSetBuilder,
ApkOptimizations apkOptimizations) {
ApkOptimizations apkOptimizations,
Version bundleVersion) {
// For now we build just a single variant with hard-coded L+ targeting.
Variant.Builder variant = Variant.newBuilder().setTargeting(lPlusVariantTargeting());
for (BundleModule module : modules) {
ModuleSplitter moduleSplitter =
new ModuleSplitter(module, apkOptimizations.getSplitDimensions());
new ModuleSplitter(module, apkOptimizations.getSplitDimensions(), bundleVersion);
ImmutableList<ModuleSplit> splitApks = moduleSplitter.splitModule();

List<ApkDescription> apkDescriptions =
Expand Down Expand Up @@ -382,10 +385,11 @@ private ImmutableList<Variant> generateStandaloneApkVariants(
boolean isUniversalApk,
Path tempDir,
ApkSetBuilder apkSetBuilder,
ApkOptimizations apkOptimizations) {
ApkOptimizations apkOptimizations,
Version bundleVersion) {

ImmutableList<ModuleSplit> standaloneApks =
new BundleSharder(tempDir)
new BundleSharder(tempDir, bundleVersion)
.shardBundle(modules, apkOptimizations.getSplitDimensions(), bundleMetadata);

// Wait for all concurrent tasks to succeed, or any to fail.
Expand Down Expand Up @@ -445,7 +449,7 @@ private static VariantTargeting lPlusVariantTargeting() {
}

private static VariantTargeting standaloneApkVariantTargeting(ModuleSplit standaloneApk) {
ApkTargeting apkTargeting = standaloneApk.getTargeting();
ApkTargeting apkTargeting = standaloneApk.getApkTargeting();

VariantTargeting.Builder variantTargeting = VariantTargeting.newBuilder();
if (apkTargeting.hasAbiTargeting()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private ImmutableList<Path> extractMatchedApks(ImmutableList<Path> matchedApks)
for (Path matchedApk : matchedApks) {
ZipEntry entry = apksArchive.getEntry(matchedApk.toString());
checkNotNull(entry);
Path extractedApkPath = getOutputDirectory().resolve(matchedApk);
Path extractedApkPath = getOutputDirectory().resolve(matchedApk.getFileName());
try (InputStream inputStream = BufferedIo.inputStream(apksArchive, entry);
OutputStream outputApk = BufferedIo.outputStream(extractedApkPath)) {
ByteStreams.copy(inputStream, outputApk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.android.tools.build.bundletool.device;


import com.android.bundle.Devices.DeviceSpec;
import com.android.ddmlib.IDevice.DeviceState;
import com.android.tools.build.bundletool.exceptions.CommandExecutionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import static com.android.tools.build.bundletool.model.BundleModule.ROOT_DIRECTORY;
import static com.android.tools.build.bundletool.utils.files.FilePreconditions.checkFileDoesNotExist;
import static com.android.tools.build.bundletool.utils.files.FilePreconditions.checkFileHasExtension;
import static com.android.tools.build.bundletool.utils.files.FileUtils.createParentDirectories;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down Expand Up @@ -127,6 +128,8 @@ Path writeToZipFile(ModuleSplit split, Path outputPath) {

void writeToZipFile(ModuleSplit split, Path outputPath, Path tempDir) {
checkFileDoesNotExist(outputPath);
createParentDirectories(outputPath);

// Write a Proto-APK with only files that aapt2 requires as part of the convert command.
Path partialProtoApk = tempDir.resolve("proto.apk");
writeProtoApk(split, partialProtoApk);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
import com.android.tools.build.bundletool.model.BundleModuleName;
import com.android.tools.build.bundletool.model.ModuleSplit;
import com.android.tools.build.bundletool.model.SigningConfiguration;
import com.android.tools.build.bundletool.model.ZipPath;
import com.google.common.collect.Iterables;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Optional;

/** Serializes split APKs on disk. */
public class SplitApkSerializer {

public static final String SPLIT_APKS_SUB_DIR = "splits";

private final ApkSerializerHelper apkSerializerHelper;

public SplitApkSerializer(
Expand All @@ -46,12 +48,16 @@ public SplitApkSerializer(

public ApkDescription writeSplitToDisk(ModuleSplit split, Path outputDirectory) {
checkState(isDirectory(outputDirectory));

String apkFileName = getApkFileName(split, split.getModuleName());
apkSerializerHelper.writeToZipFile(split, outputDirectory.resolve(Paths.get(apkFileName)));
// Using ZipPath to ensure '/' path delimiter in the ApkDescription proto.
String apkFileRelPath = ZipPath.create(SPLIT_APKS_SUB_DIR).resolve(apkFileName).toString();

apkSerializerHelper.writeToZipFile(split, outputDirectory.resolve(apkFileRelPath));

return ApkDescription.newBuilder()
.setPath(apkFileName)
.setTargeting(split.getTargeting())
.setPath(apkFileRelPath)
.setTargeting(split.getApkTargeting())
.setSplitApkMetadata(
SplitApkMetadata.newBuilder()
.setSplitId(split.getAndroidManifest().get().getSplitId().orElse(""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
import com.android.tools.build.bundletool.model.Aapt2Command;
import com.android.tools.build.bundletool.model.ModuleSplit;
import com.android.tools.build.bundletool.model.SigningConfiguration;
import com.android.tools.build.bundletool.model.ZipPath;
import com.google.common.annotations.VisibleForTesting;
import java.nio.file.Path;
import java.util.Optional;

/** Serializes standalone APKs to disk. */
public class StandaloneApkSerializer {

public static final String STANDALONE_APKS_SUB_DIR = "standalones";

private final ApkSerializerHelper apkSerializerHelper;

public StandaloneApkSerializer(
Expand All @@ -42,26 +45,29 @@ public ApkDescription writeToDisk(ModuleSplit standaloneSplit, Path outputDirect
String suffix =
(standaloneSplit.getSuffix().isEmpty() ? "" : "-") + standaloneSplit.getSuffix();
String apkFileName = String.format("standalone%s.apk", suffix);
// Using ZipPath to ensure '/' path delimiter in the ApkDescription proto.
String apkFileRelPath = ZipPath.create(STANDALONE_APKS_SUB_DIR).resolve(apkFileName).toString();

return writeToDiskInternal(standaloneSplit, apkFileName, outputDirectory);
return writeToDiskInternal(standaloneSplit, outputDirectory, apkFileRelPath);
}

public ApkDescription writeToDiskAsUniversal(ModuleSplit standaloneSplit, Path outputDirectory) {
return writeToDiskInternal(standaloneSplit, "universal.apk", outputDirectory);
return writeToDiskInternal(
standaloneSplit, outputDirectory, /* apkFileRelPath= */ "universal.apk");
}

@VisibleForTesting
ApkDescription writeToDiskInternal(
ModuleSplit standaloneSplit, String apkFileName, Path outputDirectory) {
apkSerializerHelper.writeToZipFile(standaloneSplit, outputDirectory.resolve(apkFileName));
ModuleSplit standaloneSplit, Path outputDirectory, String apkFileRelPath) {
apkSerializerHelper.writeToZipFile(standaloneSplit, outputDirectory.resolve(apkFileRelPath));

return ApkDescription.newBuilder()
.setPath(apkFileName)
.setPath(apkFileRelPath)
.setStandaloneApkMetadata(
StandaloneApkMetadata.newBuilder()
.addAllFusedModuleName(
standaloneSplit.getAndroidManifest().get().getFusedModuleNames()))
.setTargeting(standaloneSplit.getTargeting())
.setTargeting(standaloneSplit.getApkTargeting())
.build();
}
}
Loading

0 comments on commit b6d7036

Please sign in to comment.