aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar corysmith <corysmith@google.com>2018-08-06 10:49:47 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-06 10:51:55 -0700
commitb853e930228e4e8039c8df2bfac1e55de00230b0 (patch)
tree931c8c6edc98fe5a5ab38cd39fa369b05a14b615
parente140ab6cef2f79d992ab6695e8dfcd5675ff6e47 (diff)
Added functionality to let the ResourceLinker link ProtoApks.
RELNOTES: None PiperOrigin-RevId: 207570745
-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;