Skip to content

Commit

Permalink
Move Settings enum and command line prefix constant to StarlarkDefine…
Browse files Browse the repository at this point in the history
…dConfigTransition so we can use it here and in FunctionTransitionUtil going forward

work towards #11128

PiperOrigin-RevId: 350588700
  • Loading branch information
juliexxia authored and copybara-github committed Jan 7, 2021
1 parent c228558 commit 2039c75
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> inputs;
private final List<String> outputs;
private final Location location;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/google/devtools/build/lib/query2/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2039c75

Please sign in to comment.