How to use environment variables in bazel build

4,861 views
Skip to first unread message

Kaustubh Deorukhkar

unread,
Nov 4, 2015, 4:03:42 AM11/4/15
to bazel-discuss
Hi,

Can some please help show a better way to export an env var and use in bazel build files? 

Here is one way I found, but I want to avoid passing an extra option to bazel command and use some env variable from shell.

bazel build //:sometarget --define MY_VAR_EXTRA_INCS=`pwd`/../../include

# Note that the above path is not within the bazel project scope, so I don't want to copy include to bazel project workspace.

cc_binary (
  name = "sometarget",
  includes = ["$(MY_VAR_EXTRA_INCS)", "third_party/xyz/include"],
 ...
)

I simply want to set env variable in shell and run bazel build //:sometarget

Thanks in advance,
Kaustubh

Damien Martin-guillerez

unread,
Nov 10, 2015, 9:22:14 AM11/10/15
to Kaustubh Deorukhkar, bazel-discuss
This would be not hermetic and is not allowed in Bazel. What do you want to do exactly?

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/6111c126-4289-4729-9ce0-777cfdddb368%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages