aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
index 5d8ecfb4f2..8930883dd8 100644
--- a/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
+++ b/src/tools/android/java/com/google/devtools/build/android/aapt2/ResourceLinker.java
@@ -532,6 +532,34 @@ public class ResourceLinker {
}
}
+ /** Link a proto apk to produce an apk. */
+ public Path link(ProtoApk protoApk) {
+ try {
+ final Path protoApkPath = protoApk.asApkPath();
+ final Path working =
+ workingDirectory
+ .resolve("link-proto")
+ .resolve(replaceExtension(protoApkPath.getFileName().toString(), "working"));
+ final Path manifest = protoApk.writeManifestAsXmlTo(working);
+ final Path apk = working.resolve("binary.apk");
+ logger.fine(
+ new AaptCommandBuilder(aapt2)
+ .forBuildToolsVersion(buildToolsVersion)
+ .forVariantType(VariantType.DEFAULT)
+ .add("link")
+ .when(Objects.equals(logger.getLevel(), Level.FINE))
+ .thenAdd("-v")
+ .add("--manifest", manifest)
+ .addRepeated("-I", StaticLibrary.toPathStrings(linkAgainst))
+ .add("-R", convertToBinary(protoApkPath))
+ .add("-o", apk.toString())
+ .execute(String.format("Re-linking %s", protoApkPath)));
+ return apk;
+ } catch (IOException e) {
+ throw new LinkError(e);
+ }
+ }
+
public ResourceLinker storeUncompressed(List<String> uncompressedExtensions) {
this.uncompressedExtensions = uncompressedExtensions;
return this;