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));
}
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));
}
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();
}
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);
}
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();
}
Aggregations