Add --host_action_env option
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:
Closes
@@ -342,14 +342,30 @@ public class CoreOptions extends FragmentOptions implements Cloneable {
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,
@@ -957,6 +973,9 @@ public class CoreOptions extends FragmentOptions implements Cloneable {
host.hostCpu = hostCpu;
host.hostCompilationMode = hostCompilationMode;
+ // Pass host action environment variables
+ host.actionEnvironment = hostActionEnvironment;
+
return host;
}
