Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let Starlark executable rules specify their environment #15766

Merged
merged 4 commits into from
Jun 29, 2022

Commits on Jun 29, 2022

  1. Specify fixedEnv/inheritedEnv interaction in ActionEnvironment

    Previously, ActionEnvironment did not publicly document how fixed and
    inherited environment variables interact, but still cautioned users to
    keep the two sets disjoint without enforcing this. As a result, neither
    could users rely on the interaction nor could ActionEnvironment benefit
    from the additional freedom of not specifying the behavior.
    
    With this commit, ActionEnvironment explicitly specifies that the values
    of environment variable inherited from the client environment take
    precedence over fixed values and codifies this behavior in a test.
    This has been the effective behavior all along and has the advantage
    that users can provide overrideable defaults for environment variables.
    
    Closes bazelbuild#15170.
    
    PiperOrigin-RevId: 439315634
    fmeum committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    d0cf9c5 View commit details
    Browse the repository at this point in the history
  2. Intern trivial ActionEnvironment and EnvironmentVariables instances

    When an ActionEnvironment is constructed out of an existing one, the
    ActionEnvironment and EnvironmentVariables instances, which are
    immutable, can be reused if no variables are added.
    
    Also renames addVariables and addFixedVariables to better reflect that
    they are operating on an immutable type.
    
    Closes bazelbuild#15171.
    
    PiperOrigin-RevId: 440312159
    fmeum committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    5118e54 View commit details
    Browse the repository at this point in the history
  3. Let Starlark executable rules specify their environment

    The new RunEnvironmentInfo provider allows any executable or test
    Starlark rule to specify the environment for when it is executed, either
    as part of a test action or via the run command.
    
    Refactors testing.TestEnvironment to construct a RunEnvironmentInfo and
    adds a warning (but not an error) if the provider constructed in this
    way is returned from a non-executable non-test rule. If a
    RunEnvironmentInfo is constructed directly via the Starlark constructor,
    this warning becomes an error.
    
    Fixes bazelbuild#7364
    Fixes bazelbuild#15224
    Fixes bazelbuild#15225
    
    Closes bazelbuild#15232.
    
    PiperOrigin-RevId: 448185352
    fmeum committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    3b51b72 View commit details
    Browse the repository at this point in the history
  4. Fix strict deps violation

    ```
    src/main/java/com/google/devtools/build/lib/analysis/starlark/StarlarkRuleClassFunctions.java:990: error: [strict] Using type com.google.devtools.build.lib.cmdline.LabelValidator from an indirect dependency (TOOL_INFO: "//src/main/java/com/google/devtools/build/lib/cmdline:LabelValidator"). See command below **
          LabelValidator.parseAbsoluteLabel(labelString);
          ^
    ```
    fmeum committed Jun 29, 2022
    Configuration menu
    Copy the full SHA
    4478d01 View commit details
    Browse the repository at this point in the history