Skip to content

Commit

Permalink
Add --host_action_env option
Browse files Browse the repository at this point in the history
This PR adds `--host_action_env` option to specify a set of environment variables to be added to the host configuration. The variables specified by this option are only added to host configuration while those specified by `--action_env` are only included in the target configuration.

Fixes: #4008

Closes #12122.

PiperOrigin-RevId: 333060884
  • Loading branch information
mai93 authored and copybara-github committed Sep 22, 2020
1 parent 67e4aaa commit a463d90
Showing 1 changed file with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,30 @@ public String getTypeDescription() {
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES},
help =
"Specifies the set of environment variables available to actions. "
+ "Variables can be either specified by name, in which case the value will be "
+ "taken from the invocation environment, or by the name=value pair which sets "
+ "the value independent of the invocation environment. This option can be used "
+ "multiple times; for options given for the same variable, the latest wins, options "
+ "for different variables accumulate.")
"Specifies the set of environment variables available to actions with target"
+ " configuration. Variables can be either specified by name, in which case the"
+ " value will be taken from the invocation environment, or by the name=value pair"
+ " which sets the value independent of the invocation environment. This option can"
+ " be used multiple times; for options given for the same variable, the latest"
+ " wins, options for different variables accumulate.")
public List<Map.Entry<String, String>> actionEnvironment;

@Option(
name = "host_action_env",
converter = Converters.OptionalAssignmentConverter.class,
allowMultiple = true,
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.OUTPUT_PARAMETERS,
effectTags = {OptionEffectTag.ACTION_COMMAND_LINES},
help =
"Specifies the set of environment variables available to actions with host or execution"
+ " configurations. Variables can be either specified by name, in which case the"
+ " value will be taken from the invocation environment, or by the name=value pair"
+ " which sets the value independent of the invocation environment. This option can"
+ " be used multiple times; for options given for the same variable, the latest"
+ " wins, options for different variables accumulate.")
public List<Map.Entry<String, String>> hostActionEnvironment;

@Option(
name = "repo_env",
converter = Converters.OptionalAssignmentConverter.class,
Expand Down Expand Up @@ -957,6 +973,9 @@ public FragmentOptions getHost() {
host.hostCpu = hostCpu;
host.hostCompilationMode = hostCompilationMode;

// Pass host action environment variables
host.actionEnvironment = hostActionEnvironment;

return host;
}

Expand Down

0 comments on commit a463d90

Please sign in to comment.