Skip to content

Commit

Permalink
Add getExec method to FragmentOptions.
Browse files Browse the repository at this point in the history
This acts similarly to getHost, except:
1. It is intended to generate options for the exec transition, and
2. The default is to clone the options, not start with defaults.

Part of work on execution transitions, bazelbuild#7935.

PiperOrigin-RevId: 245418547
  • Loading branch information
katre authored and copybara-github committed Apr 26, 2019
1 parent 6362c2d commit 87388e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ public BuildOptions createHostOptions() {
return builder.addStarlarkOptions(skylarkOptionsMap).build();
}

/** Creates a new BuildOptions instance for exec. */
public BuildOptions createExecOptions() {
Builder builder = builder();
for (FragmentOptions options : fragmentOptionsMap.values()) {
builder.addFragmentOptions(options.getExec());
}
return builder.addStarlarkOptions(skylarkOptionsMap).build();
}

/**
* Returns {@code BuildOptions} that are otherwise identical to this one, but contain only options
* from the given {@link FragmentOptions} classes (plus build configuration options).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ public FragmentOptions getDefault() {
* Creates a new instance of this {@code FragmentOptions} with all flags adjusted as needed to
* represent the host platform.
*/
@SuppressWarnings("unused")
public FragmentOptions getHost() {
return getDefault();
}

/**
* Creates a new instance of this {@code FragmentOptions} with all flags adjusted as needed to
* represent the execution platform.
*/
public FragmentOptions getExec() {
return clone();
}

/**
* Returns an instance of {@code FragmentOptions} with all flags adjusted to be suitable for
* forming configurations.
Expand Down

0 comments on commit 87388e2

Please sign in to comment.