-
-
Notifications
You must be signed in to change notification settings - Fork 183
feat(js_run_binary): add support for path mapping #2962
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
Merged
+103
−17
Merged
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c888d48
feat(js_run_binary): add support for path mapping
acozzette ab3e8da
Upgrade bazel_lib to 3.7.0
acozzette 1d5d563
Added e2e test
acozzette fde0d20
Simplify some things
acozzette 2daa7fa
buildifier
acozzette e4affbe
Avoid re-ordering variables
acozzette 6721f57
Compute some of these variables inside the macro
acozzette 48a9dd6
Fix ordering
acozzette ab101ca
Add e2e tests for BAZEL_BUILD_FILE_PATH and BAZEL_TARGET across modules
acozzette 3406fb5
Shorten long comment
acozzette b2211b6
Fix bazel_target_test to work across Bazel versions
acozzette d7aea7d
Revert to Make-variable expansion for the legacy js_run_binary env vars
acozzette 042330e
Simplify test
acozzette 7f3ac97
Fix up ordering
acozzette d8ce431
Move BAZEL_PACKAGE and BAZEL_TARGET_NAME behind set_legacy_environmen…
acozzette 6ab1956
Remove outdated comment
acozzette 88d4643
buildifier
acozzette 438cf15
Simplify comment
acozzette 9c0bd73
Explicitly set BAZEL_BINDIR if set_legacy_environment_variables
acozzette 4b3f418
Tweak comment
acozzette 4722d21
Fix comment
acozzette File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
e2e/path_mapping/js_run_binary_path_mapping_check/BUILD.bazel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary") | ||
| load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
|
||
| # Verifies that a js_run_binary target supports path mapping. This requires | ||
| # use_execroot_entry_point and set_legacy_environment_variables to both be | ||
| # disabled, and args must avoid Make variable and location expansion. | ||
| js_binary( | ||
| name = "check", | ||
| entry_point = "check.mjs", | ||
| ) | ||
|
|
||
| js_run_binary( | ||
| name = "js_run_binary_path_mapping_check", | ||
| outs = ["out.txt"], | ||
| args = ["out.txt"], | ||
| chdir = package_name(), | ||
| mnemonic = "JsRunBinaryPathMappingCheck", | ||
| set_legacy_environment_variables = False, | ||
| tool = ":check", | ||
| use_execroot_entry_point = False, | ||
| ) | ||
|
|
||
| build_test( | ||
| name = "js_run_binary_path_mapping_check_test", | ||
| targets = [":js_run_binary_path_mapping_check"], | ||
| ) |
23 changes: 23 additions & 0 deletions
23
e2e/path_mapping/js_run_binary_path_mapping_check/check.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { writeFileSync } from 'fs' | ||
|
|
||
| const outFile = process.argv[2] | ||
| if (!outFile) { | ||
| process.stderr.write('Usage: check.mjs <output-file>\n') | ||
| process.exit(1) | ||
| } | ||
|
|
||
| const bindir = process.env.BAZEL_BINDIR | ||
| if (bindir !== 'bazel-out/cfg/bin') { | ||
| process.stderr.write( | ||
| `Expected BAZEL_BINDIR to be "bazel-out/cfg/bin", got "${bindir}"\n` | ||
| ) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| const leaked = process.argv.filter((arg) => arg === '--bazel-bindir') | ||
| if (leaked.length > 0) { | ||
| process.stderr.write(`--bazel-bindir flag leaked into argv: ${leaked}\n`) | ||
| process.exit(1) | ||
| } | ||
|
|
||
| writeFileSync(outFile, 'OK\n') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.