Search in sources :

Example 1 with SourceManifestAction

use of com.google.devtools.build.lib.analysis.SourceManifestAction in project bazel by bazelbuild.

the class BuildViewTestCase method getSymlinkTreeManifest.

protected Map<String, String> getSymlinkTreeManifest(Artifact outputManifest) throws Exception {
    SymlinkTreeAction symlinkTreeAction = (SymlinkTreeAction) getGeneratingAction(outputManifest);
    Artifact inputManifest = Iterables.getOnlyElement(symlinkTreeAction.getInputs());
    SourceManifestAction inputManifestAction = (SourceManifestAction) getGeneratingAction(inputManifest);
    // Ask the manifest to write itself to a byte array so that we can
    // read its contents.
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    inputManifestAction.writeOutputFile(stream, reporter);
    String contents = stream.toString();
    // Get the file names from the manifest output.
    ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
    for (String line : Splitter.on('\n').split(contents)) {
        int space = line.indexOf(' ');
        if (space < 0) {
            continue;
        }
        result.put(line.substring(0, space), line.substring(space + 1));
    }
    return result.build();
}
Also used : SourceManifestAction(com.google.devtools.build.lib.analysis.SourceManifestAction) SymlinkTreeAction(com.google.devtools.build.lib.analysis.actions.SymlinkTreeAction) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Artifact(com.google.devtools.build.lib.actions.Artifact) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with SourceManifestAction

use of com.google.devtools.build.lib.analysis.SourceManifestAction in project bazel by bazelbuild.

the class NativeLibs method createApkBuilderSymlinks.

public Pair<Artifact, Runfiles> createApkBuilderSymlinks(RuleContext ruleContext) {
    Map<PathFragment, Artifact> symlinks = new LinkedHashMap<>();
    for (Map.Entry<String, Iterable<Artifact>> entry : nativeLibs.entrySet()) {
        String arch = entry.getKey();
        for (Artifact lib : entry.getValue()) {
            symlinks.put(new PathFragment(arch + "/" + lib.getExecPath().getBaseName()), lib);
        }
    }
    if (symlinks.isEmpty()) {
        return null;
    }
    Artifact inputManifest = AndroidBinary.getDxArtifact(ruleContext, "native_symlinks.manifest");
    SourceManifestAction sourceManifestAction = new SourceManifestAction.Builder(ruleContext.getWorkspaceName(), ManifestType.SOURCE_SYMLINKS, ruleContext.getActionOwner(), inputManifest, ruleContext.getConfiguration().legacyExternalRunfiles()).addRootSymlinks(symlinks).build();
    ruleContext.registerAction(sourceManifestAction);
    Artifact outputManifest = AndroidBinary.getDxArtifact(ruleContext, "native_symlinks/MANIFEST");
    Artifact nativeLibsMiddleman = ruleContext.getAnalysisEnvironment().getMiddlemanFactory().createRunfilesMiddleman(ruleContext.getActionOwner(), null, symlinks.values(), ruleContext.getConfiguration().getMiddlemanDirectory(ruleContext.getRule().getRepository()), "android_native_libs");
    ruleContext.registerAction(new SymlinkTreeAction(ruleContext.getActionOwner(), inputManifest, nativeLibsMiddleman, outputManifest, false, ruleContext.getConfiguration().getLocalShellEnvironment(), ruleContext.getConfiguration().runfilesEnabled()));
    return Pair.of(outputManifest, sourceManifestAction.getGeneratedRunfiles());
}
Also used : SourceManifestAction(com.google.devtools.build.lib.analysis.SourceManifestAction) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) SymlinkTreeAction(com.google.devtools.build.lib.analysis.actions.SymlinkTreeAction) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Artifact(com.google.devtools.build.lib.actions.Artifact) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)2 Artifact (com.google.devtools.build.lib.actions.Artifact)2 SourceManifestAction (com.google.devtools.build.lib.analysis.SourceManifestAction)2 SymlinkTreeAction (com.google.devtools.build.lib.analysis.actions.SymlinkTreeAction)2 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1