Skip to content

Commit

Permalink
Add Make variables to java_runtime and java_runtime_suite .
Browse files Browse the repository at this point in the history
This is necessary so that Make variables are not accessed from BuildConfiguration, which is in turn necessary so that we can forego package loading during configuration creation (currently we need to parse the java_runtime_suite / java_runtime rules to create the Jvm fragment)

RELNOTES: None.
PiperOrigin-RevId: 161496779
  • Loading branch information
lberki authored and laszlocsomor committed Jul 11, 2017
1 parent 5ed49b0 commit 76a251b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.rules.java;

import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.actions.Actions;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.CompilationHelper;
Expand All @@ -27,6 +28,7 @@
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.rules.MakeVariableProvider;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;
import com.google.devtools.build.lib.syntax.Type;
import com.google.devtools.build.lib.util.OsUtils;
Expand Down Expand Up @@ -70,12 +72,19 @@ public ConfiguredTarget create(RuleContext ruleContext)
new Runfiles.Builder(ruleContext.getWorkspaceName())
.addTransitiveArtifacts(filesToBuild)
.build();

MakeVariableProvider makeVariableProvider = new MakeVariableProvider(ImmutableMap.of(
"JAVA", javaBinaryExecPath.getPathString(),
"JAVABASE", javaHome.getPathString()));

return new RuleConfiguredTargetBuilder(ruleContext)
.addProvider(RunfilesProvider.class, RunfilesProvider.simple(runfiles))
.setFilesToBuild(filesToBuild)
.addProvider(JavaRuntimeProvider.class, JavaRuntimeProvider.create(
filesToBuild, javaHome, javaBinaryExecPath, javaBinaryRunfilesPath))
.addProvider(MiddlemanProvider.class, new MiddlemanProvider(middleman))
.addProvider(makeVariableProvider)
.addNativeDeclaredProvider(makeVariableProvider)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.RunfilesProvider;
import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.rules.MakeVariableProvider;
import com.google.devtools.build.lib.rules.RuleConfiguredTargetFactory;

/** Implementation for the {@code java_runtime_suite} rule. */
Expand All @@ -38,10 +39,14 @@ public ConfiguredTarget create(RuleContext ruleContext)
ruleContext.throwWithRuleError(
"could not resolve runtime for cpu " + ruleContext.getConfiguration().getCpu());
}

MakeVariableProvider makeVariableProvider = runtime.getProvider(MakeVariableProvider.class);
return new RuleConfiguredTargetBuilder(ruleContext)
.addProvider(JavaRuntimeProvider.class, runtime.getProvider(JavaRuntimeProvider.class))
.addProvider(RunfilesProvider.class, runtime.getProvider(RunfilesProvider.class))
.addProvider(MiddlemanProvider.class, runtime.getProvider(MiddlemanProvider.class))
.addProvider(makeVariableProvider)
.addNativeDeclaredProvider(makeVariableProvider)
.setFilesToBuild(runtime.getProvider(FileProvider.class).getFilesToBuild())
.build();
}
Expand Down

0 comments on commit 76a251b

Please sign in to comment.