diff options
author | cparsons <cparsons@google.com> | 2017-10-11 00:14:19 +0200 |
---|---|---|
committer | Marcel Hlopko <hlopko@google.com> | 2017-10-11 10:57:39 +0200 |
commit | 78927792c77a6468607e215034c22b0641553f77 (patch) | |
tree | 697c57e08b9c705ac26ab322b0ffdce82fd0e162 /src/main/java/com/google/devtools/build | |
parent | a3868a40224ac639bd37fe7c874772cf72f6451a (diff) |
Refactor ConfiguredAttributeMapper to lib/packages from lib/analysis.
This requires moving the convenience constructor using RuleConfiguredTarget to be owned by RuleConfiguredTarget.
This refactoring is required by later work to allow SplitTransitionProvider to use configurable attributes. This would require packages/Attribute.java -> analysis/ConfiguredAttributeMapper.java, where in general, the 'analysis' package depends on the 'packages' package. This is the easiest way to prevent a circular dependency.
RELNOTES: None.
PiperOrigin-RevId: 171741620
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/BUILD | 12 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java | 1 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java | 1 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/RuleConfiguredTarget.java | 8 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/packages/ConfiguredAttributeMapper.java (renamed from src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java) | 15 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java | 3 |
8 files changed, 26 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index fdab0c01cc..9898d6fa69 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -329,6 +329,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/cmdline", ], deps = [ + "//src/main/java/com/google/devtools/build/lib:config-matching-provider", "//src/main/java/com/google/devtools/build/lib:events", "//src/main/java/com/google/devtools/build/lib:skylarkinterface", "//src/main/java/com/google/devtools/build/lib:syntax", @@ -383,6 +384,17 @@ java_library( ) java_library( + name = "config-matching-provider", + srcs = ["analysis/config/ConfigMatchingProvider.java"], + deps = [ + ":transitive-info-provider", + "//src/main/java/com/google/devtools/build/lib/cmdline", + "//src/main/java/com/google/devtools/build/lib/concurrent", + "//third_party:guava", + ], +) + +java_library( name = "skylark-provider-collection", srcs = ["analysis/SkylarkProviderCollection.java"], deps = [ diff --git a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java index 41323b6892..33c7531f4c 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/DependencyResolver.java @@ -37,6 +37,7 @@ import com.google.devtools.build.lib.packages.Attribute; import com.google.devtools.build.lib.packages.Attribute.LateBoundDefault; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.BuildType; +import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper; import com.google.devtools.build.lib.packages.EnvironmentGroup; import com.google.devtools.build.lib.packages.InputFile; import com.google.devtools.build.lib.packages.NoSuchThingException; 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 e17f74a21a..55e1f20879 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 @@ -63,6 +63,7 @@ import com.google.devtools.build.lib.packages.Attribute.SplitTransition; import com.google.devtools.build.lib.packages.AttributeMap; import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.ConfigurationFragmentPolicy; +import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper; import com.google.devtools.build.lib.packages.FileTarget; import com.google.devtools.build.lib.packages.FilesetEntry; import com.google.devtools.build.lib.packages.ImplicitOutputsFunction; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java index 5b6b267b15..64c27a28d2 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/TargetCompleteEvent.java @@ -245,7 +245,7 @@ public final class TargetCompleteEvent if (!(target instanceof RuleConfiguredTarget)) { return ImmutableList.<String>of(); } - AttributeMap attributes = ConfiguredAttributeMapper.of((RuleConfiguredTarget) target); + AttributeMap attributes = ((RuleConfiguredTarget) target).getAttributeMapper(); // Every rule (implicitly) has a "tags" attribute. return attributes.get("tags", Type.STRING_LIST); } diff --git a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/RuleConfiguredTarget.java b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/RuleConfiguredTarget.java index 5079d96ae0..4810512d9a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/RuleConfiguredTarget.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/configuredtargets/RuleConfiguredTarget.java @@ -27,6 +27,7 @@ import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; import com.google.devtools.build.lib.analysis.config.RunUnder; import com.google.devtools.build.lib.analysis.skylark.SkylarkApiProvider; import com.google.devtools.build.lib.cmdline.Label; +import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper; import com.google.devtools.build.lib.packages.Info; import com.google.devtools.build.lib.packages.OutputFile; import com.google.devtools.build.lib.packages.Provider; @@ -151,4 +152,11 @@ public final class RuleConfiguredTarget extends AbstractConfiguredTarget { public void repr(SkylarkPrinter printer) { printer.append("<target " + getLabel() + ">"); } + + /** + * Returns a {@link ConfiguredAttributeMapper} containing values of this target's attributes. + */ + public ConfiguredAttributeMapper getAttributeMapper() { + return ConfiguredAttributeMapper.of(getTarget(), getConfigConditions()); + } } diff --git a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java index 256cf93e6b..a2350703a9 100644 --- a/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/AggregatingAttributeMapper.java @@ -278,7 +278,7 @@ public class AggregatingAttributeMapper extends AbstractAttributeMapper { * This is because the selects have the same conditions, so whatever matches the first also * matches the second. Note that this doesn't work for selects with overlapping but * <i>different</i> key sets. That's because of key specialization (see - * {@link com.google.devtools.build.lib.analysis.ConfiguredAttributeMapper} - if the + * {@link ConfiguredAttributeMapper} - if the * second select also included a condition <code>':c'</code> that includes both the flags * in <code>':a'</code> and <code>':b'</code>, <code>':c'</code> would be chosen over * them both. diff --git a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java b/src/main/java/com/google/devtools/build/lib/packages/ConfiguredAttributeMapper.java index a1da224a6d..d57170fe3d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/ConfiguredAttributeMapper.java +++ b/src/main/java/com/google/devtools/build/lib/packages/ConfiguredAttributeMapper.java @@ -11,7 +11,7 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -package com.google.devtools.build.lib.analysis; +package com.google.devtools.build.lib.packages; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Joiner; @@ -20,15 +20,9 @@ import com.google.common.base.Verify; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider; -import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget; import com.google.devtools.build.lib.cmdline.Label; -import com.google.devtools.build.lib.packages.AbstractAttributeMapper; -import com.google.devtools.build.lib.packages.Attribute; -import com.google.devtools.build.lib.packages.AttributeMap; -import com.google.devtools.build.lib.packages.BuildType; import com.google.devtools.build.lib.packages.BuildType.Selector; import com.google.devtools.build.lib.packages.BuildType.SelectorList; -import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.syntax.EvalException; import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.Preconditions; @@ -71,13 +65,6 @@ public class ConfiguredAttributeMapper extends AbstractAttributeMapper { } /** - * "Do-it-all" constructor that just needs a {@link RuleConfiguredTarget}. - */ - public static ConfiguredAttributeMapper of(RuleConfiguredTarget ct) { - return new ConfiguredAttributeMapper(ct.getTarget(), ct.getConfigConditions()); - } - - /** * "Manual" constructor that requires the caller to pass the set of configurability conditions * that trigger this rule's configurable attributes. * diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java index 2446152193..f9bbde4062 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/PrintActionCommand.java @@ -24,7 +24,6 @@ import com.google.devtools.build.lib.actions.CommandLineExpansionException; import com.google.devtools.build.lib.actions.extra.DetailedExtraActionInfo; import com.google.devtools.build.lib.actions.extra.ExtraActionSummary; import com.google.devtools.build.lib.analysis.BuildView; -import com.google.devtools.build.lib.analysis.ConfiguredAttributeMapper; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.OutputGroupProvider; @@ -349,7 +348,7 @@ public final class PrintActionCommand implements BlazeCommand { if (!ruleConfiguredTarget.getTarget().isAttrDefined("hdrs", BuildType.LABEL_LIST)) { return false; } - List<Label> hdrs = ConfiguredAttributeMapper.of(ruleConfiguredTarget) + List<Label> hdrs = ruleConfiguredTarget.getAttributeMapper() .get("hdrs", BuildType.LABEL_LIST); if (hdrs != null) { for (Label hdrLabel : hdrs) { |