Is it possible to easily set environment variables inside ninja.build?

1,352 views
Skip to first unread message

Michael Schlottke

unread,
Feb 27, 2014, 11:10:01 AM2/27/14
to ninja...@googlegroups.com
Hi everyone,

Is it possible to easily set some global environment variables (i.e. variables that would have the same effect if I set them using "export ..." in bash) inside the ninja build files?
I know I could use wrapper script but I'd rather be able to do this inside ninja somehow. The reason is that for some commercial compilers we need to set an environment variable with the license server information. Since the variables are unique to each compiler, clobbering of existing environment variables is not an issue.

Regards,

Michael

P.S.: I tried searching the mailing list but couldn't find this question, but if it has been asked (and answered) before, I'd appreciate any links to previous posts.

Scott Graham

unread,
Feb 27, 2014, 12:13:53 PM2/27/14
to Michael Schlottke, ninja-build
There's no way to do it currently without a wrapper.

Currently for chromium windows, we use the (otherwise unnecessary) "ninja -t msvc -e environment.block compiler.exe ...". This is a bit silly just to set the environment; it no longer does any of the deps parsing that was the original use of that tool.

Ideally, I'd like a variable pointing to that file, or perhaps it could be a literal directly containing the contents of the environment block. Another possibility that was proposed before is "env_SOMETHING = blah" to set SOMETHING.



--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Evan Martin

unread,
Feb 27, 2014, 1:14:40 PM2/27/14
to Scott Graham, Michael Schlottke, ninja-build
On non-Windows, where the commands are evaluated by a shell, you can always make your commands look like
  command = FOO=bar gcc ...
Reply all
Reply to author
Forward
0 new messages