8

feat: allow customizing the command for running build scripts by fee1-dead · Pul...

 2 years ago
source link: https://github.com/rust-lang/rust-analyzer/pull/11956
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

New issue

feat: allow customizing the command for running build scripts #11956

Conversation

Copy link

Member

@fee1-dead fee1-dead commented 12 days ago

edited

I have tested this locally and it fixed #9201 with some small changes on the compiler side with suggestions from #9201 (comment).

I have also added an environment variable IS_RA_BUILDSCRIPT_CHECK for crates to detect that it is a check for buildscripts, and allows defaulting to bogus values for expected environment variables.

Copy link

Member

Author

fee1-dead commented 10 days ago

@Veykril this helps with properly expanding procedural macros in rust-lang/rust. Would you like to review this?

Copy link

Member

Veykril commented 9 days ago

I have also added an environment variable IS_RA_BUILDSCRIPT_CHECK for crates to detect that it is a check for buildscripts, and allows defaulting to bogus values for expected environment variables.

Is this required? I am a bit reluctant to setting that env var since we don't really want crates to specialize for the case where r-a builds them.

Copy link

Member

Author

fee1-dead commented 9 days ago

Is this required?

Not really. rust-lang/rust requires a few env vars to be set as can be seen with eddyb's comment: CFG_RELEASE= CFG_RELEASE_CHANNEL= RUSTC_INSTALL_BINDIR=. I'm not sure which is better: adding a configuration for rust-analyzer setting env vars when checking for buildscripts, or just use that env var. Not doing anything needs rustc to always default to bogus values if those variables are not set, which should really be treated as errors unless r-a is building them.

Copy link

Member

flodiebold commented 9 days ago

edited

I wonder if this is the right solution. Usually, if the project is a normal cargo workspace there should be no reason why we can't cargo check everything (especially with the rustc wrapper). If the project is not a normal cargo workspace, cargo check is most likely to not be the right thing to call at all. So to me it would make more sense to make the "run build scripts and compile proc macros" command completely customizable?

fee1-dead reacted with thumbs up emoji

Copy link

Member

Author

fee1-dead commented 9 days ago

So to me it would make more sense to make the "run build scripts and compile proc macros" command completely customizable?

cargo check -p rustc_driver works with the rustc wrapper. But x.py check does not. So the best way is still using cargo check.

Copy link

Member

flodiebold commented 9 days ago

edited

Sure, but making it fully configurable wouldn't mean that it can't be configured to still use cargo check though -- or to use some x.py variant that either doesn't use the rustc wrapper or does work with it.

(I don't want to let the perfect be the enemy of the good though.)

Copy link

Member

Author

fee1-dead commented 9 days ago

Yeah. That is why I pushed the fully configurable version.

/// Advanced option, fully override the command rust-analyzer uses for

/// checking buildscripts and procedural macros. The command should

/// include `--message-format=json` or similar option.

checkBuildScriptOnSave_overrideCommand: Option<Vec<String>> = "null",

Copy link

Member

@flodiebold flodiebold 9 days ago

edited

I suggest we call this rust-analyzer.cargo.runBuildScriptsCommand (maybe runBuildScripts.command would be ideal if we didn't already have runBuildScripts as a boolean option). (The point of running cargo check here is not to check the build scripts, it's to have their results and the proc macros available.) For the description how about something like this:

Advanced option, fully override the command rust-analyzer uses to run build scripts and build procedural macros. The command should include `--message-format=json` or a similar option.

Copy link

Member

Author

@fee1-dead fee1-dead 9 days ago

done.

Copy link

Contributor

bjorn3 commented 9 days ago

Maybe update the PR title and commit message?

fee1-dead reacted with thumbs up emoji

fee1-dead

changed the title feat: allow selecting which packages to check for buildscripts

feat: allow customizing the command for running build scripts

9 days ago

Copy link

Member

flodiebold commented 9 days ago

bors r+

fee1-dead reacted with hooray emoji

Copy link

Member

Veykril commented 9 days ago

bors doesn't work right now because of the repo move

Copy link

Member

Author

fee1-dead commented 9 days ago

edited

Are you working on the PRs to migrate to homu? I would like to help.

Copy link

Member

Veykril commented 9 days ago

Ye I was about to look into that, help with would be appreciated :)

Copy link

Member

Veykril commented 9 days ago

@bors ping

Copy link

Member

Veykril commented 9 days ago

@bors r=flodiebold

Copy link

Collaborator

bors commented 9 days ago

pushpin Commit 73a033e has been approved by flodiebold

Copy link

Collaborator

bors commented 9 days ago

hourglass Testing commit 73a033e with merge 15844bf...

Copy link

Collaborator

bors commented 9 days ago

sunny Test successful - checks-actions
Approved by: flodiebold
Pushing 15844bf to master...

Copy link

Contributor

lf- commented 9 days ago

Can we submit a change to the rustc contributor docs to say how to enable this feature?

Veykril reacted with thumbs up emoji

Copy link

Member

Author

fee1-dead commented 8 days ago

Can we submit a change to the rustc contributor docs to say how to enable this feature?

It shouldn't be changed until another nightly is released, rust-analyzer bumped in rust-lang/rust. But in the mean time I will write the instructions up and prepare a PR to rustc-dev-guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

No one assigned

Labels
None yet
Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK