aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2017-08-17 11:24:19 +0200
committerGravatar Irina Iancu <elenairina@google.com>2017-08-18 08:58:50 +0200
commit2b25a2a85a7b4d743eb3f38138bb350a19295077 (patch)
tree46a2276dcfef88b02deb8775248573896bd267b0 /src/main/java/com/google/devtools
parentab38960b9f34b965352d953afc00b918a97966a3 (diff)
Fetch the Java-specific Make variables from the :host_jdk dependency instead of the configuration in genrules.
This is necessary because if one uses a java_runtime rule that has java_home="$(VAR") and VAR is set to an absolute path, BuildConfiguration won't be able to resolve VAR (since it's a Make variable and thus can't affect other Make variables), Blaze won't be able to tell that it's an absolute value and thus will prepend the package name of the java_runtime rule to it, e.g. resulting in a//foo/bar instead of /foo/bar if the java_runtime rule is in package a. RELNOTES: None. PiperOrigin-RevId: 165555251
Diffstat (limited to 'src/main/java/com/google/devtools')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java7
2 files changed, 7 insertions, 4 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 2274a3dfb9..eaa634d34b 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
@@ -1086,8 +1086,8 @@ public final class RuleContext extends TargetContext
if (!attributes().has(attributeName)) {
continue;
}
- Iterables.addAll(makeVariableProviders,
- getPrerequisites(attributeName, Mode.TARGET, MakeVariableProvider.SKYLARK_CONSTRUCTOR));
+ Iterables.addAll(makeVariableProviders, getPrerequisites(
+ attributeName, Mode.DONT_CHECK, MakeVariableProvider.SKYLARK_CONSTRUCTOR));
}
LinkedHashMap<String, String> makeVariables = new LinkedHashMap<>();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java
index 7ea6743a05..e2b14a62ce 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/genrule/GenRuleBase.java
@@ -46,6 +46,7 @@ import com.google.devtools.build.lib.rules.java.JavaHelper;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.LazyString;
import com.google.devtools.build.lib.vfs.PathFragment;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@@ -354,9 +355,11 @@ public abstract class GenRuleBase implements RuleConfiguredTargetFactory {
return dir.getRelative(relPath).getPathString();
}
} else if (JDK_MAKE_VARIABLE.matcher("$(" + variableName + ")").find()) {
+ List<String> attributes = new ArrayList<>();
+ attributes.addAll(ConfigurationMakeVariableContext.DEFAULT_MAKE_VARIABLE_ATTRIBUTES);
+ attributes.add(":host_jdk");
return new ConfigurationMakeVariableContext(
- ruleContext.getMakeVariables(
- ConfigurationMakeVariableContext.DEFAULT_MAKE_VARIABLE_ATTRIBUTES),
+ ruleContext.getMakeVariables(attributes),
ruleContext.getTarget().getPackage(),
ruleContext.getHostConfiguration())
.lookupMakeVariable(variableName);