Search in sources :

Example 1 with ResourceAttributes

use of com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes in project bazel by bazelbuild.

the class BinaryLinkingTargetFactory method common.

private ObjcCommon common(RuleContext ruleContext, Optional<ObjcProvider> protosObjcProvider) {
    IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
    CompilationArtifacts compilationArtifacts = CompilationSupport.compilationArtifacts(ruleContext);
    ObjcCommon.Builder builder = new ObjcCommon.Builder(ruleContext).setCompilationAttributes(CompilationAttributes.Builder.fromRuleContext(ruleContext).build()).setCompilationArtifacts(compilationArtifacts).setResourceAttributes(new ResourceAttributes(ruleContext)).addDefines(ruleContext.getTokenizedStringListAttr("defines")).addDeps(ruleContext.getPrerequisites("deps", Mode.TARGET)).addRuntimeDeps(ruleContext.getPrerequisites("runtime_deps", Mode.TARGET)).addDeps(ruleContext.getPrerequisites("bundles", Mode.TARGET)).addDepObjcProviders(protosObjcProvider.asSet()).addNonPropagatedDepObjcProviders(ruleContext.getPrerequisites("non_propagated_deps", Mode.TARGET, ObjcProvider.class)).setIntermediateArtifacts(intermediateArtifacts).setAlwayslink(false).setHasModuleMap().setLinkedBinary(intermediateArtifacts.strippedSingleArchitectureBinary());
    if (ObjcRuleClasses.objcConfiguration(ruleContext).generateDsym()) {
        builder.addDebugArtifacts(DsymOutputType.APP);
    }
    if (ObjcRuleClasses.objcConfiguration(ruleContext).generateLinkmap()) {
        builder.setLinkmapFile(intermediateArtifacts.linkmap());
    }
    return builder.build();
}
Also used : ResourceAttributes(com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes)

Example 2 with ResourceAttributes

use of com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes in project bazel by bazelbuild.

the class IosTest method common.

/** Constructs an {@link ObjcCommon} instance based on the attributes. */
private ObjcCommon common(RuleContext ruleContext, Optional<ObjcProvider> protosObjcProvider) {
    CompilationArtifacts compilationArtifacts = CompilationSupport.compilationArtifacts(ruleContext);
    ObjcCommon.Builder builder = new ObjcCommon.Builder(ruleContext).setCompilationAttributes(CompilationAttributes.Builder.fromRuleContext(ruleContext).build()).setCompilationArtifacts(compilationArtifacts).setResourceAttributes(new ResourceAttributes(ruleContext)).addDefines(ruleContext.getTokenizedStringListAttr("defines")).addDeps(ruleContext.getPrerequisites("deps", Mode.TARGET)).addRuntimeDeps(ruleContext.getPrerequisites("runtime_deps", Mode.TARGET)).addDeps(ruleContext.getPrerequisites("bundles", Mode.TARGET)).addDepObjcProviders(protosObjcProvider.asSet()).addNonPropagatedDepObjcProviders(ruleContext.getPrerequisites("non_propagated_deps", Mode.TARGET, ObjcProvider.class)).setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)).setHasModuleMap();
    if (isXcTest(ruleContext)) {
        builder.addExtraSdkFrameworks(AUTOMATIC_SDK_FRAMEWORKS_FOR_XCTEST).addDepObjcProviders(ImmutableList.of(xcTestAppProvider(ruleContext).getObjcProvider()));
    }
    // Add the memleaks library if the --ios_memleaks flag is true.  The library pauses the test
    // after all tests have been executed so that leaks can be run.
    ObjcConfiguration config = ruleContext.getFragment(ObjcConfiguration.class);
    if (config.runMemleaks()) {
        builder.addDepObjcProviders(ruleContext.getPrerequisites(MEMLEAKS_DEP_ATTR, Mode.TARGET, ObjcProvider.class));
    }
    return builder.build();
}
Also used : ResourceAttributes(com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes)

Example 3 with ResourceAttributes

use of com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes in project bazel by bazelbuild.

the class ObjcImport method create.

@Override
public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    ObjcCommon common = new ObjcCommon.Builder(ruleContext).setCompilationAttributes(CompilationAttributes.Builder.fromRuleContext(ruleContext).build()).setResourceAttributes(new ResourceAttributes(ruleContext)).setIntermediateArtifacts(ObjcRuleClasses.intermediateArtifacts(ruleContext)).setAlwayslink(ruleContext.attributes().get("alwayslink", Type.BOOLEAN)).setHasModuleMap().addExtraImportLibraries(ruleContext.getPrerequisiteArtifacts("archives", Mode.TARGET).list()).addDepObjcProviders(ruleContext.getPrerequisites("bundles", Mode.TARGET, ObjcProvider.class)).build();
    XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder();
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
    CompilationAttributes compilationAttributes = CompilationAttributes.Builder.fromRuleContext(ruleContext).build();
    IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
    Iterable<Artifact> publicHeaders = compilationAttributes.hdrs();
    CppModuleMap moduleMap = intermediateArtifacts.moduleMap();
    CompilationSupport.create(ruleContext).registerGenerateModuleMapAction(moduleMap, publicHeaders).addXcodeSettings(xcodeProviderBuilder, common).validateAttributes();
    new ResourceSupport(ruleContext).validateAttributes().addXcodeSettings(xcodeProviderBuilder);
    new XcodeSupport(ruleContext).addXcodeSettings(xcodeProviderBuilder, common.getObjcProvider(), LIBRARY_STATIC).addDependencies(xcodeProviderBuilder, new Attribute("bundles", Mode.TARGET)).registerActions(xcodeProviderBuilder.build()).addFilesToBuild(filesToBuild);
    return ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build()).addProvider(XcodeProvider.class, xcodeProviderBuilder.build()).addProvider(ObjcProvider.class, common.getObjcProvider()).build();
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) ResourceAttributes(com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes) Artifact(com.google.devtools.build.lib.actions.Artifact) CppModuleMap(com.google.devtools.build.lib.rules.cpp.CppModuleMap)

Aggregations

ResourceAttributes (com.google.devtools.build.lib.rules.objc.ObjcCommon.ResourceAttributes)3 Artifact (com.google.devtools.build.lib.actions.Artifact)1 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)1 CppModuleMap (com.google.devtools.build.lib.rules.cpp.CppModuleMap)1