diff options
author | 2017-07-10 14:28:56 +0200 | |
---|---|---|
committer | 2017-07-10 14:37:49 +0200 | |
commit | d579b6eafd1d41a73c0dfce7b9ffcfdf1d607a97 (patch) | |
tree | 05416632d6f9d9ede24355087a15b591d1d15929 /src/main/java/com/google/devtools/build/lib | |
parent | 30fd4566557f016e8c2fa1629196bbd724cde576 (diff) |
Make jvm_runtime.java_home expand Make variables.
RELNOTES: None.
PiperOrigin-RevId: 161383469
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
3 files changed, 14 insertions, 7 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 b3d8940598..d2999d3098 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 @@ -1108,11 +1108,12 @@ public final class RuleContext extends TargetContext } /** - * Return a context that maps Make variable names (string) to values (string). + * Expands the make variables in {@code expression}. * - * <p>Uses {@NoopExpansionInterceptor}. - * - * @return a ConfigurationMakeVariableContext. + * @param attributeName the name of the attribute from which "expression" comes; used for error + * reporting. + * @param expression the string to expand. + * @return the expanded string. */ public String expandMakeVariables(String attributeName, String expression) { return expandMakeVariables(attributeName, expression, ImmutableList.<MakeVariableSupplier>of()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java index 0d15e60e9f..37fbab51da 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntime.java @@ -45,10 +45,13 @@ public class JavaRuntime implements RuleConfiguredTargetFactory { PrerequisiteArtifacts.nestedSet(ruleContext, "srcs", Mode.TARGET); PathFragment javaHome = defaultJavaHome(ruleContext.getLabel()); if (ruleContext.attributes().isAttributeValueExplicitlySpecified("java_home")) { - PathFragment javaHomeAttribute = PathFragment.create( - ruleContext.attributes().get("java_home", Type.STRING)); + PathFragment javaHomeAttribute = PathFragment.create(ruleContext.expandMakeVariables( + "java_home", ruleContext.attributes().get("java_home", Type.STRING))); if (!filesToBuild.isEmpty() && javaHomeAttribute.isAbsolute()) { ruleContext.ruleError("'java_home' with an absolute path requires 'srcs' to be empty."); + } + + if (ruleContext.hasErrors()) { return null; } diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntimeRule.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntimeRule.java index ef526863f8..9d4ae426cf 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntimeRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaRuntimeRule.java @@ -36,7 +36,10 @@ public final class JavaRuntimeRule implements RuleDefinition { <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("srcs", LABEL_LIST).allowedFileTypes(FileTypeSet.ANY_FILE).mandatory()) /* <!-- #BLAZE_RULE(java_runtime).ATTRIBUTE(java_home) --> - The relative path to the root of the runtime. + The path to the root of the runtime. + Subject to <a href="${link make-variables}">"Make" variable</a> substitution. + If this path is absolute, the rule denotes a non-hermetic Java runtime with a well-known + path. In that case, the <code>srcs</code> attribute must be empty. <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ .add(attr("java_home", STRING)) .add(attr("output_licenses", LICENSE)) |