use of com.google.devtools.build.lib.rules.apple.AppleConfiguration in project bazel by bazelbuild.
the class ReleaseBundlingSupport method registerPostProcessAndSigningActions.
/**
* Registers all actions necessary to create a processed and signed IPA from the initial merged
* IPA.
*
* <p>Includes user-provided actions to process IPA contents (via {@code ipa_post_processor}),
* and signing actions if the IPA is being built for device architectures. If signing is necessary
* also includes entitlements generation and processing actions.
*
* <p>Note that multiple "actions" on the IPA contents may be run in a single blaze action to
* avoid excessive zipping/unzipping of IPA contents.
*/
private void registerPostProcessAndSigningActions() {
Artifact processedIpa = releaseBundling.getIpaArtifact();
Artifact unprocessedIpa = intermediateArtifacts.unprocessedIpa();
NestedSetBuilder<Artifact> inputs = NestedSetBuilder.<Artifact>stableOrder().add(unprocessedIpa);
String actionCommandLine = "set -e && " + "t=$(mktemp -d \"${TMPDIR:-/tmp}/signing_intermediate.XXXXXX\") && " + "trap \"rm -rf ${t}\" EXIT && " + // Get an absolute path since we need to cd into the temp directory for zip.
"signed_ipa=${PWD}/" + processedIpa.getShellEscapedExecPathString() + " && " + "/usr/bin/unzip -qq " + unprocessedIpa.getShellEscapedExecPathString() + " -d ${t} && ";
FilesToRunProvider processor = attributes.ipaPostProcessor();
if (processor != null) {
actionCommandLine += processor.getExecutable().getShellEscapedExecPathString() + " ${t} && ";
}
if (platform.isDevice()) {
actionCommandLine += deviceSigningCommandLine();
registerEntitlementsActions();
inputs.add(releaseBundling.getProvisioningProfile()).add(intermediateArtifacts.entitlements());
} else {
actionCommandLine += simulatorSigningCommandLine();
}
actionCommandLine += "cd ${t} && /usr/bin/zip -q -r \"${signed_ipa}\" .";
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
SpawnAction.Builder processAction = ObjcRuleClasses.spawnBashOnDarwinActionBuilder(actionCommandLine).setEnvironment(ObjcRuleClasses.appleToolchainEnvironment(appleConfiguration, platform)).setMnemonic("ObjcProcessIpa").setProgressMessage("Processing iOS IPA: " + ruleContext.getLabel()).disableSandboxing().addTransitiveInputs(inputs.build()).addOutput(processedIpa);
if (processor != null) {
processAction.addTool(processor);
}
ruleContext.registerAction(processAction.build(ruleContext));
}
use of com.google.devtools.build.lib.rules.apple.AppleConfiguration in project bazel by bazelbuild.
the class ReleaseBundlingSupport method bundling.
private Bundling bundling(RuleContext ruleContext, ObjcProvider objcProvider, String bundleDirFormat, String bundleName, DottedVersion minimumOsVersion) {
ImmutableList<BundleableFile> extraBundleFiles;
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
if (platform.isDevice()) {
extraBundleFiles = ImmutableList.of(new BundleableFile(releaseBundling.getProvisioningProfile(), PROVISIONING_PROFILE_BUNDLE_FILE));
} else {
extraBundleFiles = ImmutableList.of();
}
Bundling.Builder bundling = new Builder().setName(bundleName).setExecutableName(bundleName).setArchitecture(appleConfiguration.getDependencySingleArchitecture()).setBundleDirFormat(bundleDirFormat).addExtraBundleFiles(extraBundleFiles).setObjcProvider(objcProvider).setIntermediateArtifacts(intermediateArtifacts).setPrimaryBundleId(releaseBundling.getPrimaryBundleId()).setFallbackBundleId(releaseBundling.getFallbackBundleId()).setMinimumOsVersion(minimumOsVersion).setArtifactPrefix(releaseBundling.getArtifactPrefix()).setTargetDeviceFamilies(releaseBundling.getTargetDeviceFamilies());
// Add plists from rule first.
if (releaseBundling.getInfoPlistsFromRule() != null) {
bundling.addInfoplistInputs(releaseBundling.getInfoPlistsFromRule());
} else {
bundling.addInfoplistInputFromRule(ruleContext);
}
// Add generated plists next so that generated values can override the default values in the
// plists from rule.
bundling.setAutomaticEntriesInfoplistInput(getGeneratedAutomaticPlist()).addInfoplistInput(getGeneratedVersionPlist()).addInfoplistInput(getGeneratedEnvironmentPlist()).addInfoplistInputs(releaseBundling.getInfoplistInputs());
if (releaseBundling.getLaunchStoryboard() != null) {
bundling.addInfoplistInput(getLaunchStoryboardPlist());
}
return bundling.build();
}
use of com.google.devtools.build.lib.rules.apple.AppleConfiguration in project bazel by bazelbuild.
the class TestSupport method getExtraProviders.
/**
* Returns any additional providers that need to be exported to the rule context to the passed
* builder.
*/
public Iterable<SkylarkClassObject> getExtraProviders() {
IosDeviceProvider deviceProvider = (IosDeviceProvider) ruleContext.getPrerequisite(IosTest.TARGET_DEVICE, Mode.TARGET, IosDeviceProvider.SKYLARK_CONSTRUCTOR.getKey());
DottedVersion xcodeVersion = deviceProvider.getXcodeVersion();
AppleConfiguration configuration = ruleContext.getFragment(AppleConfiguration.class);
ImmutableMap.Builder<String, String> envBuilder = ImmutableMap.builder();
if (xcodeVersion != null) {
envBuilder.putAll(configuration.getXcodeVersionEnv(xcodeVersion));
}
if (ruleContext.getConfiguration().isCodeCoverageEnabled()) {
envBuilder.put("COVERAGE_GCOV_PATH", ruleContext.getHostPrerequisiteArtifact(IosTest.OBJC_GCOV_ATTR).getExecPathString());
envBuilder.put("APPLE_COVERAGE", "1");
}
return ImmutableList.<SkylarkClassObject>of(new TestEnvironmentProvider(envBuilder.build()));
}
use of com.google.devtools.build.lib.rules.apple.AppleConfiguration in project bazel by bazelbuild.
the class WatchApplicationSupport method registerActions.
/**
* Registers actions to copy WatchKit stub binary at
* $(SDK_ROOT)/Library/Application Support/WatchKit/WK as bundle binary and as stub resource.
*
* For example, for a bundle named "Foo.app", the contents will be,
* - Foo.app/Foo (WK stub as binary)
* - Foo.app/_WatchKitStub/WK (WK stub as resource)
*/
private void registerActions() {
Artifact watchKitStubZip = watchKitStubZip();
String workingDirectory = watchKitStubZip.getExecPathString().substring(0, watchKitStubZip.getExecPathString().lastIndexOf('/'));
String watchKitStubBinaryPath = workingDirectory + "/" + bundleName;
String watchKitStubResourcePath = workingDirectory + "/_WatchKitStub";
ImmutableList<String> command = ImmutableList.of(// 1. Copy WK stub as binary
String.format("cp -f %s %s", WatchUtils.WATCH_KIT_STUB_PATH, watchKitStubBinaryPath), "&&", // 2. Copy WK stub as bundle resource.
"mkdir -p " + watchKitStubResourcePath, "&&", String.format("cp -f %s %s", WatchUtils.WATCH_KIT_STUB_PATH, watchKitStubResourcePath), // 3. Zip them.
"&&", "cd " + workingDirectory, "&&", String.format("/usr/bin/zip -q -r -0 %s %s", watchKitStubZip.getFilename(), Joiner.on(" ").join(ImmutableList.of("_WatchKitStub", bundleName))));
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(appleConfiguration, appleConfiguration.getMultiArchPlatform(PlatformType.WATCHOS)).setProgressMessage("Copying WatchKit binary and stub resource: " + ruleContext.getLabel()).setShellCommand(ImmutableList.of("/bin/bash", "-c", Joiner.on(" ").join(command))).addOutput(watchKitStubZip).build(ruleContext));
}
use of com.google.devtools.build.lib.rules.apple.AppleConfiguration in project bazel by bazelbuild.
the class ObjcBundleLibrary method bundling.
private Bundling bundling(RuleContext ruleContext, ObjcCommon common) {
IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
AppleConfiguration appleConfiguration = ruleContext.getFragment(AppleConfiguration.class);
ImmutableSet<TargetDeviceFamily> families = null;
List<String> rawFamilies = ruleContext.attributes().get(FAMILIES_ATTR, Type.STRING_LIST);
try {
families = ImmutableSet.copyOf(TargetDeviceFamily.fromNamesInRule(rawFamilies));
} catch (InvalidFamilyNameException | RepeatedFamilyNameException e) {
families = ImmutableSet.of();
}
if (families.isEmpty()) {
ruleContext.attributeError(FAMILIES_ATTR, ReleaseBundling.INVALID_FAMILIES_ERROR);
}
return new Bundling.Builder().setName(ruleContext.getLabel().getName()).setArchitecture(appleConfiguration.getIosCpu()).setBundleDirFormat("%s.bundle").setObjcProvider(common.getObjcProvider()).addInfoplistInputFromRule(ruleContext).setIntermediateArtifacts(intermediateArtifacts).setMinimumOsVersion(appleConfiguration.getMinimumOsForPlatformType(PlatformType.IOS)).setTargetDeviceFamilies(families).build();
}
Aggregations