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();
}
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());
}
Aggregations