// 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.actions; import static com.google.common.collect.ImmutableList.toImmutableList; import static java.util.Comparator.comparing; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Functions; import com.google.common.base.Joiner; import com.google.common.base.Preconditions; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Streams; import com.google.devtools.build.lib.actions.ActionAnalysisMetadata.MiddlemanType; import com.google.devtools.build.lib.analysis.actions.CommandLineItem; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.shell.ShellUtils; import com.google.devtools.build.lib.skyframe.serialization.InjectingObjectCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; import com.google.devtools.build.lib.skylarkinterface.SkylarkPrinter; import com.google.devtools.build.lib.skylarkinterface.SkylarkValue; import com.google.devtools.build.lib.syntax.EvalUtils; import com.google.devtools.build.lib.syntax.EvalUtils.ComparisonException; import com.google.devtools.build.lib.util.FileType; import com.google.devtools.build.lib.util.FileTypeSet; import com.google.devtools.build.lib.vfs.FileSystemProvider; import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; import java.util.List; import java.util.Objects; import javax.annotation.Nullable; /** * An Artifact represents a file used by the build system, whether it's a source file or a derived * (output) file. Not all Artifacts have a corresponding FileTarget object in the * build.lib.packages API: for example, low-level intermediaries internal to a given rule, * such as a Java class files or C++ object files. However all FileTargets have a corresponding * Artifact. * *

In any given call to SkyframeExecutor#buildArtifacts(), no two Artifacts in the action graph * may refer to the same path. * *

Artifacts generally fall into two classifications, source and derived, but there exist a few * other cases that are fuzzy and difficult to classify. The following cases exist: * *

* * In the usual case, an Artifact represents a single file. However, an Artifact may also represent * the following: * * * *

This class is "theoretically" final; it should not be subclassed except by {@link * SpecialArtifact}. */ @Immutable @SkylarkModule( name = "File", category = SkylarkModuleCategory.BUILTIN, doc = "

This type represents a file or directory used by the build system. It can be " + "either a source file or a derived file produced by a rule.

" + "

The File constructor is private, so you cannot call it directly to create new " + "Files. If you have a Skylark rule that needs to create a new File, " + "you have two options:" + "