aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-08-20 13:31:24 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-08-20 14:50:31 +0000
commit21a04f2fe2364fcae13d3e7783c5b390438a05f6 (patch)
tree4eb23b2f1679b345ce41017e3685c5e167912b20 /src/main/java/com/google/devtools/build/lib
parentb24b1c491456980d2cd7e505204be1816d83bbea (diff)
Replace AnalysisEnvironment.getDerivedArtifact() calls with RuleContext.getShareableArtifact() calls where the former method is used to create the outputs of shared actions.
-- MOS_MIGRATED_REVID=101116694
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java12
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/nativedeps/NativeDepsHelper.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/python/PythonUtils.java2
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);
}
/**