aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/objc
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2017-01-05 20:14:07 +0000
committerGravatar John Cater <jcater@google.com>2017-01-05 21:10:49 +0000
commitbf51766b1ec67159b1c55889ac55a2e37faeeb02 (patch)
treead8b2a95bff1a534077396e1d14afcc10d142ad9 /src/main/java/com/google/devtools/build/lib/rules/objc
parentcae11a765439577061f51cb8f46d34ae59c882af (diff)
Add a "dylib" binary type to apple_binary, and deprecate apple_dynamic_library
-- PiperOrigin-RevId: 143694257 MOS_MIGRATED_REVID=143694257
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/objc')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java46
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinaryRule.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryRule.java10
3 files changed, 46 insertions, 18 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
index c20133319a..4d789bbac6 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinary.java
@@ -47,9 +47,37 @@ import java.util.Set;
*/
public class AppleBinary implements RuleConfiguredTargetFactory {
- // TODO(b/33077308): Expand into DYLIB when apple_dynamic_library is removed.
+ /**
+ * Type of linked binary that apple_binary may create.
+ */
enum BinaryType {
- EXECUTABLE, BUNDLE;
+
+ /**
+ * Binaries that can be loaded by other binaries at runtime, and which can't be
+ * directly executed by the operating system. When linking, a bundle_loader binary may be passed
+ * which signals the linker on where to look for unimplemented symbols, basically declaring that
+ * the bundle should be loaded by that binary. Bundle binaries are usually found in Plugins, and
+ * one common use case is tests. Tests are bundled into an .xctest bundle which contains the
+ * test binary along with required resources. The test bundle is then loaded and run during
+ * test execution.
+ */
+ BUNDLE,
+
+ /**
+ * Binaries that can be run directly by the operating system. They implement the main method
+ * that is the entry point to the program. In Apple apps, they are usually distributed in .app
+ * bundles, which are directories that contain the executable along with required resources to
+ * run.
+ */
+ EXECUTABLE,
+
+ /**
+ * Binaries meant to be loaded at load time (when the operating system is loading the binary
+ * into memory), which cannot be unloaded. They are usually distributed in frameworks,
+ * which are .framework bundles that contain the dylib as well as well as required resources to
+ * run.
+ */
+ DYLIB;
@Override
public String toString() {
@@ -145,11 +173,10 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
if (getBinaryType(ruleContext) == BinaryType.EXECUTABLE) {
targetBuilder.addProvider(BundleLoaderProvider.class, new BundleLoaderProvider(objcProvider));
}
-
return targetBuilder.build();
}
- private ExtraLinkArgs getExtraLinkArgs(RuleContext ruleContext) throws RuleErrorException {
+ private static ExtraLinkArgs getExtraLinkArgs(RuleContext ruleContext) throws RuleErrorException {
BinaryType binaryType = getBinaryType(ruleContext);
ImmutableList.Builder<String> extraLinkArgs = new ImmutableList.Builder<>();
@@ -164,8 +191,7 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
}
switch(binaryType) {
- case EXECUTABLE: break;
- case BUNDLE: {
+ case BUNDLE:
extraLinkArgs.add("-bundle");
if (didProvideBundleLoader) {
Artifact bundleLoader =
@@ -173,13 +199,17 @@ public class AppleBinary implements RuleConfiguredTargetFactory {
extraLinkArgs.add("-bundle_loader " + bundleLoader.getExecPathString());
}
break;
- }
+ case DYLIB:
+ extraLinkArgs.add("-dynamiclib");
+ break;
+ case EXECUTABLE:
+ break;
}
return new ExtraLinkArgs(extraLinkArgs.build());
}
- private Iterable<Artifact> getExtraLinkInputs(RuleContext ruleContext) {
+ private static Iterable<Artifact> getExtraLinkInputs(RuleContext ruleContext) {
return Optional.fromNullable(
ruleContext.getPrerequisiteArtifact(AppleBinaryRule.BUNDLE_LOADER_ATTR, TARGET))
.asSet();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinaryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinaryRule.java
index 371ed449c7..4c330a826b 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinaryRule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleBinaryRule.java
@@ -91,11 +91,15 @@ public class AppleBinaryRule implements RuleDefinition {
<li>
<code>executable</code> (default): the output binary is an executable and must implement
the main() function.
- </li>
- <li>
+ </li><li>
<code>bundle</code>: the output binary is a loadable bundle that may be loaded at
runtime. When building a bundle, you may also pass a bundle_loader binary that contains
symbols referenced but not implemented in the bundle.
+ </li><li>
+ <code>dylib</code>: the output binary is meant to be loaded at load time (when the
+ operating system is loading the binary into memory) and cannot be unloaded. Dylibs
+ are usually consumed in frameworks, which are .framework bundles that contain the
+ dylib as well as well as required resources to run.
</li>
</ul>
<!-- #END_BLAZE_RULE.ATTRIBUTE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryRule.java b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryRule.java
index 123d300b60..8e95d8c519 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryRule.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/objc/AppleDynamicLibraryRule.java
@@ -27,7 +27,7 @@ import com.google.devtools.build.lib.rules.apple.AppleConfiguration;
/**
* Rule definition for apple_dynamic_library.
*/
-// TODO(b/33077308): Deprecate this rule for apple_binary with attribute changes.
+// TODO(b/33077308): Remove this rule.
public class AppleDynamicLibraryRule implements RuleDefinition {
/**
@@ -69,13 +69,7 @@ public class AppleDynamicLibraryRule implements RuleDefinition {
/*<!-- #BLAZE_RULE (NAME = apple_dynamic_library, TYPE = BINARY, FAMILY = Objective-C) -->
-<p>This rule produces single- or multi-architecture ("fat") Apple dynamic libraries,
-typically used in creating dynamic Apple Frameworks for distribution and re-use in multiple
-extensions or applications.</p>
-
-<p>The <code>lipo</code> tool is used to combine files of multiple architectures; a build flag
-controls which architectures are targeted. The build flag examined depends on the
-<code>platform_type</code> attribute for this rule (and is described in its documentation).</p
+<p> This rule is deprecated. Please use apple_binary with binary_type = "dylib" instead. </p>
${IMPLICIT_OUTPUTS}