[Scons-users] Setting environment variables for scons to use globally on my system

Dirk Bächle tshortik at gmx.de
Thu May 15 13:59:26 EDT 2014


Hi Benjamin,

On 15.05.2014 10:06, Benjamin Lindley wrote:

>

> Is there any way to set environment variables for my system which

> scons will use, without me having to change the SConstruct file? For

> example, I would like to use MinGW instead of VC++ for my C++ builds

> on Windows. I can, of course, do this in my SConstruct file:

>

> |env = Environment(tools = ['mingw'])

> |

>

> But if I do that, then I'm editing things into my build files that

> make it specific to my particular system configuration. That defeats

> the whole purpose of a portable build system, in my opinion. If I

> upload that as part of my repository for others to build, they may not

> be using MinGW. They may want to use VC++, or Clang, and I don't think

> they should have to modify the build file (or anything else in the

> repository for that matter) in order to build the program or library.

> Ideally, anyone with in an environment with a functional C++ toolchain

> and scons installed /should/ be able to just type |scons| on the

> command line, and things should go smoothly for them. Isn't that the

> (or a) goal of scons? Or am I misunderstanding its purpose?

>

> Another thing is paths. The above line is not even enough, I have to

> still import the path to the MinGW binaries. I've read the

> justification for this. But it's just more system specific information

> which I have to put in my build files, which may be used by others

> where the chosen paths are not applicable.

>

>


if you want to be as cross-platform and user friendly as possible, you
should pull the "PATH" environment variable in to your build environment:

env = Environment(ENV = {'PATH' : os.environ['PATH']})

and let SCons detect the compilers and tools. This enables you, and
other users, to control which executables are found by setting the PATH
in the current shell environment...just as you would do for an
application that you wanted to call from the command line.

Note, how the solution above (getting things to compile anywhere, no
matter which compiler is used) is different from a company's environment
where the build process has to enforce and make sure that on any machine
the same compiler is used (and all environment settings are the same for
a given architecture, such that exactly the same binary comes out).

Both of these are valid approaches, and can be setup in SCons easily.

Best regards,

Dirk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20140515/d4e1d54c/attachment.htm


More information about the Scons-users mailing list