Search in sources :

Example 1 with CppCompileAction

use of com.google.devtools.build.lib.rules.cpp.CppCompileAction in project bazel by bazelbuild.

the class CrosstoolCompilationSupport method registerHeaderScanningActions.

private void registerHeaderScanningActions(Info info, ObjcProvider objcProvider, CompilationArtifacts compilationArtifacts) {
    // PIC is not used for Obj-C builds, if that changes this method will need to change
    if (!isHeaderThinningEnabled() || info.getCcCompilationOutputs().getObjectFiles(false).isEmpty()) {
        return;
    }
    ImmutableList.Builder<ObjcHeaderThinningInfo> headerThinningInfos = ImmutableList.builder();
    AnalysisEnvironment analysisEnvironment = ruleContext.getAnalysisEnvironment();
    for (Artifact objectFile : info.getCcCompilationOutputs().getObjectFiles(false)) {
        ActionAnalysisMetadata generatingAction = analysisEnvironment.getLocalGeneratingAction(objectFile);
        if (generatingAction instanceof CppCompileAction) {
            CppCompileAction action = (CppCompileAction) generatingAction;
            Artifact sourceFile = action.getSourceFile();
            if (!sourceFile.isTreeArtifact() && SOURCES_FOR_HEADER_THINNING.matches(sourceFile.getFilename())) {
                headerThinningInfos.add(new ObjcHeaderThinningInfo(sourceFile, intermediateArtifacts.headersListFile(sourceFile), action.getCompilerOptions()));
            }
        }
    }
    registerHeaderScanningActions(headerThinningInfos.build(), objcProvider, compilationArtifacts);
}
Also used : AnalysisEnvironment(com.google.devtools.build.lib.analysis.AnalysisEnvironment) ImmutableList(com.google.common.collect.ImmutableList) CppCompileAction(com.google.devtools.build.lib.rules.cpp.CppCompileAction) ActionAnalysisMetadata(com.google.devtools.build.lib.actions.ActionAnalysisMetadata) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 ActionAnalysisMetadata (com.google.devtools.build.lib.actions.ActionAnalysisMetadata)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 AnalysisEnvironment (com.google.devtools.build.lib.analysis.AnalysisEnvironment)1 CppCompileAction (com.google.devtools.build.lib.rules.cpp.CppCompileAction)1