From 2039c75069218260c9115928774d1b7ab9e91a9d Mon Sep 17 00:00:00 2001 From: juliexxia Date: Thu, 7 Jan 2021 10:20:02 -0800 Subject: [PATCH] Move Settings enum and command line prefix constant to StarlarkDefinedConfigTransition so we can use it here and in FunctionTransitionUtil going forward work towards #11128 PiperOrigin-RevId: 350588700 --- .../com/google/devtools/build/lib/analysis/BUILD | 1 - .../config/StarlarkDefinedConfigTransition.java | 15 +++++++++++++++ .../analysis/starlark/FunctionTransitionUtil.java | 3 +-- .../lib/analysis/starlark/StarlarkTransition.java | 13 ++----------- .../com/google/devtools/build/lib/query2/BUILD | 2 +- .../cquery/StarlarkOutputFormatterCallback.java | 2 +- .../lib/rules/config/ConfigGlobalLibrary.java | 4 ++-- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/BUILD b/src/main/java/com/google/devtools/build/lib/analysis/BUILD index d52424e0ecda11..598d7545af5eba 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/BUILD +++ b/src/main/java/com/google/devtools/build/lib/analysis/BUILD @@ -2094,7 +2094,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/util", "//src/main/java/com/google/devtools/common/options", "//src/main/java/net/starlark/java/eval", - "//src/main/java/net/starlark/java/syntax", "//third_party:guava", ], ) diff --git a/src/main/java/com/google/devtools/build/lib/analysis/config/StarlarkDefinedConfigTransition.java b/src/main/java/com/google/devtools/build/lib/analysis/config/StarlarkDefinedConfigTransition.java index 1cf7e729adce1d..caf5a40238b009 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/config/StarlarkDefinedConfigTransition.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/config/StarlarkDefinedConfigTransition.java @@ -44,6 +44,21 @@ */ public abstract class StarlarkDefinedConfigTransition implements ConfigurationTransitionApi { + public static final String COMMAND_LINE_OPTION_PREFIX = "//command_line_option:"; + + /** + * The two groups of build settings that are relevant for a {@link + * StarlarkDefinedConfigTransition} + */ + public enum Settings { + /** Build settings that are read by a {@link StarlarkDefinedConfigTransition} */ + INPUTS, + /** Build settings that are written by a {@link StarlarkDefinedConfigTransition} */ + OUTPUTS, + /** Build settings that are read and/or written by a {@link StarlarkDefinedConfigTransition } */ + INPUTS_AND_OUTPUTS + } + private final List inputs; private final List outputs; private final Location location; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java index bb3b0b294ad913..f68f9acc28d261 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/FunctionTransitionUtil.java @@ -14,6 +14,7 @@ package com.google.devtools.build.lib.analysis.starlark; +import static com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.COMMAND_LINE_OPTION_PREFIX; import static java.util.stream.Collectors.joining; import com.google.common.base.Joiner; @@ -53,8 +54,6 @@ */ public class FunctionTransitionUtil { - public static final String COMMAND_LINE_OPTION_PREFIX = "//command_line_option:"; - // The length of the hash of the config tacked onto the end of the output path. // Limited for ergonomics and MAX_PATH reasons. private static final int HASH_LENGTH = 12; diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java index 27e979b6603d16..0dfb587b462a1d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkTransition.java @@ -13,7 +13,7 @@ // limitations under the License. package com.google.devtools.build.lib.analysis.starlark; -import static com.google.devtools.build.lib.analysis.starlark.FunctionTransitionUtil.COMMAND_LINE_OPTION_PREFIX; +import static com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.COMMAND_LINE_OPTION_PREFIX; import static com.google.devtools.build.lib.packages.RuleClass.Builder.STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME; import com.google.common.base.Preconditions; @@ -25,6 +25,7 @@ import com.google.common.collect.Sets; import com.google.devtools.build.lib.analysis.config.BuildOptions; import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition; +import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.Settings; import com.google.devtools.build.lib.analysis.config.transitions.ConfigurationTransition; import com.google.devtools.build.lib.analysis.starlark.FunctionTransitionUtil.OptionInfo; import com.google.devtools.build.lib.cmdline.Label; @@ -59,16 +60,6 @@ public abstract class StarlarkTransition implements ConfigurationTransition { public static final String ALIAS_RULE_NAME = "alias"; public static final String ALIAS_ACTUAL_ATTRIBUTE_NAME = "actual"; - /** The two groups of build settings that are relevant for a {@link StarlarkTransition} */ - public enum Settings { - /** Build settings that are read by a {@link StarlarkTransition} */ - INPUTS, - /** Build settings that are written by a {@link StarlarkTransition} */ - OUTPUTS, - /** Build settings that are read and/or written by a {@link StarlarkTransition } */ - INPUTS_AND_OUTPUTS - } - private final StarlarkDefinedConfigTransition starlarkDefinedConfigTransition; public StarlarkTransition(StarlarkDefinedConfigTransition starlarkDefinedConfigTransition) { diff --git a/src/main/java/com/google/devtools/build/lib/query2/BUILD b/src/main/java/com/google/devtools/build/lib/query2/BUILD index 735cbfe850cf35..98c97cc527265f 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/BUILD +++ b/src/main/java/com/google/devtools/build/lib/query2/BUILD @@ -34,6 +34,7 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:config/config_matching_provider", "//src/main/java/com/google/devtools/build/lib/analysis:config/core_options", "//src/main/java/com/google/devtools/build/lib/analysis:config/fragment_options", + "//src/main/java/com/google/devtools/build/lib/analysis:config/starlark_defined_config_transition", "//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/configuration_transition", "//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/no_transition", "//src/main/java/com/google/devtools/build/lib/analysis:config/transitions/null_transition", @@ -44,7 +45,6 @@ java_library( "//src/main/java/com/google/devtools/build/lib/analysis:inconsistent_aspect_order_exception", "//src/main/java/com/google/devtools/build/lib/analysis:platform_configuration", "//src/main/java/com/google/devtools/build/lib/analysis:required_config_fragments_provider", - "//src/main/java/com/google/devtools/build/lib/analysis:starlark/function_transition_util", "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_collection", "//src/main/java/com/google/devtools/build/lib/analysis:toolchain_context", "//src/main/java/com/google/devtools/build/lib/buildeventstream", diff --git a/src/main/java/com/google/devtools/build/lib/query2/cquery/StarlarkOutputFormatterCallback.java b/src/main/java/com/google/devtools/build/lib/query2/cquery/StarlarkOutputFormatterCallback.java index f611bf48d1e542..d2c8e8a2886884 100644 --- a/src/main/java/com/google/devtools/build/lib/query2/cquery/StarlarkOutputFormatterCallback.java +++ b/src/main/java/com/google/devtools/build/lib/query2/cquery/StarlarkOutputFormatterCallback.java @@ -14,7 +14,7 @@ package com.google.devtools.build.lib.query2.cquery; -import static com.google.devtools.build.lib.analysis.starlark.FunctionTransitionUtil.COMMAND_LINE_OPTION_PREFIX; +import static com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.COMMAND_LINE_OPTION_PREFIX; import com.google.common.collect.ImmutableMap; import com.google.devtools.build.lib.analysis.ConfiguredTarget; diff --git a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigGlobalLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigGlobalLibrary.java index c8d8a444e683a1..8bd9d166656b2b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/config/ConfigGlobalLibrary.java +++ b/src/main/java/com/google/devtools/build/lib/rules/config/ConfigGlobalLibrary.java @@ -14,11 +14,11 @@ package com.google.devtools.build.lib.rules.config; -import static com.google.devtools.build.lib.analysis.starlark.FunctionTransitionUtil.COMMAND_LINE_OPTION_PREFIX; +import static com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.COMMAND_LINE_OPTION_PREFIX; import com.google.common.collect.Sets; import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition; -import com.google.devtools.build.lib.analysis.starlark.StarlarkTransition.Settings; +import com.google.devtools.build.lib.analysis.config.StarlarkDefinedConfigTransition.Settings; import com.google.devtools.build.lib.cmdline.Label; import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions; import com.google.devtools.build.lib.starlarkbuildapi.config.ConfigGlobalLibraryApi;