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

Cannot extend build directives within cargo #11461

Closed
epage opened this issue Dec 6, 2022 · 12 comments · Fixed by #12201
Closed

Cannot extend build directives within cargo #11461

epage opened this issue Dec 6, 2022 · 12 comments · Fixed by #12201
Assignees
Labels
A-build-scripts Area: build.rs scripts C-bug Category: bug E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@epage
Copy link
Contributor

epage commented Dec 6, 2022

Because of cargo:KEY=VALUE, it isn't safe to add cargo:error= (or any other directive) as it can be interpreted as a KEY/VALUE, blocking #10159.

@epage epage added C-bug Category: bug A-build-scripts Area: build.rs scripts labels Dec 6, 2022
@epage
Copy link
Contributor Author

epage commented Dec 6, 2022

tl;dr we decided to extend the build directive syntax with cargo:: (maintaining compatibility on cargo: support). cargo:KEY=VALUE metadata syntax would move to something like cargo::metadata=KEY=VALUE. The name "metadata" was not fully settled on.

Ideally, cargo:KEY=VALUE would be changed to cargo:metadata=KEY=VALUE (name to be bikesheded) and we can extend as needed.

How to do it

  • Change it on an edition boundary
    • A directive could opt-in to the style
      • We'd need "begin" and "end"s to allow composing with third-party dependencies
    • Provide an env variable with the package.edition for what directive syntax is accepted by default
      • There are target-specific editions but the build script is tied to the package and not the target
  • Hack in a new namespace, say cargo:: instead of cargo:
    • For cargo:KEY=VALUE, we'd get :KEY=VALUE which seems a corner case enough that we'd consider this a minor incompatibility instead of a major incompatibility
    • Update all documentation to use :: with a note that : exists for compatiblity purposes with support for some directives

In the cargo team meeting we feel like cargo:: is a relatively simple solution with little documentation impact (new syntax, not concepts or interactions). We can always add directive versioning in the future within the syntax we have. We do not see any other compatibility traps within this syntax.

@epage epage added S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review E-easy Experience: Easy E-help-wanted labels Jan 31, 2023
@XaurDesu
Copy link

XaurDesu commented Feb 3, 2023

Could i take a look into this? Currently learning rust and it is marked as 'help wanted'

@epage
Copy link
Contributor Author

epage commented Feb 3, 2023

Sure. Feel free to message me on Zulip if you have questions

@XaurDesu
Copy link

XaurDesu commented Feb 3, 2023

@rustbot claim

@Rustin170506
Copy link
Member

@rustbot claim

Since there was no progress for a long time, I wanted to try to implement it.

@Rustin170506
Copy link
Member

  • Change it on an edition boundary

    • A directive could opt-in to the style

      • We'd need "begin" and "end"s to allow composing with third-party dependencies
    • Provide an env variable with the package.edition for what directive syntax is accepted by default

      • There are target-specific editions but the build script is tied to the package and not the target

@epage Could you explain a bit about change it on an edition boundary? Did you mean we use cargo: in edition 2021, and use cargo:: in the next edition?

@XaurDesu
Copy link

XaurDesu commented May 7, 2023

@rustbot claim

Since there was no progress for a long time, I wanted to try to implement it.

Go ahead, i wanted to help here but college brought me down. As @epage told me, please take a look into #11312 , because it points out to a bunch of the places that must be changed for this request.

EDIT: i copied the wrong pull request, sorry for that.

@epage
Copy link
Contributor Author

epage commented May 9, 2023

@hi-rustin sorry if this wasn't clear but all of those notes were a summary of the discussion. We ended up deciding this will not need an edition boundary as we ended up preferring the "Hack in a new namespace, say cargo:: instead of cargo:" route (those were meant to be alternatives, not parts of the same solution).

@XaurDesu
Copy link

XaurDesu commented May 9, 2023

@hi-rustin sorry if this wasn't clear but all of those notes were a summary of the discussion. We ended up deciding this will not need an edition boundary as we ended up preferring the "Hack in a new namespace, say cargo:: instead of cargo:" route (those were meant to be alternatives, not parts of the same solution).

Would it be feasible/desirable to make this it's own issue? given that, according to you:

In the cargo team meeting we feel like cargo:: is a relatively simple solution with little documentation impact (new syntax, not concepts or interactions). We can always add directive versioning in the future within the syntax we have. We do not see any other compatibility traps within this syntax.

This could probably be added to the issue list. I might be wrong however, since i'm still fairly new to the codebase. What do you think @epage ?

@epage
Copy link
Contributor Author

epage commented May 9, 2023

Its not quite clear to me what we would want another issue for or what you mean by "added to the issue list".

This issue would be resolved by the cargo:::. We could have an issue for directive versioning support but I personally wouldn't bother creating one. If we actually run into that, we can reference this issue for context. I see it as unlikely and adding noise to our already large backlog.

@XaurDesu
Copy link

XaurDesu commented May 9, 2023

Alright then, makes sense.

@Rustin170506
Copy link
Member

@hi-rustin sorry if this wasn't clear but all of those notes were a summary of the discussion. We ended up deciding this will not need an edition boundary as we ended up preferring the "Hack in a new namespace, say cargo:: instead of cargo:" route (those were meant to be alternatives, not parts of the same solution).

Got it. Thanks! I will give it a try recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts C-bug Category: bug E-easy Experience: Easy S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants