// Copyright 2014 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package com.google.devtools.build.lib.analysis; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.actions.AbstractAction; import com.google.devtools.build.lib.actions.ActionContext; import com.google.devtools.build.lib.actions.ActionOwner; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.actions.ArtifactFactory; import com.google.devtools.build.lib.actions.ArtifactOwner; import com.google.devtools.build.lib.util.OptionsUtils; import com.google.devtools.build.lib.vfs.FileSystemUtils; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import com.google.devtools.common.options.Option; import com.google.devtools.common.options.OptionDocumentationCategory; import com.google.devtools.common.options.OptionEffectTag; import com.google.devtools.common.options.OptionsBase; import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; /** * An action writing the workspace status files. * *
These files represent information about the environment the build was run in. They are used * by language-specific build info factories to make the data in them available for individual * languages (e.g. by turning them into .h files for C++) * *
The format of these files a list of key-value pairs, one for each line. The key and the value * are separated by a space. * *
There are two of these files: volatile and stable. Changes in the volatile file do not
* cause rebuilds if no other file is changed. This is useful for frequently-changing information
* that does not significantly affect the build, e.g. the current time.
*/
public abstract class WorkspaceStatusAction extends AbstractAction {
/** Options controlling the workspace status command. */
public static class Options extends OptionsBase {
@Option(
name = "embed_label",
defaultValue = "",
valueHelp = " The output is a text file with each line representing a workspace status info key.
* The key is the part of the line before the first space and should consist of the characters
* [A-Z_] (although this is not checked). Everything after the first space is the value.
*/
public static Map The action will have a supplier inside it allowing it to access data that may change on
* every build. Since the action is unconditionally executed on each build, we don't recreate
* the action on every build, just re-executing and letting it read the updated data each time.
*/
WorkspaceStatusAction createWorkspaceStatusAction(
ArtifactFactory artifactFactory, ArtifactOwner artifactOwner, String workspaceName);
/**
* Creates a dummy workspace status map. Used in cases where the build failed, so that part of
* the workspace status is nevertheless available.
*/
Map