diff options
Diffstat (limited to 'src/main/java/com/google')
3 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java index bddb2c2bb5..0f07e39036 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java @@ -467,6 +467,18 @@ public final class RuleContext extends TargetContext } /** + * Returns an artifact that can be an output of shared actions. Only use when there is no other + * option. + * + * <p>This artifact can be created anywhere in the output tree, which, in addition to making + * sharing possible, opens up the possibility of action conflicts and makes it impossible to + * infer the label of the rule creating the artifact from the path of the artifact. + */ + public Artifact getShareableArtifact(PathFragment rootRelativePath, Root root) { + return getAnalysisEnvironment().getDerivedArtifact(rootRelativePath, root); + } + + /** * Creates an artifact in a directory that is unique to the package that contains the rule, * thus guaranteeing that it never clashes with artifacts created by rules in other packages. */ diff --git a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java index 8c22344955..e808eb538b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java +++ b/src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java @@ -153,7 +153,7 @@ public abstract class NativeDepsHelper { linkopts, linkstamps.keySet(), buildInfoArtifacts, ruleContext.getFeatures()) : nativeDepsPath; - Artifact sharedLibrary = ruleContext.getAnalysisEnvironment().getDerivedArtifact( + Artifact sharedLibrary = ruleContext.getShareableArtifact( linkerOutputPath, configuration.getBinDirectory()); CppLinkAction.Builder builder = new CppLinkAction.Builder( ruleContext, sharedLibrary, configuration, toolchain); diff --git a/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java b/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java index c663b263db..1dde89346e 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java +++ b/src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java @@ -83,7 +83,7 @@ public final class PythonUtils { private static Artifact get2to3OutputArtifact(RuleContext ruleContext, Artifact input) { Root root = ruleContext.getConfiguration().getGenfilesDirectory(); PathFragment path = new PathFragment("python3").getRelative(input.getRootRelativePath()); - return ruleContext.getAnalysisEnvironment().getDerivedArtifact(path, root); + return ruleContext.getShareableArtifact(path, root); } /** |