Search in sources :

Example 1 with PlatformType

use of com.google.devtools.build.lib.rules.apple.Platform.PlatformType in project bazel by bazelbuild.

the class BundleSupport method actoolzipCommandLine.

private CommandLine actoolzipCommandLine(ObjcProvider provider, Artifact zipOutput, Artifact partialInfoPlist) {
    PlatformType platformType = PlatformType.IOS;
    // use the watchos platform whereas watchOS 1 uses the iphone platform.
    if (isBuildingForWatch() && bundling.getBundleDir().startsWith("Watch")) {
        platformType = PlatformType.WATCHOS;
    }
    CustomCommandLine.Builder commandLine = CustomCommandLine.builder().addPath(zipOutput.getExecPath()).add("--platform").add(appleConfiguration.getMultiArchPlatform(platformType).getLowerCaseNameInPlist()).addExecPath("--output-partial-info-plist", partialInfoPlist).add("--minimum-deployment-target").add(bundling.getMinimumOsVersion().toString());
    for (TargetDeviceFamily targetDeviceFamily : targetDeviceFamiliesForResources()) {
        commandLine.add("--target-device").add(targetDeviceFamily.name().toLowerCase(Locale.US));
    }
    return commandLine.add(PathFragment.safePathStrings(provider.get(XCASSETS_DIR))).add(extraActoolArgs).build();
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Example 2 with PlatformType

use of com.google.devtools.build.lib.rules.apple.Platform.PlatformType in project bazel by bazelbuild.

the class AppleBinary method create.

@Override
public final ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    PlatformType platformType = MultiArchSplitTransitionProvider.getPlatformType(ruleContext);
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    Platform platform = appleConfiguration.getMultiArchPlatform(platformType);
    ImmutableListMultimap<BuildConfiguration, ObjcProvider> configurationToNonPropagatedObjcMap = ruleContext.getPrerequisitesByConfiguration("non_propagated_deps", Mode.SPLIT, ObjcProvider.class);
    ImmutableListMultimap<BuildConfiguration, TransitiveInfoCollection> configToDepsCollectionMap = ruleContext.getPrerequisitesByConfiguration("deps", Mode.SPLIT);
    Set<BuildConfiguration> childConfigurations = getChildConfigurations(ruleContext);
    Artifact outputArtifact = ObjcRuleClasses.intermediateArtifacts(ruleContext).combinedArchitectureBinary();
    MultiArchBinarySupport multiArchBinarySupport = new MultiArchBinarySupport(ruleContext);
    Map<BuildConfiguration, ObjcProvider> objcProviderByDepConfiguration = multiArchBinarySupport.objcProviderByDepConfiguration(childConfigurations, configToDepsCollectionMap, configurationToNonPropagatedObjcMap, getDylibProviders(ruleContext), getDylibProtoProviders(ruleContext));
    multiArchBinarySupport.registerActions(platform, getExtraLinkArgs(ruleContext), objcProviderByDepConfiguration, getExtraLinkInputs(ruleContext), configToDepsCollectionMap, outputArtifact);
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.<Artifact>stableOrder().add(outputArtifact);
    RuleConfiguredTargetBuilder targetBuilder = ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build());
    ObjcProvider.Builder objcProviderBuilder = new ObjcProvider.Builder();
    for (ObjcProvider objcProvider : objcProviderByDepConfiguration.values()) {
        objcProviderBuilder.addTransitiveAndPropagate(objcProvider);
    }
    objcProviderBuilder.add(MULTI_ARCH_LINKED_BINARIES, outputArtifact);
    ObjcProvider objcProvider = objcProviderBuilder.build();
    // TODO(cparsons): Stop propagating ObjcProvider directly from this rule.
    targetBuilder.addProvider(ObjcProvider.class, objcProvider);
    switch(getBinaryType(ruleContext)) {
        case EXECUTABLE:
            targetBuilder.addNativeDeclaredProvider(new AppleExecutableBinaryProvider(outputArtifact, objcProvider));
            break;
        case DYLIB:
            targetBuilder.addNativeDeclaredProvider(new AppleDylibBinaryProvider(outputArtifact, objcProvider));
            break;
        case LOADABLE_BUNDLE:
            targetBuilder.addNativeDeclaredProvider(new AppleLoadableBundleBinaryProvider(outputArtifact));
            break;
    }
    AppleDebugOutputsProvider.Builder builder = AppleDebugOutputsProvider.Builder.create();
    for (BuildConfiguration childConfig : childConfigurations) {
        AppleConfiguration childAppleConfig = childConfig.getFragment(AppleConfiguration.class);
        ObjcConfiguration childObjcConfig = childConfig.getFragment(ObjcConfiguration.class);
        IntermediateArtifacts intermediateArtifacts = new IntermediateArtifacts(ruleContext, /*archiveFileNameSuffix*/
        "", /*outputPrefix*/
        "", childConfig);
        String arch = childAppleConfig.getSingleArchitecture();
        if (childAppleConfig.getBitcodeMode() == AppleBitcodeMode.EMBEDDED) {
            Artifact bitcodeSymbol = intermediateArtifacts.bitcodeSymbolMap();
            builder.addOutput(arch, OutputType.BITCODE_SYMBOLS, bitcodeSymbol);
        }
        if (childObjcConfig.generateDsym()) {
            Artifact dsymBinary = intermediateArtifacts.dsymSymbol(DsymOutputType.APP);
            builder.addOutput(arch, OutputType.DSYM_BINARY, dsymBinary);
        }
        if (childObjcConfig.generateLinkmap()) {
            Artifact linkmap = intermediateArtifacts.linkmap();
            builder.addOutput(arch, OutputType.LINKMAP, linkmap);
        }
    }
    targetBuilder.addNativeDeclaredProvider(builder.build());
    return targetBuilder.build();
}
Also used : Platform(com.google.devtools.build.lib.rules.apple.Platform) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) Artifact(com.google.devtools.build.lib.actions.Artifact) BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) TransitiveInfoCollection(com.google.devtools.build.lib.analysis.TransitiveInfoCollection) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Example 3 with PlatformType

use of com.google.devtools.build.lib.rules.apple.Platform.PlatformType in project bazel by bazelbuild.

the class AppleStaticLibrary method create.

@Override
public final ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    PlatformType platformType = MultiArchSplitTransitionProvider.getPlatformType(ruleContext);
    ImmutableListMultimap<BuildConfiguration, TransitiveInfoCollection> configToDepsCollectionMap = ruleContext.getPrerequisitesByConfiguration("deps", Mode.SPLIT);
    ImmutableListMultimap<BuildConfiguration, ObjcProvider> configToObjcAvoidDepsMap = ruleContext.getPrerequisitesByConfiguration(AppleStaticLibraryRule.AVOID_DEPS_ATTR_NAME, Mode.SPLIT, ObjcProvider.class);
    ImmutableListMultimap<BuildConfiguration, CcLinkParamsProvider> configToCcAvoidDepsMap = ruleContext.getPrerequisitesByConfiguration(AppleStaticLibraryRule.AVOID_DEPS_ATTR_NAME, Mode.SPLIT, CcLinkParamsProvider.class);
    Set<BuildConfiguration> childConfigurations = getChildConfigurations(ruleContext);
    IntermediateArtifacts ruleIntermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
    NestedSetBuilder<Artifact> librariesToLipo = NestedSetBuilder.<Artifact>stableOrder();
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.<Artifact>stableOrder().add(ruleIntermediateArtifacts.combinedArchitectureArchive());
    ObjcProvider.Builder objcProviderBuilder = new ObjcProvider.Builder();
    for (BuildConfiguration childConfig : childConfigurations) {
        ProtobufSupport protoSupport = new ProtobufSupport(ruleContext, childConfig).registerGenerationActions().registerCompilationActions();
        Optional<ObjcProvider> protosObjcProvider = protoSupport.getObjcProvider();
        IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext, childConfig);
        ObjcCommon common = common(ruleContext, childConfig, intermediateArtifacts, nullToEmptyList(configToDepsCollectionMap.get(childConfig)), protosObjcProvider);
        ObjcProvider objcProvider = common.getObjcProvider().subtractSubtrees(configToObjcAvoidDepsMap.get(childConfig), configToCcAvoidDepsMap.get(childConfig));
        librariesToLipo.add(intermediateArtifacts.strippedSingleArchitectureLibrary());
        CompilationSupport.createForConfig(ruleContext, childConfig).registerCompileAndArchiveActions(common).registerFullyLinkAction(objcProvider, intermediateArtifacts.strippedSingleArchitectureLibrary()).validateAttributes();
        ruleContext.assertNoErrors();
        addTransitivePropagatedKeys(objcProviderBuilder, objcProvider);
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    new LipoSupport(ruleContext).registerCombineArchitecturesAction(librariesToLipo.build(), ruleIntermediateArtifacts.combinedArchitectureArchive(), appleConfiguration.getMultiArchPlatform(platformType));
    RuleConfiguredTargetBuilder targetBuilder = ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build());
    objcProviderBuilder.add(MULTI_ARCH_LINKED_ARCHIVES, ruleIntermediateArtifacts.combinedArchitectureArchive());
    targetBuilder.addProvider(ObjcProvider.class, objcProviderBuilder.build());
    return targetBuilder.build();
}
Also used : CcLinkParamsProvider(com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) Artifact(com.google.devtools.build.lib.actions.Artifact) BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) TransitiveInfoCollection(com.google.devtools.build.lib.analysis.TransitiveInfoCollection) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Example 4 with PlatformType

use of com.google.devtools.build.lib.rules.apple.Platform.PlatformType in project bazel by bazelbuild.

the class MultiArchSplitTransitionProvider method apply.

@Override
public SplitTransition<?> apply(Rule fromRule) {
    String platformTypeString = NonconfigurableAttributeMapper.of(fromRule).get(MultiArchPlatformRule.PLATFORM_TYPE_ATTR_NAME, STRING);
    PlatformType platformType;
    try {
        platformType = getPlatformType(platformTypeString);
    } catch (IllegalArgumentException exception) {
        // There's no opportunity to propagate exception information up cleanly at the transition
        // provider level. This should later be registered as a rule error during the initialization
        // of the rule.
        platformType = PlatformType.IOS;
    }
    return SPLIT_TRANSITIONS_BY_TYPE.get(platformType);
}
Also used : PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Example 5 with PlatformType

use of com.google.devtools.build.lib.rules.apple.Platform.PlatformType in project bazel by bazelbuild.

the class WatchApplicationSupport method createBundle.

private void createBundle(Optional<XcodeProvider.Builder> xcodeProviderBuilder, ObjcProvider depsObjcProvider, NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException {
    registerActions();
    ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder().setIpaArtifact(ipaArtifact).setBundleId(attributes.bundleId()).setAppIcon(attributes.appIcon()).setProvisioningProfile(attributes.provisioningProfile()).setProvisioningProfileAttributeName(WATCH_APP_PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(families()).setIntermediateArtifacts(intermediateArtifacts).setInfoPlistsFromRule(attributes.infoPlists()).setArtifactPrefix(artifactPrefix).setEntitlements(attributes.entitlements());
    if (attributes.isBundleIdExplicitySpecified()) {
        releaseBundling.setPrimaryBundleId(attributes.bundleId());
    } else {
        releaseBundling.setFallbackBundleId(attributes.bundleId());
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    PlatformType appPlatformType = watchOSVersion == WatchOSVersion.OS1 ? PlatformType.IOS : PlatformType.WATCHOS;
    DottedVersion minimumOsVersion = appPlatformType == PlatformType.IOS ? WatchUtils.determineMinimumIosVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)) : appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, depsObjcProvider, LinkedBinary.DEPENDENCIES_ONLY, watchOSVersion.getApplicationBundleDirFormat(), bundleName, minimumOsVersion, releaseBundling.build(), appleConfiguration.getMultiArchPlatform(appPlatformType)).registerActions(DsymOutputType.APP);
    if (xcodeProviderBuilder.isPresent()) {
        releaseBundlingSupport.addXcodeSettings(xcodeProviderBuilder.get());
    }
    releaseBundlingSupport.addFilesToBuild(filesToBuild, Optional.<DsymOutputType>absent()).validateResources().validateAttributes();
}
Also used : DottedVersion(com.google.devtools.build.lib.rules.apple.DottedVersion) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration) PlatformType(com.google.devtools.build.lib.rules.apple.Platform.PlatformType)

Aggregations

PlatformType (com.google.devtools.build.lib.rules.apple.Platform.PlatformType)5 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)3 AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)3 Artifact (com.google.devtools.build.lib.actions.Artifact)2 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)2 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)2 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)2 CustomCommandLine (com.google.devtools.build.lib.analysis.actions.CustomCommandLine)1 DottedVersion (com.google.devtools.build.lib.rules.apple.DottedVersion)1 Platform (com.google.devtools.build.lib.rules.apple.Platform)1 CcLinkParamsProvider (com.google.devtools.build.lib.rules.cpp.CcLinkParamsProvider)1