use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class Root method middlemanRoot.
// TODO(kchodorow): remove once roots don't need to know if they're in the main repo.
public static Root middlemanRoot(Path execRoot, Path outputDir, boolean isMainRepo) {
Path root = outputDir.getRelative("internal");
Preconditions.checkArgument(root.startsWith(execRoot));
Preconditions.checkArgument(!root.equals(execRoot));
return new Root(execRoot, root, true, isMainRepo);
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ArtifactFactory method getFilesetArtifact.
/**
* Returns an artifact that represents the output directory of a Fileset at the given
* root-relative path under the given root, creating it if not found. This method only works for
* normalized, relative paths.
*
* <p>The root must be below the execRootParent, and the execPath of the resulting Artifact is
* computed as {@code root.getRelative(rootRelativePath).relativeTo(root.execRoot)}.
*/
public Artifact getFilesetArtifact(PathFragment rootRelativePath, Root root, ArtifactOwner owner) {
validatePath(rootRelativePath, root);
Path path = root.getPath().getRelative(rootRelativePath);
return getArtifact(path, root, path.relativeTo(root.getExecRoot()), owner, SpecialArtifactType.FILESET);
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ArtifactFactory method getConstantMetadataArtifact.
public Artifact getConstantMetadataArtifact(PathFragment rootRelativePath, Root root, ArtifactOwner owner) {
validatePath(rootRelativePath, root);
Path path = root.getPath().getRelative(rootRelativePath);
return getArtifact(path, root, path.relativeTo(root.getExecRoot()), owner, SpecialArtifactType.CONSTANT_METADATA);
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ProfileCommand method exec.
@Override
public ExitCode exec(final CommandEnvironment env, OptionsProvider options) {
ProfileOptions opts = options.getOptions(ProfileOptions.class);
if (!opts.vfsStats) {
opts.vfsStatsLimit = 0;
}
try (PrintStream out = new PrintStream(env.getReporter().getOutErr().getOutputStream())) {
env.getReporter().handle(Event.warn(null, "This information is intended for consumption by Blaze developers" + " only, and may change at any time. Script against it at your own risk"));
if (opts.combine != null && opts.dumpMode == null) {
MultiProfileStatistics statistics = new MultiProfileStatistics(env.getWorkingDirectory(), env.getWorkspaceName(), options.getResidue(), getInfoListener(env), opts.vfsStatsLimit > 0);
Path outputFile = env.getWorkingDirectory().getRelative(opts.combine);
try (PrintStream output = new PrintStream(new BufferedOutputStream(outputFile.getOutputStream()))) {
if (opts.html) {
env.getReporter().handle(Event.info("Creating HTML output in " + outputFile));
HtmlCreator.create(output, statistics, opts.htmlDetails, opts.htmlPixelsPerSecond, opts.vfsStatsLimit);
} else {
env.getReporter().handle(Event.info("Creating text output in " + outputFile));
new PhaseText(output, statistics.getSummaryStatistics(), statistics.getSummaryPhaseStatistics(), Optional.<CriticalPathStatistics>absent(), statistics.getMissingActionsCount(), opts.vfsStatsLimit).print();
}
} catch (IOException e) {
env.getReporter().handle(Event.error("Failed to write to output file " + outputFile + ":" + e.getMessage()));
}
} else {
for (String name : options.getResidue()) {
Path profileFile = env.getWorkingDirectory().getRelative(name);
try {
ProfileInfo info = ProfileInfo.loadProfileVerbosely(profileFile, getInfoListener(env));
if (opts.dumpMode == null || !opts.dumpMode.contains("unsorted")) {
ProfileInfo.aggregateProfile(info, getInfoListener(env));
}
if (opts.taskTree != null) {
printTaskTree(out, name, info, opts.taskTree, opts.taskTreeThreshold);
continue;
}
if (opts.dumpMode != null) {
dumpProfile(info, out, opts.dumpMode);
continue;
}
PhaseSummaryStatistics phaseSummaryStatistics = new PhaseSummaryStatistics(info);
EnumMap<ProfilePhase, PhaseStatistics> phaseStatistics = new EnumMap<>(ProfilePhase.class);
for (ProfilePhase phase : ProfilePhase.values()) {
phaseStatistics.put(phase, new PhaseStatistics(phase, info, env.getWorkspaceName(), opts.vfsStatsLimit > 0));
}
CriticalPathStatistics critPathStats = new CriticalPathStatistics(info);
if (opts.html) {
Path htmlFile = profileFile.getParentDirectory().getChild(profileFile.getBaseName() + ".html");
env.getReporter().handle(Event.info("Creating HTML output in " + htmlFile));
HtmlCreator.create(info, htmlFile, phaseSummaryStatistics, phaseStatistics, critPathStats, info.getMissingActionsCount(), opts.htmlDetails, opts.htmlPixelsPerSecond, opts.vfsStatsLimit, opts.chart, opts.htmlHistograms);
} else {
new PhaseText(out, phaseSummaryStatistics, phaseStatistics, Optional.of(critPathStats), info.getMissingActionsCount(), opts.vfsStatsLimit).print();
}
} catch (IOException e) {
System.out.println(e);
env.getReporter().handle(Event.error("Failed to analyze profile file(s): " + e.getMessage()));
}
}
}
}
return ExitCode.SUCCESS;
}
use of com.google.devtools.build.lib.vfs.Path in project bazel by bazelbuild.
the class ProjectFileSupport method handleProjectFiles.
/**
* Reads any project files specified on the command line and updates the options parser
* accordingly. If project files cannot be read or if they contain unparsable options, or if they
* are not enabled, then it throws an exception instead.
*/
public static void handleProjectFiles(CommandEnvironment env, OptionsParser optionsParser, String command) throws OptionsParsingException {
BlazeRuntime runtime = env.getRuntime();
List<String> targets = optionsParser.getResidue();
ProjectFile.Provider projectFileProvider = runtime.getProjectFileProvider();
if (projectFileProvider != null && !targets.isEmpty() && targets.get(0).startsWith(PROJECT_FILE_PREFIX)) {
if (targets.size() > 1) {
throw new OptionsParsingException("Cannot handle more than one +<file> argument yet");
}
if (!optionsParser.getOptions(CommonCommandOptions.class).allowProjectFiles) {
throw new OptionsParsingException("project file support is not enabled");
}
// TODO(bazel-team): This is currently treated as a path relative to the workspace - if the
// cwd is a subdirectory of the workspace, that will be surprising, and we should interpret it
// relative to the cwd instead.
PathFragment projectFilePath = new PathFragment(targets.get(0).substring(1));
List<Path> packagePath = PathPackageLocator.create(env.getOutputBase(), optionsParser.getOptions(PackageCacheOptions.class).packagePath, env.getReporter(), env.getWorkspace(), env.getWorkingDirectory()).getPathEntries();
ProjectFile projectFile = projectFileProvider.getProjectFile(env.getWorkingDirectory(), packagePath, projectFilePath);
env.getReporter().handle(Event.info("Using " + projectFile.getName()));
optionsParser.parse(OptionPriority.RC_FILE, projectFile.getName(), projectFile.getCommandLineFor(command));
env.getEventBus().post(new GotProjectFileEvent(projectFile.getName()));
}
}
Aggregations