Repository navigation
Bazel: Pass nodejs binary path as an environment variable. - #1518
Conversation
The current way to derive the binary path relies on a specific name for the nodejs repository. This blocks migrating to bzlmod, as it generates repository names based on which module is creating them, resulting in a different name. By letting Bazel tell us the correct name and passing it in, we can keep this working with both old and new name, independent of using bzlmod.
| ), | ||
| env_entry( | ||
| key = "NODE_JS_PATH", | ||
| value = nodejs_path, |
There was a problem hiding this comment.
If this is is an absolute path (or can be) then you can just pass EM_NODE_JS and completely remove the line from the config file.
There was a problem hiding this comment.
I looked a bit more into this, but couldn't find a way to do this much better. When this code here is executed, then the absolute path is not known yet, as we aren't yet executing actions, which run in sandboxes. I looked for some variable that will get substituted later, but couldn't find any.
There is env.sh, which is called before we end up in the config and it could do the conversion to an absolute path, but that doesn't really save any work. If we do it in env.sh, it does not work on Windows, which has its own env.bat, so the conversion forks into two places.
Can't test on Windows, so let's see what CI says.
|
Ok this seems to have fixed the Windows issue. I don't fully understand why this broke the closure compiler call and it wasn't broken before, but I guess having the same workaround on all platforms at least is better. |
|
Hi! Anything left to do here? |
|
lgtm if @walkingeyerobot is happy. Are you able to hit the merge button @walkingeyerobot ? |
|
Sorry! sbc had started the review so I wanted to approve but didn't want to hit the merge without his approval as well. Thanks very much for contributing! |
…n-core#1518) The current way to derive the binary path relies on a specific name for the nodejs repository. This blocks migrating to bzlmod, as bzlmod prefixes repository directories with the module name that created them. By asking bazel for the path instead we always get the correct path, so we can work with both bzlmod and WORKSPACE based dependencies at the same time. The repository @nodejs, used in the build label, refers to nodejs for the host platform and is generated by the following macro (wasn't too obvious to me): https://github.com/bazel-contrib/rules_nodejs/blob/d19d695275c5fd0d5224ddc7826d9f7f4b8186df/nodejs/repositories.bzl#L452 This is some work towards solving emscripten-core#1509.
The current way to derive the binary path relies on a specific name for the nodejs repository. This blocks migrating to bzlmod, as bzlmod prefixes repository directories with the module name that created them. By asking bazel for the path instead we always get the correct path, so we can work with both bzlmod and WORKSPACE based dependencies at the same time.
The repository @nodejs, used in the build label, refers to nodejs for the host platform and is generated by the following macro (wasn't too obvious to me):
https://github.com/bazel-contrib/rules_nodejs/blob/d19d695275c5fd0d5224ddc7826d9f7f4b8186df/nodejs/repositories.bzl#L452
This is some work towards solving #1509.