Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 655280643
Change-Id: Id777c8e6ebbdf8496a21aa9afc4523e9bf98d318
  • Loading branch information
ahumesky authored and copybara-github committed Jul 23, 2024
1 parent 6040533 commit 0803ad3
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableCollection;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
Expand Down Expand Up @@ -95,7 +94,6 @@ public static BuildOptions of(
}
return builder
.addStarlarkOptions(labelizeStarlarkOptions(provider.getStarlarkOptions()))
.addUserOptions(provider.getUserOptions())
.build();
}

Expand Down Expand Up @@ -213,14 +211,6 @@ public ImmutableMap<Label, Object> getStarlarkOptions() {
return starlarkOptionsMap;
}

/**
* Returns the list of options that were parsed from either a user blazerc file or the command
* line.
*/
public ImmutableList<String> getUserOptions() {
return userOptions;
}

/**
* Creates a copy of the BuildOptions object that contains copies of the FragmentOptions and
* Starlark options.
Expand All @@ -236,8 +226,7 @@ public BuildOptions clone() {
e -> e.getValue().clone()));
// Note that this assumes that starlark option values are immutable.
ImmutableMap<Label, Object> starlarkOptions = ImmutableMap.copyOf(starlarkOptionsMap);
ImmutableList<String> userOptions = this.userOptions;
return new BuildOptions(nativeOptions, starlarkOptions, userOptions);
return new BuildOptions(nativeOptions, starlarkOptions);
}

@Override
Expand All @@ -258,13 +247,9 @@ public int hashCode() {

/** Maps options class definitions to FragmentOptions objects. */
private final ImmutableMap<Class<? extends FragmentOptions>, FragmentOptions> fragmentOptionsMap;

/** Maps Starlark options names to Starlark options values. */
private final ImmutableMap<Label, Object> starlarkOptionsMap;

/** The list of options that were parsed from either a user blazerc file or the command line. */
private final ImmutableList<String> userOptions;

// Lazily initialized both for performance and correctness - BuildOptions instances may be mutated
// after construction but before consumption. Access via checksum() to ensure initialization. This
// field is volatile as per https://errorprone.info/bugpattern/DoubleCheckedLocking, which
Expand All @@ -273,11 +258,9 @@ public int hashCode() {

private BuildOptions(
ImmutableMap<Class<? extends FragmentOptions>, FragmentOptions> fragmentOptionsMap,
ImmutableMap<Label, Object> starlarkOptionsMap,
ImmutableList<String> userOptions) {
ImmutableMap<Label, Object> starlarkOptionsMap) {
this.fragmentOptionsMap = fragmentOptionsMap;
this.starlarkOptionsMap = starlarkOptionsMap;
this.userOptions = userOptions;
}

/**
Expand Down Expand Up @@ -318,11 +301,6 @@ public BuildOptions applyParsingResult(OptionsParsingResult parsingResult) {
builder.addStarlarkOption(starlarkOption.getKey(), starlarkOption.getValue());
}

// And update options set in user blazerc or command line
builder.userOptions.addAll(
parsingResult.getUserOptions() == null
? ImmutableList.of()
: parsingResult.getUserOptions());
return builder.build();
}

Expand Down Expand Up @@ -413,7 +391,6 @@ public Builder merge(BuildOptions options) {
this.addFragmentOptions(fragment);
}
this.addStarlarkOptions(options.getStarlarkOptions());
this.addUserOptions(options.getUserOptions());
return this;
}

Expand Down Expand Up @@ -470,23 +447,15 @@ public Builder removeStarlarkOption(Label key) {
return this;
}

@CanIgnoreReturnValue
public Builder addUserOptions(ImmutableList<String> options) {
userOptions.addAll(options);
return this;
}

public BuildOptions build() {
return new BuildOptions(
ImmutableSortedMap.copyOf(fragmentOptions, LEXICAL_FRAGMENT_OPTIONS_COMPARATOR),
ImmutableSortedMap.copyOf(starlarkOptions),
userOptions.build());
ImmutableSortedMap.copyOf(starlarkOptions));
}

private final Map<Class<? extends FragmentOptions>, FragmentOptions> fragmentOptions =
new HashMap<>();
private final Map<Label, Object> starlarkOptions = new HashMap<>();
private final ImmutableList.Builder<String> userOptions = new ImmutableList.Builder<>();

private Builder() {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@
import javax.annotation.Nullable;

/**
* A BuildRequest represents a single invocation of the build tool by a user. A request specifies a
* list of targets to be built for a single configuration, a pair of output/error streams, and
* additional options such as --keep_going, --jobs, etc.
* A BuildRequest represents a single invocation of the build tool by a user.
* A request specifies a list of targets to be built for a single
* configuration, a pair of output/error streams, and additional options such
* as --keep_going, --jobs, etc.
*/
public class BuildRequest implements OptionsProvider {
public static final String VALIDATION_ASPECT_NAME = "ValidateTarget";
Expand Down Expand Up @@ -188,7 +189,10 @@ public BuildRequest build() {
/** A human-readable description of all the non-default option settings. */
private final String optionsDescription;

/** The name of the Blaze command that the user invoked. Used for --announce. */
/**
* The name of the Blaze command that the user invoked.
* Used for --announce.
*/
private final String commandName;

private final OutErr outErr;
Expand All @@ -201,7 +205,6 @@ public BuildRequest build() {
private final boolean runTests;
private final boolean checkForActionConflicts;
private final boolean reportIncompatibleTargets;
private final ImmutableList<String> userOptions;

private BuildRequest(
String commandName,
Expand All @@ -221,8 +224,6 @@ private BuildRequest(
this.targets = targets;
this.id = id;
this.startTimeMillis = startTimeMillis;
this.userOptions =
options.getUserOptions() == null ? ImmutableList.of() : options.getUserOptions();
this.optionsCache =
Caffeine.newBuilder()
.build(
Expand Down Expand Up @@ -277,20 +278,15 @@ public Map<String, Object> getExplicitStarlarkOptions(
}

/**
* Returns the list of options that were parsed from either a user blazerc file or the command
* line.
* Returns a unique identifier that universally identifies this build.
*/
@Override
public ImmutableList<String> getUserOptions() {
return userOptions;
}

/** Returns a unique identifier that universally identifies this build. */
public UUID getId() {
return id;
}

/** Returns the name of the Blaze command that the user invoked. */
/**
* Returns the name of the Blaze command that the user invoked.
*/
public String getCommandName() {
return commandName;
}
Expand All @@ -299,19 +295,24 @@ boolean isRunningInEmacs() {
return runningInEmacs;
}

/** Returns true if tests should be run by the build tool. */
/**
* Returns true if tests should be run by the build tool.
*/
public boolean shouldRunTests() {
return runTests;
}

/** Returns the (immutable) list of targets to build in commandline form. */
/**
* Returns the (immutable) list of targets to build in commandline
* form.
*/
public List<String> getTargets() {
return targets;
}

/**
* Returns the output/error streams to which errors and progress messages should be sent during
* the fulfillment of this request.
* Returns the output/error streams to which errors and progress messages
* should be sent during the fulfillment of this request.
*/
public OutErr getOutErr() {
return outErr;
Expand All @@ -323,7 +324,10 @@ public <T extends OptionsBase> T getOptions(Class<T> clazz) {
return (T) optionsCache.get(clazz).orNull();
}

/** Returns the set of command-line options specified for this request. */

/**
* Returns the set of command-line options specified for this request.
*/
public BuildRequestOptions getBuildOptions() {
return getOptions(BuildRequestOptions.class);
}
Expand All @@ -333,12 +337,17 @@ public PackageOptions getPackageOptions() {
return getOptions(PackageOptions.class);
}

/** Returns the set of options related to the loading phase. */
/**
* Returns the set of options related to the loading phase.
*/
public LoadingOptions getLoadingOptions() {
return getOptions(LoadingOptions.class);
}

/** Returns the set of command-line options related to the view specified for this request. */
/**
* Returns the set of command-line options related to the view specified for
* this request.
*/
public AnalysisOptions getViewOptions() {
return getOptions(AnalysisOptions.class);
}
Expand All @@ -352,20 +361,24 @@ public boolean getKeepGoing() {
int getLoadingPhaseThreadCount() {
return getOptions(LoadingPhaseThreadsOption.class).threads;
}

/** Returns the set of execution options specified for this request. */
/**
* Returns the set of execution options specified for this request.
*/
public ExecutionOptions getExecutionOptions() {
return getOptions(ExecutionOptions.class);
}

/** Returns the human-readable description of the non-default options for this build request. */
/**
* Returns the human-readable description of the non-default options
* for this build request.
*/
public String getOptionsDescription() {
return optionsDescription;
}

/**
* Return the time (according to System.currentTimeMillis()) at which the service of this request
* was started.
* Return the time (according to System.currentTimeMillis()) at which the
* service of this request was started.
*/
public long getStartTime() {
return startTimeMillis;
Expand All @@ -390,10 +403,8 @@ public List<String> validateOptions() {
int jobs = getBuildOptions().jobs;
if (localTestJobs > jobs) {
warnings.add(
String.format(
"High value for --local_test_jobs: %d. This exceeds the value for --jobs: "
+ "%d. Only up to %d local tests will run concurrently.",
localTestJobs, jobs, jobs));
String.format("High value for --local_test_jobs: %d. This exceeds the value for --jobs: "
+ "%d. Only up to %d local tests will run concurrently.", localTestJobs, jobs, jobs));
}

// Validate other BuildRequest options.
Expand All @@ -412,7 +423,7 @@ public TopLevelArtifactContext getTopLevelArtifactContext() {
getOptions(BuildEventProtocolOptions.class).expandFilesets,
getOptions(BuildEventProtocolOptions.class).fullyResolveFilesetSymlinks,
OutputGroupInfo.determineOutputGroups(
buildOptions.outputGroups, validationMode(), /* shouldRunTests= */ shouldRunTests()));
buildOptions.outputGroups, validationMode(), /*shouldRunTests=*/ shouldRunTests()));
}

public ImmutableList<String> getAspects() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,6 @@ void parseRcOptions(
"%s:\n %s'%s' options: %s",
source, inherited, commandToParse, Joiner.on(' ').join(rcArgs.getArgs())));
}
PriorityCategory priorityCategory;
// There's not a separate PriorityCategory for "client" options, so treat them as global
// rcfile options. Client options are passed via the wrapper script.
if ((workspace.getWorkspace() != null
&& rcArgs.getRcFile().contains(workspace.getWorkspace().toString()))
|| rcArgs.getRcFile().equals("client")) {
priorityCategory = PriorityCategory.GLOBAL_RC_FILE;
} else {
priorityCategory = PriorityCategory.RC_FILE;
}
if (commandToParse.equals(COMMON_PSEUDO_COMMAND)) {
// Pass in options data for all commands supported by the runtime so that options that
// apply to some but not the current command can be ignored.
Expand All @@ -245,7 +235,7 @@ void parseRcOptions(
// pseudo command can be parsed unambiguously.
ImmutableList<String> ignoredArgs =
optionsParser.parseWithSourceFunction(
priorityCategory,
PriorityCategory.RC_FILE,
o -> rcArgs.getRcFile(),
rcArgs.getArgs(),
OptionsParser.getFallbackOptionsData(allOptionsClasses));
Expand All @@ -260,7 +250,7 @@ void parseRcOptions(
rcfileNotes.set(index, note);
}
} else {
optionsParser.parse(priorityCategory, rcArgs.getRcFile(), rcArgs.getArgs());
optionsParser.parse(PriorityCategory.RC_FILE, rcArgs.getRcFile(), rcArgs.getArgs());
}
}
}
Expand Down
Loading

0 comments on commit 0803ad3

Please sign in to comment.