From 821ee9b59893929dc645fb8783c3bf2e4b3fbb2a Mon Sep 17 00:00:00 2001 From: Lukacs Berki Date: Fri, 17 Feb 2017 12:15:18 +0000 Subject: [PATCH] Remove DynamicModeFlag and thus fix crash caused by passing --dynamic_mode=auto on the command line. -- PiperOrigin-RevId: 147824992 MOS_MIGRATED_REVID=147824992 --- .../rules/android/AndroidConfiguration.java | 4 ++-- .../build/lib/rules/cpp/CppConfiguration.java | 8 +------- .../build/lib/rules/cpp/CppOptions.java | 19 +++++-------------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java index b57165e9fe681a..b6923579cfaf01 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java @@ -30,8 +30,8 @@ import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.packages.Attribute.SplitTransition; +import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode; import com.google.devtools.build.lib.rules.cpp.CppOptions.DynamicModeConverter; -import com.google.devtools.build.lib.rules.cpp.CppOptions.DynamicModeFlag; import com.google.devtools.common.options.Converter; import com.google.devtools.common.options.Converters; import com.google.devtools.common.options.EnumConverter; @@ -250,7 +250,7 @@ public static class Options extends FragmentOptions { + "whether to link dynamically. 'fully' means all libraries will be linked " + "dynamically. 'off' means that all libraries will be linked in mostly static mode." ) - public DynamicModeFlag dynamicMode; + public DynamicMode dynamicMode; // Label of filegroup combining all Android tools used as implicit dependencies of // android_* rules diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java index c0a7f69c31338d..9441fbe6fd2294 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppConfiguration.java @@ -384,13 +384,7 @@ protected CppConfiguration(CppConfigurationParameters params) // TODO(bazel-team): implement dynamic linking with LIPO this.dynamicMode = DynamicMode.OFF; } else { - switch (cppOptions.dynamicMode) { - case DEFAULT: - this.dynamicMode = DynamicMode.DEFAULT; break; - case OFF: this.dynamicMode = DynamicMode.OFF; break; - case FULLY: this.dynamicMode = DynamicMode.FULLY; break; - default: throw new IllegalStateException("Invalid dynamicMode."); - } + this.dynamicMode = cppOptions.dynamicMode; } this.fdoZip = params.fdoZip; diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java index 0db208b98fd134..fa8787a7860abb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java @@ -25,6 +25,7 @@ import com.google.devtools.build.lib.analysis.config.PerLabelOptions; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.cmdline.LabelSyntaxException; +import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.LibcTop; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.StripMode; import com.google.devtools.build.lib.util.OptionsUtils; @@ -69,21 +70,11 @@ public String getTypeDescription() { } /** - * The same as DynamicMode, but on command-line we also allow AUTO. + * Converter for {@link DynamicMode} */ - public enum DynamicModeFlag { - OFF, - DEFAULT, - FULLY, - AUTO - } - - /** - * Converter for DynamicModeFlag - */ - public static class DynamicModeConverter extends EnumConverter { + public static class DynamicModeConverter extends EnumConverter { public DynamicModeConverter() { - super(DynamicModeFlag.class, "dynamic mode"); + super(DynamicMode.class, "dynamic mode"); } } @@ -226,7 +217,7 @@ public LipoModeConverter() { + "will be linked dynamically. 'off' means that all libraries will be linked " + "in mostly static mode." ) - public DynamicModeFlag dynamicMode; + public DynamicMode dynamicMode; @Option( name = "experimental_link_compile_output_separately",