/** * Adds any files to the given nested set builder that should be built if this application is the * top level target in a blaze invocation. * * @return this application support * @throws InterruptedException */ ReleaseBundlingSupport addFilesToBuild(NestedSetBuilder<Artifact> filesToBuild) throws InterruptedException { NestedSetBuilder<Artifact> debugSymbolBuilder = NestedSetBuilder.<Artifact>stableOrder() .addTransitive(objcProvider.get(ObjcProvider.DEBUG_SYMBOLS)); for (Artifact breakpadFile : getBreakpadFiles().values()) { filesToBuild.add(breakpadFile); } if (linkedBinary == LinkedBinary.LOCAL_AND_DEPENDENCIES && ObjcRuleClasses.objcConfiguration(ruleContext).generateDebugSymbols()) { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); debugSymbolBuilder .add(intermediateArtifacts.dsymPlist()) .add(intermediateArtifacts.dsymSymbol()) .add(intermediateArtifacts.breakpadSym()); } filesToBuild .add(ruleContext.getImplicitOutputArtifact(ReleaseBundlingSupport.IPA)) // TODO(bazel-team): Fat binaries may require some merging of these file rather than just // making them available. .addTransitive(debugSymbolBuilder.build()); return this; }
/** Registers an action to copy Swift standard library dylibs into app bundle. */ private void registerSwiftStdlibActionsIfNecessary() { if (!objcProvider.is(USES_SWIFT)) { return; } ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext); CustomCommandLine.Builder commandLine = CustomCommandLine.builder() .addPath(intermediateArtifacts.swiftFrameworksFileZip().getExecPath()) .add("--platform") .add(IosSdkCommands.swiftPlatform(objcConfiguration)) .addExecPath("--scan-executable", intermediateArtifacts.combinedArchitectureBinary()); ruleContext.registerAction( ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("SwiftStdlibCopy") .setExecutable(attributes.swiftStdlibToolWrapper()) .setCommandLine(commandLine.build()) .addOutput(intermediateArtifacts.swiftFrameworksFileZip()) .addInput(intermediateArtifacts.combinedArchitectureBinary()) // TODO(dmaclach): Adding realpath and xcrunwrapper should not be required once // https://github.com/google/bazel/issues/285 is fixed. .addInput(attributes.realpath()) .addInput(CompilationSupport.xcrunwrapper(ruleContext).getExecutable()) .build(ruleContext)); }
private void addResourceFilesToBuild( RuleContext ruleContext, ObjcProvider objcProvider, NestedSetBuilder<Artifact> filesToBuild) { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); Iterable<Xcdatamodel> xcdatamodels = Xcdatamodels.xcdatamodels(intermediateArtifacts, objcProvider.get(XCDATAMODEL)); filesToBuild.addAll(Xcdatamodel.outputZips(xcdatamodels)); for (Artifact storyboard : objcProvider.get(STORYBOARD)) { filesToBuild.add(intermediateArtifacts.compiledStoryboardZip(storyboard)); } }
/** * Returns a map of input breakpad artifacts from the CPU-specific binaries built for this * ios_application to the new output breakpad artifacts. */ private ImmutableMap<Artifact, Artifact> getBreakpadFiles() { ImmutableMap.Builder<Artifact, Artifact> results = ImmutableMap.builder(); for (Entry<String, Artifact> breakpadFile : attributes.cpuSpecificBreakpadFiles().entrySet()) { Artifact destBreakpad = intermediateArtifacts.breakpadSym(breakpadFile.getKey()); results.put(breakpadFile.getValue(), destBreakpad); } return results.build(); }
private NestedSet<Artifact> linkedBinaries() { NestedSetBuilder<Artifact> linkedBinariesBuilder = NestedSetBuilder.<Artifact>stableOrder() .addTransitive(attributes.dependentLinkedBinaries()); if (linkedBinary == LinkedBinary.LOCAL_AND_DEPENDENCIES) { linkedBinariesBuilder.add(intermediateArtifacts.strippedSingleArchitectureBinary()); } return linkedBinariesBuilder.build(); }
private Artifact registerBundleSigningActions(Artifact ipaOutput) throws InterruptedException { IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext); Artifact teamPrefixFile = intermediateArtifacts.appendExtensionForEntitlementArtifact(".team_prefix_file"); registerExtractTeamPrefixAction(teamPrefixFile); Artifact entitlementsNeedingSubstitution = attributes.entitlements(); if (entitlementsNeedingSubstitution == null) { entitlementsNeedingSubstitution = intermediateArtifacts.appendExtensionForEntitlementArtifact( ".entitlements_with_variables"); registerExtractEntitlementsAction(entitlementsNeedingSubstitution); } Artifact entitlements = intermediateArtifacts.appendExtensionForEntitlementArtifact(".entitlements"); registerEntitlementsVariableSubstitutionAction( entitlementsNeedingSubstitution, entitlements, teamPrefixFile); Artifact ipaUnsigned = ruleContext.getImplicitOutputArtifact(IPA_UNSIGNED); registerSignBundleAction(entitlements, ipaOutput, ipaUnsigned); return ipaUnsigned; }
private void registerCombineArchitecturesAction() { Artifact resultingLinkedBinary = intermediateArtifacts.combinedArchitectureBinary(); NestedSet<Artifact> linkedBinaries = linkedBinaries(); ruleContext.registerAction( ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext) .setMnemonic("ObjcCombiningArchitectures") .addTransitiveInputs(linkedBinaries) .addOutput(resultingLinkedBinary) .setExecutable(CompilationSupport.xcrunwrapper(ruleContext)) .setCommandLine( CustomCommandLine.builder() .add(ObjcRuleClasses.LIPO) .addExecPaths("-create", linkedBinaries) .addExecPath("-o", resultingLinkedBinary) .build()) .build(ruleContext)); }
/** * Creates the {@link XcTestAppProvider} that can be used if this application is used as an {@code * xctest_app}. * * @throws InterruptedException */ XcTestAppProvider xcTestAppProvider() throws InterruptedException { // We want access to #import-able things from our test rig's dependency graph, but we don't // want to link anything since that stuff is shared automatically by way of the // -bundle_loader linker flag. ObjcProvider partialObjcProvider = new ObjcProvider.Builder() .addTransitiveAndPropagate(ObjcProvider.HEADER, objcProvider) .addTransitiveAndPropagate(ObjcProvider.INCLUDE, objcProvider) .addTransitiveAndPropagate(ObjcProvider.SDK_DYLIB, objcProvider) .addTransitiveAndPropagate(ObjcProvider.SDK_FRAMEWORK, objcProvider) .addTransitiveAndPropagate(ObjcProvider.SOURCE, objcProvider) .addTransitiveAndPropagate(ObjcProvider.WEAK_SDK_FRAMEWORK, objcProvider) .addTransitiveAndPropagate(ObjcProvider.FRAMEWORK_DIR, objcProvider) .addTransitiveAndPropagate(ObjcProvider.FRAMEWORK_FILE, objcProvider) .build(); // TODO(bazel-team): Handle the FRAMEWORK_DIR key properly. We probably want to add it to // framework search paths, but not actually link it with the -framework flag. return new XcTestAppProvider( intermediateArtifacts.combinedArchitectureBinary(), ruleContext.getImplicitOutputArtifact(IPA), partialObjcProvider); }