diff options
author | Cal Peyser <cpeyser@google.com> | 2016-11-18 18:53:52 +0000 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2016-11-21 19:36:35 +0000 |
commit | a5312cdfe3dee6d34a32592c00d80e8142f89615 (patch) | |
tree | dba98ff71513e8a15f03c9b45fa896331ca3b57d /src/main/java/com/google/devtools/build | |
parent | babd485f80de515bcadd99bb645b519f26230b9a (diff) |
Better error message for experimental_objc_library targets built with a
crosstool that does not support objc.
--
MOS_MIGRATED_REVID=139598484
Diffstat (limited to 'src/main/java/com/google/devtools/build')
3 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java index b3f325087b..694f4e6e53 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CcToolchainFeatures.java @@ -1425,7 +1425,7 @@ public class CcToolchainFeatures implements Serializable { } /** @return whether an action config for the blaze action with the given name is enabled. */ - boolean actionIsConfigured(String actionName) { + public boolean actionIsConfigured(String actionName) { return enabledActionConfigActionNames.contains(actionName); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java index 3e529993c2..21d7cd3849 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/CrosstoolCompilationSupport.java @@ -60,7 +60,7 @@ public class CrosstoolCompilationSupport extends CompilationSupport { private static final String OBJC_MODULE_FEATURE_NAME = "use_objc_modules"; private static final String NO_ENABLE_MODULES_FEATURE_NAME = "no_enable_modules"; - private static final Iterable<String> ACTIVATED_ACTIONS = + private static final ImmutableList<String> ACTIVATED_ACTIONS = ImmutableList.of( "objc-compile", "objc++-compile", @@ -221,6 +221,25 @@ public class CrosstoolCompilationSupport extends CompilationSupport { return this; } + @Override + CompilationSupport validateAttributes() throws RuleErrorException { + super.validateAttributes(); + + FeatureConfiguration featureConfiguration = ruleContext + .getPrerequisite(":cc_toolchain", Mode.TARGET) + .getProvider(CcToolchainProvider.class) + .getFeatures() + .getFeatureConfiguration(ACTIVATED_ACTIONS); + for (String action : ACTIVATED_ACTIONS) { + if (!featureConfiguration.actionIsConfigured(action)) { + ruleContext.ruleError( + String.format("Toolchain derived from CROSSTOOL for this build does not support objc." + + " Missing action %s.", action)); + } + } + return this; + } + private CcLibraryHelper createCcLibraryHelper(ObjcCommon common, VariablesExtension extension) { PrecompiledFiles precompiledFiles = new PrecompiledFiles(ruleContext); Collection<Artifact> arcSources = Sets.newHashSet(compilationArtifacts.getSrcs()); diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcLibrary.java index b58e842312..4ba890cb30 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/objc/ExperimentalObjcLibrary.java @@ -44,11 +44,12 @@ public class ExperimentalObjcLibrary implements RuleConfiguredTargetFactory { public static ConfiguredTarget configureExperimentalObjcLibrary(RuleContext ruleContext) throws InterruptedException, RuleErrorException { validateAttributes(ruleContext); - + ObjcCommon common = common(ruleContext); CompilationSupport compilationSupport = new CrosstoolCompilationSupport(ruleContext) + .validateAttributes() .registerCompileAndArchiveActions(common) .registerFullyLinkAction( common.getObjcProvider(), |