Skip to content

fix(cargo_build_script): expand ${pwd} for execpaths and locations in build_script_env#4088

Open
psalaberria002 wants to merge 1 commit into
bazelbuild:mainfrom
psalaberria002:main
Open

fix(cargo_build_script): expand ${pwd} for execpaths and locations in build_script_env#4088
psalaberria002 wants to merge 1 commit into
bazelbuild:mainfrom
psalaberria002:main

Conversation

@psalaberria002

Copy link
Copy Markdown

Singular $(execpath ...) and $(location ...) were already prefixed with ${pwd}/ so build_script_runner could resolve them to absolute paths at run time. The plural forms $(execpaths ...) and $(locations ...) were silently omitted from this handling, leaving their paths as execroot-relative.

For plural forms each macro is expanded individually (via ctx.expand_location) and every resulting space-separated path is prefixed with ${pwd}/.

@slackito slackito left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you please add tests for your fix? There's a location expansion test at //test/unit/location_expansion:location_expansion_test_suite but it only covers execpath, and it does so in the rustc_flags of a rust_library target. I think you could add testing for the plural forms there.

You might also want to add another test for cargo_build_script to check that your intended use case is covered too.

…n build_script_env

Singular $(execpath ...) and $(location ...) were already prefixed with
\${pwd}/ so build_script_runner could resolve them to absolute paths at run
time. The plural forms $(execpaths ...) and $(locations ...) were silently
omitted from this handling, leaving their paths as execroot-relative.

For plural forms each macro is expanded individually (via ctx.expand_location)
and every resulting space-separated path is prefixed with \${pwd}/.

Tests: one rust_library covering all four macro forms in rustc_flags (each
referencing a distinct generated file), and a cargo_build_script test
verifying $(execpaths ...) in build_script_env is resolved to an absolute
path at run time.
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.

2 participants