use of com.google.devtools.build.lib.analysis.FilesToRunProvider in project bazel by bazelbuild.
the class RunCommand method ensureRunfilesBuilt.
/**
* Ensures that runfiles are built for the specified target. If they already
* are, does nothing, otherwise builds them.
*
* @param target the target to build runfiles for.
* @return the path of the runfiles directory.
* @throws CommandException
*/
private Path ensureRunfilesBuilt(CommandEnvironment env, ConfiguredTarget target) throws CommandException {
FilesToRunProvider provider = target.getProvider(FilesToRunProvider.class);
RunfilesSupport runfilesSupport = provider == null ? null : provider.getRunfilesSupport();
if (runfilesSupport == null) {
return env.getWorkingDirectory();
}
Artifact manifest = runfilesSupport.getRunfilesManifest();
PathFragment runfilesDir = runfilesSupport.getRunfilesDirectoryExecPath();
Path workingDir = env.getExecRoot().getRelative(runfilesDir);
// Workspace name directory doesn't exist, so don't add it.
if (target.getConfiguration().runfilesEnabled()) {
workingDir = workingDir.getRelative(runfilesSupport.getRunfiles().getSuffix());
}
// a handy way to check whether runfiles were built or not.
if (!RUNFILES_MANIFEST.matches(manifest.getFilename())) {
// Runfiles already built, nothing to do.
return workingDir;
}
SymlinkTreeHelper helper = new SymlinkTreeHelper(manifest.getPath(), runfilesSupport.getRunfilesDirectory(), false);
helper.createSymlinksUsingCommand(env.getExecRoot(), target.getConfiguration(), env.getBlazeWorkspace().getBinTools());
return workingDir;
}
use of com.google.devtools.build.lib.analysis.FilesToRunProvider in project bazel by bazelbuild.
the class PopulateTreeArtifactActionTest method testComputeKey.
@Test
public void testComputeKey() throws Exception {
final Artifact archiveA = getSourceArtifact("myArchiveA.zip");
final Artifact archiveB = getSourceArtifact("myArchiveB.zip");
final Artifact treeArtifactToPopulateA = createTreeArtifact("testA/archive_member");
final Artifact treeArtifactToPopulateB = createTreeArtifact("testB/archive_member");
final Artifact archiveManifestA = getSourceArtifact("archiveManifestA.txt");
final Artifact archiveManifestB = getSourceArtifact("archiveManifestB.txt");
final FilesToRunProvider zipperA = FilesToRunProvider.fromSingleExecutableArtifact(getSourceArtifact("unzipBinaryA"));
final FilesToRunProvider zipperB = FilesToRunProvider.fromSingleExecutableArtifact(getSourceArtifact("unzipBinaryB"));
ActionTester.runTest(16, new ActionCombinationFactory() {
@Override
public Action generate(int i) {
Artifact archive = (i & 1) == 0 ? archiveA : archiveB;
Artifact treeArtifactToPopulate = (i & 2) == 0 ? treeArtifactToPopulateA : treeArtifactToPopulateB;
Artifact archiveManifest = (i & 4) == 0 ? archiveManifestA : archiveManifestB;
FilesToRunProvider zipper = (i & 8) == 0 ? zipperA : zipperB;
return new PopulateTreeArtifactAction(ActionsTestUtil.NULL_ACTION_OWNER, archive, archiveManifest, treeArtifactToPopulate, zipper);
}
});
}
Aggregations