aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-10-28 10:00:53 +0000
committerGravatar Dmitry Lomov <dslomov@google.com>2015-10-28 16:04:31 +0000
commit1c2eeaca1d813bfb22a77cab640502d72abedb9f (patch)
treea71658ff543fe1b401a9c3009c2df96890be50c6 /src
parent50f29fbfa0bf4cccd3926ac3691831bb0918d3bd (diff)
Bugfix: Host fragments could not be accessed properly through Skylark.
RuleContext returned fragments for the target configuration, even when Skylark requested fragments for the host configuration. This Cl solves this bug. Since injecting a custom BuildConfiguration into out tests is surprisingly difficult, I tested this fix manually: I wrote a custom bzl file with def custom_rule_impl(ctx): print("target = {}, host = {}".format(ctx.fragments.cpp.cpu, ctx.host_fragments.cpp.cpu)) and built the rule with --cpu ppc. Output before the fix: target = ppc, host = ppc. Output after the fix: target = ppc, host = k8. -- MOS_MIGRATED_REVID=106479714
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java5
1 files changed, 3 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 9d21ec6fff..12916b3253 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
@@ -284,7 +284,7 @@ public final class RuleContext extends TargetContext
+ "in %s configuration in order to access it.%s",
rule.getRuleClass(), name, FragmentCollection.getConfigurationName(config),
additionalErrorMessage);
- return getConfiguration().getFragment(fragment);
+ return getConfiguration(config).getFragment(fragment);
}
@Nullable
@@ -295,7 +295,8 @@ public final class RuleContext extends TargetContext
@Nullable
public Fragment getSkylarkFragment(String name, ConfigurationTransition config) {
- Class<? extends Fragment> fragmentClass = getConfiguration().getSkylarkFragmentByName(name);
+ Class<? extends Fragment> fragmentClass =
+ getConfiguration(config).getSkylarkFragmentByName(name);
if (fragmentClass == null) {
return null;
}