You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use Bazel to build my personal site, and I've undergone a bit of a migration to try and use aspect.dev rules for all of the JS-adjacent tasks. The migration has generally gone well, but I'm a bit confused as to the best way to handle the binary directories.
I have a bunch of rules that run JS that I can't trivially use js_run_binary for, because I need to work with various providers in the deps and outputs. The main issue is, these rules use ctx.actions.args() + param files to add arguments, e.g.:
Bazel auto-converts the the args reference to point to the path to the args file...and therein lies the problem: while I can adjust the paths inside the args file, I cannot adjust the path to the args file itself.
While playing around with this, I noticed two things:
The oft-recommended chdir argument to js_run_binary works by setting JS_BINARY__CHDIR. I'm pretty sure I'm not supposed to set this myself...but I can, and this is a rather small project so I'm okay with some ugliness.
The value of BAZEL_BINDIR seems to always be bazel-out/<arch>-fastbuild/bin.
So...I can actually get this to consistently work in my rules by just setting:
The thing is, this feels...wrong? Like, the docs emphasize the trade-offs regarding paths a lot. Is this even supposed to work, or is it only working by sheer luck? Are there major risks in here I'm not aware of?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I use Bazel to build my personal site, and I've undergone a bit of a migration to try and use aspect.dev rules for all of the JS-adjacent tasks. The migration has generally gone well, but I'm a bit confused as to the best way to handle the binary directories.
I have a bunch of rules that run JS that I can't trivially use
js_run_binary
for, because I need to work with various providers in the deps and outputs. The main issue is, these rules usectx.actions.args()
+ param files to add arguments, e.g.:Bazel auto-converts the the
args
reference to point to the path to the args file...and therein lies the problem: while I can adjust the paths inside the args file, I cannot adjust the path to the args file itself.While playing around with this, I noticed two things:
chdir
argument tojs_run_binary
works by settingJS_BINARY__CHDIR
. I'm pretty sure I'm not supposed to set this myself...but I can, and this is a rather small project so I'm okay with some ugliness.BAZEL_BINDIR
seems to always bebazel-out/<arch>-fastbuild/bin
.So...I can actually get this to consistently work in my rules by just setting:
The thing is, this feels...wrong? Like, the docs emphasize the trade-offs regarding paths a lot. Is this even supposed to work, or is it only working by sheer luck? Are there major risks in here I'm not aware of?
Beta Was this translation helpful? Give feedback.
All reactions