User name in .bazelrc

旧时模样 提交于 2019-12-11 04:29:18

问题


I would like to add this to my .bazelrc, but the $(whoami) doesn't expand like if it was in a shell.

startup --output_user_root=/tmp/bazel/out/$(whoami)                                                                                                                             

It produces the literal result:

/tmp/bazel/out/$(whoami)/faedb999bdce730c9c495251de1ca1a4/execroot/__main__/bazel-out/

Is there any way to do what I want: adding a name/hash to the option in the .bashrc file?

Edit: what I really want is to set the outputRoot to /tmp/bazel/out without using an environment variable and to let bazel create it's user and workspace hash directories there.


回答1:


You can run Bazel from a wrapper script. In fact, that's exactly what the bazel binary is (at least on Linux): it's a wrapper script that calls bazel-real. You can edit this wrapper script if you like, or rename it to bazel.sh and write your own wrapper.




回答2:


/usr/bin/bazel is a script which looks for //tools/bazel, and if it exists, calls it. Otherwise, it calls bazel-real. This lets you check Bazel into your repo, or otherwise modify how it gets called. We use that to download a specific version of bazel, extract it, and then call it.

I would recommend creating //tools/bazel, and having that do your modification. It can then either call a versioned version of bazel, or call bazel-real. That keeps your modifications local to your repo rather than global.



来源:https://stackoverflow.com/questions/47678041/user-name-in-bazelrc

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!