aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/analysis/util/TestAspects.java
Commit message (Collapse)AuthorAge
* Automated refactor of Label.parseAbsolute() to always pass a repository mappingGravatar dannark2018-06-27
| | | | | RELNOTES: None PiperOrigin-RevId: 202360925
* Expose aspect actions from Skylark.Gravatar tomlu2018-06-22
| | | | | | | | | | | Like with providers, consumers get a merged view of all actions from the merged configured target (all other aspects + the base target). I had to rejig the aspect value / configured aspect to be symmetric with rule configured targets. I do not expect significant memory bloat from this. All lists / maps already existed, only extra fields have been added. RELNOTES: Expose aspect actions provider to Skylark. PiperOrigin-RevId: 201697923
* Add BuildConfiguration to ConfiguredTargetAndTarget and rename it to ↵Gravatar janakr2018-03-10
| | | | | | ConfiguredTargetAndData. We want to get BuildConfiguration out of ConfiguredTarget because it uses >800K when serialized. PiperOrigin-RevId: 188600002
* Expose an actions provider on RuleConfiguredTarget instances.Gravatar cparsons2018-03-06
| | | | | | | | | Given a target (for example from a skylark aspect), one will be able to access a list of actions that the target generated using "target.actions". This is without additional memory footprint. Actions themselves are not fully exposed to skylark (and thus there isn't much meaning to gather from them in skylark yet). Access methods will follow soon. RELNOTES: None. PiperOrigin-RevId: 188098079
* Add Codec for NativeAspectClass. As a result, remove @AutoCodec from ↵Gravatar janakr2018-02-13
| | | | | | | | concrete subclasses. Improve debugging message on serialization failures. Lot of test-side changes to make sure aspects are properly registered with the RuleClassProvider. PiperOrigin-RevId: 185607202
* Stop allowing generic LateBoundDefault value types. Such types are always ↵Gravatar janakr2018-02-02
| | | | | | | | either a Label or a List<Label>. We can easily enforce this through static type checking, so do it. This will help with LateBoundDefault serialization, since we don't have to serialize an arbitrary object. PiperOrigin-RevId: 184347100
* Change ConfiguredAspectFactory.create signature to take in aGravatar mjhalupka2018-01-31
| | | | | | | ConfiguredTargetAndTarget instead of a ConfiguredTarget. This is to assist in deprecating ConfiguredTarget.getTarget(). PiperOrigin-RevId: 184043491
* Convert TestAspects to MockRule.Gravatar gregce2017-11-29
| | | | | | It'd be nice to go further and break out a bunch of this code into more generally useful places (especially for callers that don't care about aspects). But that's a big mess and beyond the scope of what I'm aiming for here. PiperOrigin-RevId: 177307854
* Move --plugin to JavaOptions and remove --plugin_copt.Gravatar mstaib2017-09-26
| | | | | | | | | | | | | | | --plugin, though once used for C++, is currently a Java-specific flag. --plugin_copt is currently a total no-op, and has been for a long time. Moving these to the Java fragment is a little neater and helps get one step closer to enforcing LateBoundDefault fragment access. Additionally, since the "no plugins with duplicate names" restriction was added to work with plugin_copt, this restriction can be lifted. It no longer adds any value. RELNOTES: None. PiperOrigin-RevId: 169981221
* LateBoundDefault: enforce access to a single fragment (or none).Gravatar mstaib2017-09-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, there is no way to enforce that LateBoundDefaults only access the fragments that they declare. This means that LateBoundDefaults can fail to declare fragments at all, or declare the wrong ones, and still have no troubles. But when trimming, these fragments must be declared, because otherwise they will not necessarily be available. This change refactors LateBoundDefault to declare a single fragment type, not a set. All existing LateBoundDefaults use sets with a single element or no elements at all for their set of fragment classes, so this does not limit anything being done currently. To account for LateBoundDefaults which do not use configuration at all, typically those which only want to access the configured attribute map, it is possible for Void to be the fragment class which is requested. To account for LateBoundDefaults which need to access methods of the BuildConfiguration instance itself, it is possible for BuildConfiguration to be the fragment class which is requested; however, this is unsafe, so it is only a temporary state until a way to do this without also giving access to all of the fragments can be added. Drive-by refactoring: LateBoundDefaults' values are now typed. All actual production LateBoundDefaults were Label or List<Label> typed, through the LateBoundLabel and LateBoundLabelList subclasses. These subclasses have been removed, and LateBoundDefault has two type parameters, one for the type of its input, and one for the type of its output. RELNOTES: None. PiperOrigin-RevId: 169242278
* Move RuleConfiguredTarget to lib.analysis.configuredtargets.Gravatar gregce2017-09-19
| | | | | | This is a trivial change with a large file footprint. PiperOrigin-RevId: 169169864
* Move RuleConfiguredTargetFactory to lib.analysisGravatar ulfjack2017-08-07
| | | | | | | This is part of splitting up the build-base library into separate libraries for analysis, exec, and rules. PiperOrigin-RevId: 164446955
* Move some test classes into the only test that uses them.Gravatar tomlu2017-08-01
| | | | | | Preparatory step to make the test stop using --test_filter, as this is moving out of the base build configuration. PiperOrigin-RevId: 163737925
* Fix aspect processing when same dep appears in 2 attributes.Gravatar kaipi2017-05-22
| | | | | | If a target appeared in 2 different attributes, it is not processed twice, even if different aspects were applied to the different attributes. In that case, only one of the aspects is applied. This commit fixes this by checking which aspects have been applied to the target, instead of checking if the target was already processed. PiperOrigin-RevId: 156738275
* Native aspects can opt-in to apply to files.Gravatar dslomov2017-04-25
| | | | | | | Only works for top-level targets. RELNOTES: None. PiperOrigin-RevId: 154176914
* Enable rules to transition based on their Rule objects.Gravatar Michael Staib2017-03-21
| | | | | | | | | | | | This begins to allow for cases where a rule sets configuration based on its attributes, such as where a rule attribute names flags and their values - sort of a reverse select. There are no such cases yet, but they're coming! -- PiperOrigin-RevId: 150648357 MOS_MIGRATED_REVID=150648357
* Do not execute aspect implementation if target advertizes but fails to ↵Gravatar Dmitry Lomov2017-03-01
| | | | | | | | | | | provide a provider. Previously we always executed the function, but didn't add the aspect to the deps. -- PiperOrigin-RevId: 148887089 MOS_MIGRATED_REVID=148887089
* Remove special handling of name attribute. Fixes #278Gravatar Googler2017-02-14
| | | | | | | | | | | | | | | | | | | | | | | | | The name attribute gets special treatment in the codebase, in that it's not simply yet another attribute but stored in it's own field. Thus, every callside dealing with attributes needs to be aware of this special case and explicitly handle the name attribute. It's easy to see that this can lead to bugs. For example, querying for the name attribute is currently broken due the querying code not being aware of the special case [1]. Discussions with experienced bazel developers came to the conclusion that there is no need (anymore) to treat the name attribute specially and thus we decided it's best to remove the special treatment and handle the name attribute as any other attribute. This change removes the handling of name attributes and also adds a test case to verify that bug [1] is fixed. [1] https://github.com/bazelbuild/bazel/issues/278 -- PiperOrigin-RevId: 147446345 MOS_MIGRATED_REVID=147446345
* Allow aspects to adveritise providers they provide.Gravatar Dmitry Lomov2017-02-07
| | | | | | -- PiperOrigin-RevId: 146794883 MOS_MIGRATED_REVID=146794883
* Split transitions that return an empty list of options do not suppress ↵Gravatar Cal Peyser2017-01-30
| | | | | | | | | | dynamic ruleclass transitions. -- PiperOrigin-RevId: 146000375 MOS_MIGRATED_REVID=146000375
* Remove the ability for an aspect to propagate a different aspect.Gravatar Dmitry Lomov2017-01-20
| | | | | | | | | This functionality is never used, have never been exposed to Skylark and is a continuous pain to maintain and test. -- PiperOrigin-RevId: 145079832 MOS_MIGRATED_REVID=145079832
* Allows a rule class to specify a configuration transtion that will apply to allGravatar Cal Peyser2017-01-12
| | | | | | | | | | incoming edges if dynamic configurations are turned on. This CL does not cover top-level nodes. -- PiperOrigin-RevId: 144258789 MOS_MIGRATED_REVID=144258789
* Allow aspects to specify multiple sets of required providers to match ↵Gravatar Rumou Duan2016-12-01
| | | | | | | against rules. Aspects can attach to a rule if at least one set of required providers are present on the rule. -- MOS_MIGRATED_REVID=140605023
* Provide AspectDescriptor to ConfiguredAspect.Gravatar Dmitry Lomov2016-11-29
| | | | | | | | Also clean up the setting of aspect name in ConfiguredAspect and AspectDefintion - it is now obtained from the AspectClass. -- MOS_MIGRATED_REVID=140357052
* Do not propagate aspect to own attributes when using '*'.Gravatar Googler2016-11-04
| | | | | | | RELNOTES: Do not propagate aspect to its own attributes when using '*'. -- MOS_MIGRATED_REVID=138194456
* Allow aspects to propagate to all attributes.Gravatar Dmitry Lomov2016-09-27
| | | | | -- MOS_MIGRATED_REVID=134378592
* Enable aspect invocations to be matched by output filters.Gravatar Michael Staib2016-09-19
| | | | | | | | | | | | | Currently aspects have no tag, i.e., they don't get checked against output filters at all. This changes aspects to have a tag of the same form as the rule they are attached to (i.e., the label of the target). Since the default output filters match on ^//package[:/], this should cover most uses of the output filter, while still allowing for finer control for those who crave it. -- MOS_MIGRATED_REVID=133425215
* Add a specialized TransitiveInfoProviderMap to map TransitiveInfoProviders ↵Gravatar Googler2016-09-19
| | | | | | | | | | | | by class. TransitiveInfoProviderMap enforces that the provider implements the interface it's keyed by and provides accessors the reduce the amount of casting. This in general reduces boilerplate throughout wherever TransitiveInfoProviders are mapped by their class. Also add shorthand for adding a provider where it only implements TransitiveInfoProvider once, reducing the redundant specification of the TransitiveInfoProvider class. Infer the class as the exclusive direct implementor of TransitiveInfoProvider to account for special cases like AutoValue and LicenseProvider. -- MOS_MIGRATED_REVID=133386336
* Remove a dependency on dart_library rule from ↵Gravatar Dmitry Lomov2016-05-03
| | | | | | | ConfiguredTargetTransitivePackagesTest. -- MOS_MIGRATED_REVID=121398365
* Delete the interface NativeAspectFactory and make native aspects extend from ↵Gravatar Luis Fernando Pino Duque2016-04-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NativeAspectClass. This a large refactoring of the aspects, currently we have the following: - AspectClasses: The interface AspectClass is a implemented by either SkylarkAspectClass or NativeAspectClass<NativeAspectFactory>. They are wrappers for the AspectFactories and they hold the information about the Class<> of the factory. - AspectFactories (FooAspect.java): Represented by the interfaces ConfiguredAspectFactory and NativeAspectFactory, also by the interface ConfiguredNativeAspectFactory which is the union of the two aforementioned interfaces. All aspects implement ConfiguredNativeAspectFactory except Skylark aspects which implement only ConfiguredAspectFactory. After this CL the distinction between NativeAspectFactories and NativeAspectClasses dissappear, namely aspect that extends NativeAspectClass is considered native and if it implements ConfiguredAspectFactory it is configured. Therefore the interfaces NativeAspectFactory and ConfiguredNativeAspectFactory both disappear. With this refactoring the aspectFactoryMap in the ConfiguredRuleClassProvider changes its type from (String -> Class<? extends NativeAspectClass>) to (String -> NativeAspectClass) which means it is now able to have an instance of the aspect instead of its Class only. By doing this, it is now possible to pass parameters when creating an aspect in the ConfiguredRuleClassProvider. -- MOS_MIGRATED_REVID=120819647
* Rename LateBoundLabel#getDefault(Rule, AttributeMap, T) to #resolve().Gravatar Lukacs Berki2016-04-19
| | | | | | | Its old name was confusing because resolve() and getDefault() do radically different things: getDefault() returns a good enough lie for when BuildConfiguration is not available, and resolve() resolves the dependency when we do have a BuildConfiguration. -- MOS_MIGRATED_REVID=120212630
* Implement TODO from: ↵Gravatar Greg Estren2016-02-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/bazelbuild/bazel/blo[]fbbd6a32b95ba746f09dae1eaeaccf675cd5b3/src/main/java/com/google/devtools/build/lib/packages/Attribute.java#L1045 This allows the default value computation for latebound attributes to consider the values of configurable attributes. This is most directly useful for user-definable Skylark defaults, which have full access to the values of all non-latebound attributes. Without this change, this kind of scenario crashes Bazel. For example: ------------------ select_rules.bzl: ------------------ def _impl(ctx): ctx.file_action( output=ctx.outputs.out_file, content=ctx.attr.string_value, ) return struct() # Bug does not manifest without using this as a default. def _derived_value(attrs, _): return Label("//some:dep") selector_rule = rule( implementation=_impl, attrs={ "string_value": attr.string(default=""), "out_file": attr.output(), "_derived": attr.label(default=_derived_value), }, output_to_genfiles=True, ) def selector_macro(name, out_file="", string_value=""): # This will fail with selectors. selector_rule( name="%s_skylark" % name, string_value=string_value, out_file=out_file + ".skylark", ) # This does not. native.genrule( name="%s_genrule" % name, cmd="echo '" + string_value + "' > $@", outs=[out_file + ".genrule"], ) native.filegroup( name=name, srcs=[":%s_genrule" % name, "%s_skylark" % name], ) ------------------ BUILD.bzl: ------------------ config_setting( name = "selector", values = {"compilation_mode": "opt"}, ) selector_macro( name = "this_rule", string_value = """soup? """ + select({ ":selector": "no, thank you.", "//conditions:default": "yes, please!!", }), out_file = "this_rule.txt", ) -- MOS_MIGRATED_REVID=114326474
* Rewrite SkylarkAspectsTest to inherit AnalysisTestCase.Gravatar Ulf Adams2016-01-19
| | | | | | | | | | | | | | | | | | While BuildViewTestCase now has an update() function, it also has a lot of legacy cruft that doesn't match how the code is used in production. This also makes the test code a bit simpler. Also add a couple missing fail() statements. This is in preparation for adding a couple more tests; we don't have good test coverage for interaction between Skylark aspects and native rules and vice versa, especially for error scenarios. I may reuse some of the AspectTest code, but that inherits AnalysisTestCase. Inheriting AnalysisTestCase here also makes that easier. -- MOS_MIGRATED_REVID=112460142
* Emit extra-actions for actions registered by Aspects.Gravatar Carmi Grushko2015-11-17
| | | | | | | A prerequisite is to pass RuleContext to ConfiguredAspect, so we can read from it the registered actions when we build() the aspect. -- MOS_MIGRATED_REVID=107997593
* Aspect terminology update.Gravatar Dmitry Lomov2015-11-10
| | | | | | | | Aspect => ConfiguredAspect AspectWithParameters => Aspect -- MOS_MIGRATED_REVID=107375211
* When creating RuleContext, explicitly pass the set of attributes an attached ↵Gravatar Carmi Grushko2015-11-02
| | | | | | | Aspect provides. -- MOS_MIGRATED_REVID=106882046
* Parametrize aspect definition with AspectParameters.Gravatar Dmitry Lomov2015-11-02
| | | | | -- MOS_MIGRATED_REVID=106848269
* Implement propagation along dependencies for Skylark aspects.Gravatar Dmitry Lomov2015-11-02
| | | | | -- MOS_MIGRATED_REVID=106694515
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Move Label from the lib.syntax to the lib.cmdline package so that:Gravatar Lukacs Berki2015-09-21
| | | | | | | | | | - Label parsing can be simplified - lib.syntax is only contains the code for Skylark and is reasonably independent from the problem domain of building things This change is mostly only changes to imports declarations. The rest is reversing the dependency between :cmdline and :syntax and moving a tiny amount of code between Printer and FilesetEntry and the addition of SkylarkPrintableValue that I couldn't be bothered to separate out into its own change. -- MOS_MIGRATED_REVID=103527877
* Separate build-specific types and types inherent to Skylark.Gravatar Lukacs Berki2015-09-21
| | | | | -- MOS_MIGRATED_REVID=103374106
* Fix a bug, when we have dependency from one aspect to another ↵Gravatar Marian Lobur2015-09-14
| | | | | | | aspect1->aspect2 and aspect2 fails then aspect1 throws IllegalStateException. -- MOS_MIGRATED_REVID=102976139
* Fix broken tests.Gravatar Marian Lobur2015-09-02
| | | | | -- MOS_MIGRATED_REVID=102134151
* Aspects can get information from their base rule.Gravatar Marian Lobur2015-09-02
| | | | | -- MOS_MIGRATED_REVID=102126786
* A prototype implementation of top-level aspects.Gravatar Dmitry Lomov2015-08-20
| | | | | -- MOS_MIGRATED_REVID=101033236
* We are trying to merge same copies of the aspect, when target is declared in ↵Gravatar Marian Lobur2015-05-15
| | | | | | | different attributes, to which we have attached aspect. -- MOS_MIGRATED_REVID=93412457
* Open source the aspects-related tests.Gravatar Ulf Adams2015-04-24
-- MOS_MIGRATED_REVID=91907246