diff options
author | 2015-05-20 15:25:50 +0000 | |
---|---|---|
committer | 2015-05-21 09:49:44 +0000 | |
commit | 5b168f3abe7eb1a85425bfa43e99994ed46eb4f0 (patch) | |
tree | 60c7f1d475942f17599706f4ea78bfbf354a36b6 /src/main/java/com/google/devtools/build/lib/rules/objc | |
parent | 7d429acdb4fd8e9889b8a88895b598057752f261 (diff) |
Have ConfiguredTargetFactory subclasses declare which FragmentOptions
they need to create their fragments.
This is prerequisite work for fragment-limited configurations
(configurations that only include the fragments needed by their rules'
transitive closures). Given a set of desired fragment classes, we need
to know which FragmentOptions are needed to instantiate those fragments.
Note that we can't map this relationship the other way (given a set
of FragmentOptions, which fragment classes do they load?). That's
because different fragment loaders may consume overlapping options.
A good example is CppOptions, which is, e.g., used by both the C++
and Python configuration loaders.
At some point, we're probably going to want to force configuration
loaders to only understand options from their own "domain" (or have
well-defined hierarchies). But that's not the reality of today.
--
MOS_MIGRATED_REVID=94091093
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcConfiguration.java | 6 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfigurationLoader.java | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcConfiguration.java index 116030b2ab..185df22eae 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/J2ObjcConfiguration.java @@ -20,6 +20,7 @@ import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment; import com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory; +import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.events.Event; import com.google.devtools.build.lib.events.EventHandler; @@ -65,6 +66,11 @@ public class J2ObjcConfiguration extends Fragment { public Class<? extends Fragment> creates() { return J2ObjcConfiguration.class; } + + @Override + public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() { + return ImmutableSet.<Class<? extends FragmentOptions>>of(J2ObjcCommandLineOptions.class); + } } private final Set<String> translationFlags; diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfigurationLoader.java index e877aa63cc..e92c236900 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfigurationLoader.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ObjcConfigurationLoader.java @@ -14,11 +14,13 @@ package com.google.devtools.build.lib.rules.objc; +import com.google.common.collect.ImmutableSet; import com.google.devtools.build.lib.analysis.config.BuildConfiguration; import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment; import com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory; +import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; /** @@ -39,4 +41,9 @@ public class ObjcConfigurationLoader implements ConfigurationFragmentFactory { public Class<? extends BuildConfiguration.Fragment> creates() { return ObjcConfiguration.class; } + + @Override + public ImmutableSet<Class<? extends FragmentOptions>> requiredOptions() { + return ImmutableSet.<Class<? extends FragmentOptions>>of(ObjcCommandLineOptions.class); + } } |