Skip to content

Commit

Permalink
Automated g4 rollback of commit 34fe247.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Rolling forward after fixing issues in http://b/38171368

*** Original change description ***

Automated g4 rollback of commit 006a804.

*** Reason for rollback ***

Need to roll this back as part of http://b/38171368

*** Original change description ***

Make the cc_toolchain libc_top use the target configuration

The removes redundancy from the logic around calculating the sysroot (and was been a TODO since 2014!)

RELNOTES: None
PiperOrigin-RevId: 155787049
  • Loading branch information
Googler authored and kchodorow committed May 12, 2017
1 parent 1a57d29 commit f1631c2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public static PathFragment getManifestPathFromFilesetPath(PathFragment filesetDi
}

/**
* Returns the middleman artifact on the specified attribute of the specified rule, or an empty
* set if it does not exist.
* Returns the middleman artifact on the specified attribute of the specified rule for the
* specified mode, or an empty set if it does not exist.
*/
public static NestedSet<Artifact> getMiddlemanFor(RuleContext rule, String attribute) {
TransitiveInfoCollection prereq = rule.getPrerequisite(attribute, Mode.HOST);
public static NestedSet<Artifact> getMiddlemanFor(RuleContext rule, String attribute, Mode mode) {
TransitiveInfoCollection prereq = rule.getPrerequisite(attribute, mode);
if (prereq == null) {
return NestedSetBuilder.emptySet(Order.STABLE_ORDER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ public Artifact newDirectory(String name, Object siblingArtifactUnchecked) throw
@SkylarkCallable(documented = false)
public NestedSet<Artifact> middleMan(String attribute) throws EvalException {
checkMutable("middle_man");
return AnalysisUtils.getMiddlemanFor(ruleContext, attribute);
return AnalysisUtils.getMiddlemanFor(ruleContext, attribute, Mode.HOST);
}

@SkylarkCallable(documented = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.AnalysisUtils;
import com.google.devtools.build.lib.analysis.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
Expand Down Expand Up @@ -110,7 +111,7 @@ protected NestedSet<Artifact> fullInputsForLink(
RuleContext ruleContext, NestedSet<Artifact> link) {
return NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(link)
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top"))
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top", Mode.TARGET))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private ImmutableList<Artifact> getBuiltinIncludes(RuleContext ruleContext) {
}

private NestedSet<Artifact> inputsForLibc(RuleContext ruleContext) {
TransitiveInfoCollection libc = ruleContext.getPrerequisite(":libc_top", Mode.HOST);
TransitiveInfoCollection libc = ruleContext.getPrerequisite(":libc_top", Mode.TARGET);
return libc != null
? libc.getProvider(FileProvider.class).getFilesToBuild()
: NestedSetBuilder.<Artifact>emptySet(Order.STABLE_ORDER);
Expand All @@ -395,7 +395,7 @@ private NestedSet<Artifact> fullInputsForCrosstool(RuleContext ruleContext,
NestedSet<Artifact> crosstoolMiddleman) {
return NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(crosstoolMiddleman)
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top"))
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top", Mode.TARGET))
.build();
}

Expand All @@ -407,7 +407,7 @@ protected NestedSet<Artifact> fullInputsForLink(
RuleContext ruleContext, NestedSet<Artifact> link) {
return NestedSetBuilder.<Artifact>stableOrder()
.addTransitive(link)
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top"))
.addTransitive(AnalysisUtils.getMiddlemanFor(ruleContext, ":libc_top", Mode.TARGET))
.add(ruleContext.getPrerequisiteArtifact("$interface_library_builder", Mode.HOST))
.add(ruleContext.getPrerequisiteArtifact("$link_dynamic_library_tool", Mode.HOST))
.build();
Expand Down Expand Up @@ -493,7 +493,7 @@ protected ImmutableMap<String, String> getEnvironment(RuleContext ruleContext) {

private PathFragment calculateSysroot(RuleContext ruleContext) {

TransitiveInfoCollection sysrootTarget = ruleContext.getPrerequisite(":sysroot", Mode.TARGET);
TransitiveInfoCollection sysrootTarget = ruleContext.getPrerequisite(":libc_top", Mode.TARGET);
if (sysrootTarget == null) {
CppConfiguration cppConfiguration =
Preconditions.checkNotNull(ruleContext.getFragment(CppConfiguration.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public RuleClass build(Builder builder, RuleDefinitionEnvironment env) {
.cfg(HOST)
.singleArtifact()
.value(env.getToolsLabel("//tools/cpp:link_dynamic_library")))
// TODO(bazel-team): Should be using the TARGET configuration.
.add(attr(":libc_top", LABEL).cfg(HOST).value(LIBC_TOP))
.add(attr(":sysroot", LABEL).value(LIBC_TOP))
.add(attr(":libc_top", LABEL).value(LIBC_TOP))
.add(
attr(":lipo_context_collector", LABEL)
.cfg(LipoTransition.LIPO_COLLECTOR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ public static NestedSet<Artifact> getHostJavabaseInputs(RuleContext ruleContext)
/** Returns the artifacts required to invoke {@code javahome} relative binary in the action. */
public static NestedSet<Artifact> getHostJavabaseInputs(
RuleContext ruleContext, String implicitAttributesSuffix) {
return AnalysisUtils.getMiddlemanFor(ruleContext, ":host_jdk" + implicitAttributesSuffix);
return AnalysisUtils.getMiddlemanFor(
ruleContext, ":host_jdk" + implicitAttributesSuffix, Mode.HOST);
}

/**
Expand Down

0 comments on commit f1631c2

Please sign in to comment.