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

Update cargo_build_script to work without runfiles support. #2871

Merged
merged 11 commits into from
Sep 19, 2024

Conversation

UebelAndre
Copy link
Collaborator

@UebelAndre UebelAndre commented Sep 14, 2024

Partially addresses #1156

Copy link
Collaborator

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me!

cc @fmeum just as an FYI in case there's anything you think should live more upstream somewhere

cargo/cargo_build_script_runner/lib.rs Outdated Show resolved Hide resolved
Comment on lines 54 to 57
":{}_enable_runfiles".format(name): True,
":{}_disable_runfiles".format(name): False,
# Otherwise fall back to the system default.
"@platforms//os:windows": False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised Bazel is happy to treat these as independent - doesn't it have a precedence conflict between the @platforms branch and the runfiles ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It complained when you actually specified --noenable_runfiles. I've updated this to work on windows and unix systems where the flag is enabled, disabled, and unset.

@UebelAndre UebelAndre added this pull request to the merge queue Sep 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 18, 2024
@UebelAndre
Copy link
Collaborator Author

Works for me!

cc @fmeum just as an FYI in case there's anything you think should live more upstream somewhere

It would be great because I made this a lot more complicated lol

@UebelAndre UebelAndre added this pull request to the merge queue Sep 19, 2024
Merged via the queue into bazelbuild:main with commit c520417 Sep 19, 2024
4 checks passed
Comment on lines +211 to +213
workspace_name = ctx.label.workspace_name
if not workspace_name:
workspace_name = ctx.workspace_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
workspace_name = ctx.label.workspace_name
if not workspace_name:
workspace_name = ctx.workspace_name
workspace_name = ctx.workspace_name

External repos always fall into the ../ branch anyway.

Comment on lines +264 to +266
workspace_name = ctx.label.workspace_name
if not workspace_name:
workspace_name = ctx.workspace_name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above, this can be simplified.

),
}

def runfiles_enabled_build_setting(name, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice hack ;-)

I think that this can be simplified since you don't need a single build setting to match both the platform and the value of --enable_runfiles. This currently also matches the target platform, but the default is based on the host platform.

How about only matching the flag here and then using ctx.configuration.host_path_separator to filter out a Windows host in runfiles_enabled_build_setting?

Copy link
Collaborator Author

@UebelAndre UebelAndre Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmeum This took an embarrassing amount of brain power 😅 , could I get you to slice and dice this code to be the simpler form?

@@ -0,0 +1,71 @@
//! A tool for building runfiles directories for Bazel environments that don't
//! support runfiles or have runfiles enabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enabled --> disabled

UebelAndre added a commit to UebelAndre/rules_rust that referenced this pull request Sep 19, 2024
UebelAndre added a commit to UebelAndre/rules_rust that referenced this pull request Sep 19, 2024
@UebelAndre
Copy link
Collaborator Author

This change ended up being more complicated and needs another review but I forgot to disable auto-merge. Revert is here #2885

github-merge-queue bot pushed a commit that referenced this pull request Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants