aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
diff options
context:
space:
mode:
authorGravatar Chris Parsons <cparsons@google.com>2016-01-14 22:48:37 +0000
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2016-01-15 09:24:32 +0000
commit2fa25fd7e6251f78860637df7db3e17893e81b5c (patch)
tree46fb7c069747073c7e7bf3add3c7e9f6bdbda98e /src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
parentff66c192d70c6001797369a555cc1786594e10a2 (diff)
Basic implementation for the build flag apple_bitcode, to propagate bitcode build flags to clang based on a specified mode.
This handles the very basic case of objc_* rule compilation which does not depend on non-objc targets. Until we support passing bitcode flags for cc compilation, such builds will be broken if bitcode is enabled (one may be able to get around this by propagating the appropriate bitcode flag to --copt, but we'll want to do this as part of the apple_bitcode flag). Additionally, we will want to use apple_bitcode to pass bitcode-enabling properties to generated xcode projects. -- MOS_MIGRATED_REVID=112192290
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
index b48c5224f3..fbba034669 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/apple/AppleCommandLineOptions.java
@@ -15,12 +15,14 @@
package com.google.devtools.build.lib.rules.apple;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
import com.google.common.collect.Multimap;
import com.google.devtools.build.lib.Constants;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.DefaultLabelConverter;
import com.google.devtools.build.lib.analysis.config.FragmentOptions;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.common.options.Converters.CommaSeparatedOptionListConverter;
+import com.google.devtools.common.options.EnumConverter;
import com.google.devtools.common.options.Option;
import java.util.List;
@@ -99,6 +101,15 @@ public class AppleCommandLineOptions extends FragmentOptions {
}
}
+ @Option(name = "apple_bitcode",
+ converter = AppleBitcodeMode.Converter.class,
+ // TODO(blaze-team): Default to embedded_markers when fully implemented.
+ defaultValue = "none",
+ category = "flags",
+ help = "Specify the Apple bitcode mode for compile steps. "
+ + "Values: 'none', 'embedded_markers', 'embedded'.")
+ public AppleBitcodeMode appleBitcodeMode;
+
/** Converter for {@code --xcode_version_config}. */
public static class XcodeVersionConfigConverter extends DefaultLabelConverter {
public XcodeVersionConfigConverter() {
@@ -121,6 +132,61 @@ public class AppleCommandLineOptions extends FragmentOptions {
labelMap.put("default_provisioning_profile", defaultProvisioningProfile);
}
}
+
+ /**
+ * Represents the Apple Bitcode mode for compilation steps.
+ *
+ * <p>Bitcode is an intermediate representation of a compiled program. For many platforms,
+ * Apple requires app submissions to contain bitcode in order to be uploaded to the app store.
+ *
+ * <p>This is a build-wide value, as bitcode mode needs to be consistent among a target and
+ * its compiled dependencies.
+ */
+ public enum AppleBitcodeMode {
+
+ /**
+ * Do not compile bitcode.
+ */
+ NONE("none"),
+ /**
+ * Compile the minimal set of bitcode markers. This is often the best option for
+ * developer/debug builds.
+ */
+ EMBEDDED_MARKERS("embedded_markers", "-fembed-bitcode-marker"),
+ /**
+ * Fully embed bitcode in compiled files. This is often the best option for release builds.
+ */
+ EMBEDDED("embedded", "-fembed-bitcode");
+
+ private final String mode;
+ private final ImmutableList<String> compilerFlags;
+
+ private AppleBitcodeMode(String mode, String... compilerFlags) {
+ this.mode = mode;
+ this.compilerFlags = ImmutableList.copyOf(compilerFlags);
+ }
+
+ @Override
+ public String toString() {
+ return mode;
+ }
+
+ /**
+ * Returns the flags that should be added to compile actions to use this bitcode setting.
+ */
+ public ImmutableList<String> getCompilerFlags() {
+ return compilerFlags;
+ }
+
+ /**
+ * Converts to {@link AppleBitcodeMode}.
+ */
+ public static class Converter extends EnumConverter<AppleBitcodeMode> {
+ public Converter() {
+ super(AppleBitcodeMode.class, "apple bitcode mode");
+ }
+ }
+ }
@Override
public FragmentOptions getHost(boolean fallback) {
@@ -128,6 +194,7 @@ public class AppleCommandLineOptions extends FragmentOptions {
// Set options needed in the host configuration.
host.xcodeVersion = xcodeVersion;
+ host.appleBitcodeMode = appleBitcodeMode;
return host;
}