Search in sources :

Example 1 with ApkManifest

use of com.google.devtools.build.lib.rules.android.apkmanifest.ApkManifestOuterClass.ApkManifest in project bazel by bazelbuild.

the class ApkManifestAction method newDeterministicWriter.

@Override
public DeterministicWriter newDeterministicWriter(final ActionExecutionContext ctx) throws IOException {
    ApkManifestCreator manifestCreator = new ApkManifestCreator(new ArtifactDigester() {

        @Override
        public byte[] getDigest(Artifact artifact) throws IOException {
            return ctx.getMetadataHandler().getMetadata(artifact).digest;
        }
    });
    final ApkManifest manifest = manifestCreator.createManifest();
    return new DeterministicWriter() {

        @Override
        public void writeOutputFile(OutputStream out) throws IOException {
            if (textOutput) {
                TextFormat.print(manifest, new PrintStream(out));
            } else {
                manifest.writeTo(out);
            }
        }
    };
}
Also used : PrintStream(java.io.PrintStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) ApkManifest(com.google.devtools.build.lib.rules.android.apkmanifest.ApkManifestOuterClass.ApkManifest) Artifact(com.google.devtools.build.lib.actions.Artifact)

Example 2 with ApkManifest

use of com.google.devtools.build.lib.rules.android.apkmanifest.ApkManifestOuterClass.ApkManifest in project bazel by bazelbuild.

the class ApkManifestAction method computeKey.

@Override
protected String computeKey() {
    // Use fake hashes for the purposes of the action's key, because the hashes are retrieved from
    // the MetadataHandler, which is available at only action-execution time. This should be ok
    // because if an input artifact changes (and hence its hash changes), the action should be rerun
    // anyway. This is more for the purpose of putting the structure of the output data into the
    // key.
    ApkManifestCreator manifestCreator = new ApkManifestCreator(new ArtifactDigester() {

        @Override
        public byte[] getDigest(Artifact artifact) {
            return Ints.toByteArray(artifact.getExecPathString().hashCode());
        }
    });
    ApkManifest manifest;
    try {
        manifest = manifestCreator.createManifest();
    } catch (IOException e) {
        // ArtifactDigester that uses the MetadataHandler.
        throw new IllegalStateException(e);
    }
    return new Fingerprint().addString(GUID).addBoolean(textOutput).addBytes(manifest.toByteArray()).hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint) ApkManifest(com.google.devtools.build.lib.rules.android.apkmanifest.ApkManifestOuterClass.ApkManifest) IOException(java.io.IOException) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

Artifact (com.google.devtools.build.lib.actions.Artifact)2 ApkManifest (com.google.devtools.build.lib.rules.android.apkmanifest.ApkManifestOuterClass.ApkManifest)2 IOException (java.io.IOException)2 Fingerprint (com.google.devtools.build.lib.util.Fingerprint)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1