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

Document the environment_group pseudo-rule and environment rule #10849

Open
katre opened this issue Feb 24, 2020 · 6 comments
Open

Document the environment_group pseudo-rule and environment rule #10849

katre opened this issue Feb 24, 2020 · 6 comments
Labels
next_month Issues that we will review next month. This is currently mainly used by Configurability team P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability Issues for Configurability team team-Documentation Documentation improvements that cannot be directly linked to other team labels type: documentation (cleanup)

Comments

@katre
Copy link
Member

katre commented Feb 24, 2020

There is no documentation for either the environment_group pseudo-rule or the environment rule. environment appears to have one piece of documentation (for the fullfills attribute), but that can't be found because the overall rule isn't documented. environment_rule is implemented by a Starlark function and is explicitly called out as undocumented.

@katre katre added type: documentation (cleanup) P2 We'll consider working on this in future. (Assignee optional) team-Configurability Issues for Configurability team labels Feb 24, 2020
@katre
Copy link
Member Author

katre commented Feb 24, 2020

Tagging @gregestren for context and history.

@gregestren
Copy link
Contributor

This is fair. We've kept it undocumented because platforms should (I think) supplant most practical uses of this and we don't want too forked an API as we can help it.

But the cat's out of the bag already and we can clarify these relationships and best practices in the docs.

@shahms
Copy link

shahms commented Mar 24, 2022

One thing that isn't covered by platforms but can be done with constraints (although awkwardly) is preventing a target from transitively depending on targets which are mutually exclusive (regardless of platform), e.g.

environment(name = "a-env")

environment(name = "b-env")

environment_group(
    name = "a_xor_b",
    defaults = [
        ":a-env",
        ":b-env",
    ],
    environments = [
        ":a-env",
        ":b-env",
    ],
)
cc_library(
    name = "a_lib",
    srcs = ["a.cc"],
    restricted_to = [":a-env"],
)

cc_library(
    name = "b_lib",
    srcs = ["b.cc"],
    restricted_to = [":b-env"],
)

cc_binary(
    name = "main",
    srcs = ["main.cc"],
    deps = select({
        ":env-a": [":a_lib"], # Succeeds.
        ":env-b": [":b_lib"], # Succeeds.
        "//conditions:default": [ # Fails.
            ":a_lib",
            ":b_lib",
        ],
    }),
)

There shouldn't be any need to define and use a new platform to express and enforce this kind of constraing.

@gregestren gregestren added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Mar 24, 2022
@gregestren
Copy link
Contributor

I acknowledge platforms don't solve all use cases naturally. Product features (like "free" vs. "premium") are a prominent counterexample.

In your above example, would a-env and b-env refer to anything in particular? What's the non-platform mutual exclusivity you're thinking?

@shahms
Copy link

shahms commented Mar 25, 2022

This case came up internally specifically around avoiding known ODR violations at build time by declaring two libraries explicitly incompatible. A fairly niche case, to be sure, but considering the hard-to-debug breakages such issues can cause seemed potentially valuable to support.

@katre katre added the next_month Issues that we will review next month. This is currently mainly used by Configurability team label Jan 9, 2023
@keertk keertk added the team-Documentation Documentation improvements that cannot be directly linked to other team labels label Jan 10, 2023
Copy link

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next_month Issues that we will review next month. This is currently mainly used by Configurability team P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Configurability Issues for Configurability team team-Documentation Documentation improvements that cannot be directly linked to other team labels type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

4 participants