ninja-build / ninja

a small build system with a focus on speed
https://ninja-build.org/
Apache License 2.0
11.24k stars 1.6k forks source link

add support for loading environment variables globally #1610

Open graph opened 5 years ago

graph commented 5 years ago

Problem

For windows build using msvc the proper environment variables need to specified. It is not enough to call the compiler alone. different build directories may have different sets of environment variables used and keeping track of this is prone to programmer errors.

Proposed Solution

add a set_env command in ninja to set environment variables for the ninja process that will propagate to all sub commands.

eli-schwartz commented 1 year ago

A general workaround for this is for ninja generators to emit a warning message when the compiler is MSVC, cautioning the user to NOT run ninja under any circumstances, and only to run some (probably slow) wrapper script that repeats the song-and-a-dance of finding a suitable vswhere, running it, scraping for output, etc.

This is not convenient, and it still leaves the bad UX of running ninja directly resulting in very inscrutable errors about cl.exe

This seems to be similar to the ninja -t msvc functionality except it would be better to just load it once at startup. :)