Just symlink instead of running 'lipo' on a single-architecture binary
MOS_MIGRATED_REVID=146847283
package com.google.devtools.build.lib.rules.objc;
+import com.google.common.collect.Iterables;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.RuleContext;
import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
+import com.google.devtools.build.lib.analysis.actions.SymlinkAction;
import com.google.devtools.build.lib.collect.nestedset.NestedSet;
import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
import com.google.devtools.build.lib.rules.apple.Platform;
@@ -36,11 +38,14 @@ public class LipoSupport {
* Registers an action to invoke "lipo" on all artifacts in {@code inputBinaries} to create the
* {@code outputBinary} multi-architecture artifact, built for platform {@code platform}.
*
+ * <p>If there is only one input binary given, since "lipo" is an expensive action, this will only
+ * symlink the output location to the input binary.
+ *
* @return this object
*/
public LipoSupport registerCombineArchitecturesAction(NestedSet<Artifact> inputBinaries,
Artifact outputBinary, Platform platform) {
-
+ if (inputBinaries.toList().size() > 1) {
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(
ruleContext.getFragment(AppleConfiguration.class), platform)
.setMnemonic("ObjcCombiningArchitectures")
@@ -53,7 +58,13 @@ public class LipoSupport {
.addExecPath("-o", outputBinary)
.build())
.build(ruleContext));
-
+ } else {
+ ruleContext.registerAction(new SymlinkAction(
+ ruleContext.getActionOwner(),
+ Iterables.getOnlyElement(inputBinaries),
+ outputBinary,
+ "Symlinking single-architecture binary"));
+ }
return this;
}
}
