/** * Creates a builder from a rule. This also uses the configuration and artifact factory from the * rule. */ public CppCompileActionBuilder(RuleContext ruleContext, Artifact sourceFile, Label sourceLabel) { this.owner = ruleContext.getActionOwner(); this.actionContext = CppCompileActionContext.class; this.cppConfiguration = ruleContext.getFragment(CppConfiguration.class); this.analysisEnvironment = ruleContext.getAnalysisEnvironment(); this.sourceFile = sourceFile; this.sourceLabel = sourceLabel; this.configuration = ruleContext.getConfiguration(); this.mandatoryInputsBuilder = NestedSetBuilder.stableOrder(); this.pluginInputsBuilder = NestedSetBuilder.stableOrder(); this.lipoScannableMap = getLipoScannableMap(ruleContext); this.ruleContext = ruleContext; features.addAll(ruleContext.getFeatures()); }
private static CToolchainIdeInfo makeCToolchainIdeInfo( RuleContext ruleContext, CppConfiguration cppConfiguration) { CToolchainIdeInfo.Builder builder = CToolchainIdeInfo.newBuilder(); ImmutableSet<String> features = ruleContext.getFeatures(); builder.setTargetName(cppConfiguration.getTargetGnuSystemName()); builder.addAllBaseCompilerOption(cppConfiguration.getCompilerOptions(features)); builder.addAllCOption(cppConfiguration.getCOptions()); builder.addAllCppOption(cppConfiguration.getCxxOptions(features)); builder.addAllLinkOption(cppConfiguration.getLinkOptions()); // This includes options such as system includes from toolchains. builder.addAllUnfilteredCompilerOption(cppConfiguration.getUnfilteredCompilerOptions(features)); builder.setPreprocessorExecutable( cppConfiguration.getCpreprocessorExecutable().getSafePathString()); builder.setCppExecutable(cppConfiguration.getCppExecutable().getSafePathString()); List<PathFragment> builtInIncludeDirectories = cppConfiguration.getBuiltInIncludeDirectories(); for (PathFragment builtInIncludeDirectory : builtInIncludeDirectories) { builder.addBuiltInIncludeDirectory(builtInIncludeDirectory.getSafePathString()); } return builder.build(); }