Search in sources :

Example 21 with AppleConfiguration

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

the class ReleaseBundlingSupport method registerSwiftSupportActionsIfNecessary.

/** Registers an action to copy Swift standard library dylibs into SwiftSupport root directory. */
private void registerSwiftSupportActionsIfNecessary(Artifact combinedArchBinary) {
    if (!objcProvider.is(USES_SWIFT)) {
        return;
    }
    AppleConfiguration configuration = ruleContext.getFragment(AppleConfiguration.class);
    CustomCommandLine.Builder commandLine = CustomCommandLine.builder();
    if (configuration.getXcodeToolchain() != null) {
        commandLine.add("--toolchain").add(configuration.getXcodeToolchain());
    }
    commandLine.add("--output_zip_path").addPath(intermediateArtifacts.swiftSupportZip().getExecPath()).add("--bundle_path").add("SwiftSupport/" + platform.getLowerCaseNameInPlist()).add("--platform").add(platform.getLowerCaseNameInPlist()).addExecPath("--scan-executable", combinedArchBinary);
    ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(configuration, platform).setMnemonic("SwiftCopySwiftSupport").setExecutable(attributes.swiftStdlibToolWrapper()).setCommandLine(commandLine.build()).addOutput(intermediateArtifacts.swiftSupportZip()).addInput(combinedArchBinary).build(ruleContext));
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration)

Example 22 with AppleConfiguration

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

the class ReleaseBundlingSupport method registerSwiftStdlibActionsIfNecessary.

/** Registers an action to copy Swift standard library dylibs into app bundle. */
private void registerSwiftStdlibActionsIfNecessary(Artifact combinedArchBinary) {
    if (!objcProvider.is(USES_SWIFT)) {
        return;
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    CustomCommandLine.Builder commandLine = CustomCommandLine.builder();
    if (appleConfiguration.getXcodeToolchain() != null) {
        commandLine.add("--toolchain").add(appleConfiguration.getXcodeToolchain());
    }
    commandLine.add("--output_zip_path").addPath(intermediateArtifacts.swiftFrameworksFileZip().getExecPath()).add("--bundle_path").add("Frameworks").add("--platform").add(platform.getLowerCaseNameInPlist()).addExecPath("--scan-executable", combinedArchBinary);
    ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(appleConfiguration, platform).setMnemonic("SwiftStdlibCopy").setExecutable(attributes.swiftStdlibToolWrapper()).setCommandLine(commandLine.build()).addOutput(intermediateArtifacts.swiftFrameworksFileZip()).addInput(combinedArchBinary).build(ruleContext));
}
Also used : CustomCommandLine(com.google.devtools.build.lib.analysis.actions.CustomCommandLine) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration)

Example 23 with AppleConfiguration

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

the class ReleaseBundlingTargetFactory method create.

@Override
public ConfiguredTarget create(RuleContext ruleContext) throws InterruptedException, RuleErrorException {
    validateAttributes(ruleContext);
    ObjcCommon common = common(ruleContext);
    XcodeProvider.Builder xcodeProviderBuilder = new XcodeProvider.Builder();
    NestedSetBuilder<Artifact> filesToBuild = NestedSetBuilder.stableOrder();
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, common.getObjcProvider(), LinkedBinary.DEPENDENCIES_ONLY, bundleDirFormat, bundleName(ruleContext), bundleMinimumOsVersion(ruleContext), appleConfiguration.getMultiArchPlatform(PlatformType.IOS));
    releaseBundlingSupport.registerActions(DsymOutputType.APP).addXcodeSettings(xcodeProviderBuilder).addFilesToBuild(filesToBuild, Optional.of(DsymOutputType.APP)).validateResources().validateAttributes();
    XcodeSupport xcodeSupport = new XcodeSupport(ruleContext).addFilesToBuild(filesToBuild).addXcodeSettings(xcodeProviderBuilder, common.getObjcProvider(), xcodeProductType, ruleContext.getFragment(AppleConfiguration.class).getDependencySingleArchitecture(), configurationDistinguisher).addDummySource(xcodeProviderBuilder);
    for (Attribute attribute : dependencyAttributes) {
        xcodeSupport.addDependencies(xcodeProviderBuilder, attribute);
    }
    xcodeSupport.registerActions(xcodeProviderBuilder.build());
    RuleConfiguredTargetBuilder targetBuilder = ObjcRuleClasses.ruleConfiguredTarget(ruleContext, filesToBuild.build()).addProvider(XcTestAppProvider.class, releaseBundlingSupport.xcTestAppProvider()).addProvider(XcodeProvider.class, xcodeProviderBuilder.build()).addProvider(InstrumentedFilesProvider.class, InstrumentedFilesCollector.forward(ruleContext, "binary"));
    ObjcProvider exposedObjcProvider = exposedObjcProvider(ruleContext, releaseBundlingSupport);
    if (exposedObjcProvider != null) {
        targetBuilder.addProvider(ObjcProvider.class, exposedObjcProvider);
    }
    configureTarget(targetBuilder, ruleContext, releaseBundlingSupport);
    return targetBuilder.build();
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) RuleConfiguredTargetBuilder(com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder) 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)

Example 24 with AppleConfiguration

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

the class Watch2ExtensionSupport method createBundle.

/**
   * Registers actions to create a watchOS2 extension bundle and zip it into an {@code .ipa}.
   *
   * @param ipaArtifact an .ipa artifact containing to extension bundle; this is the output artifact
   *     of the bundling
   */
void createBundle(Artifact ipaArtifact, NestedSetBuilder<Artifact> extensionFilesToBuild, ObjcProvider.Builder exposedObjcProviderBuilder) throws InterruptedException {
    ObjcProvider.Builder releaseBundlingObjcProviderBuilder = new ObjcProvider.Builder();
    releaseBundlingObjcProviderBuilder.addTransitiveAndPropagate(attributes.binaryDependencies());
    releaseBundlingObjcProviderBuilder.addAll(GENERAL_RESOURCE_FILE, attributes.resources()).addAll(GENERAL_RESOURCE_FILE, attributes.strings()).addAll(GENERAL_RESOURCE_DIR, ObjcCommon.xcodeStructuredResourceDirs(attributes.structuredResources())).addAll(BUNDLE_FILE, BundleableFile.flattenedRawResourceFiles(attributes.resources())).addAll(BUNDLE_FILE, BundleableFile.structuredRawResourceFiles(attributes.structuredResources())).addAll(STRINGS, attributes.strings());
    ObjcProvider releaseBundlingObjcProvider = releaseBundlingObjcProviderBuilder.build();
    ReleaseBundling.Builder releaseBundling = new ReleaseBundling.Builder().setIpaArtifact(ipaArtifact).setBundleId(attributes.bundleId()).setProvisioningProfile(attributes.provisioningProfile()).setProvisioningProfileAttributeName(WATCH_EXT_PROVISIONING_PROFILE_ATTR).setTargetDeviceFamilies(ImmutableSet.of(TargetDeviceFamily.WATCH)).setIntermediateArtifacts(intermediateArtifacts).setInfoPlistsFromRule(attributes.infoPlists()).setEntitlements(attributes.entitlements());
    if (attributes.isBundleIdExplicitySpecified()) {
        releaseBundling.setPrimaryBundleId(attributes.bundleId());
    } else {
        releaseBundling.setFallbackBundleId(attributes.bundleId());
    }
    AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
    ReleaseBundlingSupport releaseBundlingSupport = new ReleaseBundlingSupport(ruleContext, releaseBundlingObjcProvider, LinkedBinary.DEPENDENCIES_ONLY, ReleaseBundlingSupport.EXTENSION_BUNDLE_DIR_FORMAT, bundleName, appleConfiguration.getMinimumOsForPlatformType(PlatformType.WATCHOS), releaseBundling.build(), appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS));
    releaseBundlingSupport.registerActions(DsymOutputType.APP).addFilesToBuild(extensionFilesToBuild, Optional.of(DsymOutputType.APP)).validateResources().validateAttributes().addExportedDebugArtifacts(exposedObjcProviderBuilder, DsymOutputType.APP);
}
Also used : NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) AppleConfiguration(com.google.devtools.build.lib.rules.apple.AppleConfiguration)

Example 25 with AppleConfiguration

use of com.google.devtools.build.lib.rules.apple.AppleConfiguration 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

AppleConfiguration (com.google.devtools.build.lib.rules.apple.AppleConfiguration)25 Artifact (com.google.devtools.build.lib.actions.Artifact)12 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)10 RuleConfiguredTargetBuilder (com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder)6 Platform (com.google.devtools.build.lib.rules.apple.Platform)4 CustomCommandLine (com.google.devtools.build.lib.analysis.actions.CustomCommandLine)3 DottedVersion (com.google.devtools.build.lib.rules.apple.DottedVersion)3 PlatformType (com.google.devtools.build.lib.rules.apple.Platform.PlatformType)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 RunfilesSupport (com.google.devtools.build.lib.analysis.RunfilesSupport)2 TransitiveInfoCollection (com.google.devtools.build.lib.analysis.TransitiveInfoCollection)2 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)2 NSArray (com.dd.plist.NSArray)1 NSDictionary (com.dd.plist.NSDictionary)1 HashMultiset (com.google.common.collect.HashMultiset)1 Multiset (com.google.common.collect.Multiset)1 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)1 FilesToRunProvider (com.google.devtools.build.lib.analysis.FilesToRunProvider)1 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)1 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)1