[Scons-users] Using env.Replace to replace ENV

Bill Deegan bill at baddogconsulting.com
Wed Jan 30 01:03:10 EST 2019


So the issue is that tools are initialized (unless otherwise specified)
when you call Environment()

env=Environment()
Will initialize the default list of tools for your platform.
If you change the PATH after the tools are initialized it will not find
them via that PATH.

Also there's really no reason to use Replace
env.Replace(ENV=PATH)
is equivalent to:
env['ENV'] = PATH  # the preferred method to do so..

O.k. back to your issue.

env = Environment(tools=[])
env['ENV']['PATH'] = ['C:/cygwin/bin']
env.Tool('gcc')
env.Tool('g++')
env.Tool('gnulink')
env.Tool('ar')
& any other tools you know you need

Side note. If you're on win32 and not using msvc, Explicitly listing these
tools will be a bit faster as searching for VC installs can take a > 1
second.

*Or even simpler.. And likely the best way to do this..*
env = Environment(platform='cygwin')

(see man page for all the above).

-Bill


On Tue, Jan 29, 2019 at 7:28 PM Tony Peter Long <tony.peterlong at nxp.com>
wrote:

> Yes. The actual program I am building is a simple hello world application
> (as simple as you can imagine). My platform is Windows 10, Python is
> 2.7.15, SCons is 3.0.4, compiler is g++ 4.8.2 included with Cygwin 1.7.29,
> but I am not actually using Cygwin itself; I am calling SCons from a cmd
> window. 'C:/cygwin/bin' is included in SCons PATH so it can find g++. Of
> the two methods I have tried to include PATH in my environment, only the
> following works:
>
> # Setting ENV=PATH using the Environment constructor:
> > PATH = {'PATH' : ['C:/cygwin/bin']}
> > env = Environment(ENV = PATH)
> > env.Program('helloworld.cxx')
>
> The following method fails:
>
> # Using env.Replace to set ENV after constructing my Environment:
> > PATH = {'PATH' : ['C:/cygwin/bin']}
> > env = Environment()
> > env.Replace(ENV = PATH)
> > env.Program('helloworld.cxx')
>
> Gives the following error:
>
> > File "C:\Python27\Scripts\scons.py", line 204, in <module>
> > g++ /Fohelloworld.obj /c helloworld.cxx /TP /nologo
> > g++: error: /Fohelloworld.obj: No such file or directory
> > g++: error: /c: No such file or directory
> > g++: error: /TP: No such file or directory
> > g++: error: /nologo: No such file or directory
> > scons: *** [helloworld.obj] Error 1
>
> My only real question is, is there an intentional reason why the ENV
> construction variable must be set using the Environment constructor and not
> using env.Replace?
>
> Message: 1
> Date: Tue, 29 Jan 2019 09:11:44 -0800
> From: Bill Deegan <bill at baddogconsulting.com>
> To: SCons users mailing list <scons-users at scons.org>
> Subject: Re: [Scons-users] FW: Issue: using Replace to replace ENV
>         PATH
> Message-ID:
>         <
> CAEyG4CFH6m+F1oVP9d+cMWpL+87Ui7HC_kYNJYYPZpPPKCWg3g at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Tony,
>
> Instead of just showing us what you've tried, perhaps also explain what
> you want to do?
> It looks like you want to build using cygwin tools running from windows
> shell with windows python?
> Is that correct?
>
> -Bill
>
> On Mon, Jan 28, 2019 at 10:59 PM Tony Peter Long <tony.peterlong at nxp.com>
> wrote:
>
> > Sorry. Let me try this again.
> >
> >
> >
> > From: Tony Peter Long
> > Sent: Monday, January 28, 2019 14:02
> > To: 'scons-users at scons.org' <scons-users at scons.org>
> > Subject: Issue: using Replace to replace ENV PATH
> >
> >
> >
> > Hello all.
> >
> >
> >
> > I am a new SCons user as well as new to Open Source development in
> > general, so please forgive me if I?m missing some etiquette with this
> > mail, but I have a minor issue when using the Replace method to
> > replace ENV PATH as follows:
> >
> >
> >
> > PATH = {'PATH' : ['C:/cygwin/bin']}
> >
> > *env = Environment()*
> >
> > *env.Replace(ENV = PATH)*
> >
> > env.Replace(CXX = 'g++')
> >
> > env.Replace(CC = 'gcc')
> >
> > print "PATH = ", env['ENV']
> >
> > print "CXX = ", env['CXX']
> >
> > print "CC = ", env['CC']
> >
> > env.Program('helloworld.cxx')
> >
> > gives:
> >
> > scons: warning: No version of Visual Studio compiler found - C/C++
> > compilers most likely not set correctly
> >
> > File "D:\tony\SConstruct", line 2, in <module>
> >
> > PATH =  {'PATH': ['C:/cygwin/bin']}
> >
> > CXX =  g++
> >
> > CC =  gcc
> >
> >
> >
> > scons: warning: No version of Visual Studio compiler found - C/C++
> > compilers most likely not set correctly
> >
> > File "C:\Python27\Scripts\scons.py", line 204, in <module>
> >
> > g++ /Fohelloworld.obj /c helloworld.cxx /TP /nologo
> >
> > g++: error: /Fohelloworld.obj: No such file or directory
> >
> > g++: error: /c: No such file or directory
> >
> > g++: error: /TP: No such file or directory
> >
> > g++: error: /nologo: No such file or directory
> >
> > scons: *** [helloworld.obj] Error 1
> >
> >
> >
> > Whereas:
> >
> > PATH = {'PATH' : ['C:/cygwin/bin']}
> >
> > *env = Environment(ENV = PATH)*
> >
> > *# env.Replace()*
> >
> > env.Replace(CXX = 'g++')
> >
> > env.Replace(CC = 'gcc')
> >
> > print "PATH = ", env['ENV']
> >
> > print "CXX = ", env['CXX']
> >
> > print "CC = ", env['CC']
> >
> > env.Program('helloworld.cxx')
> >
> > gives:
> >
> > scons: Reading SConscript files ...
> >
> > PATH =  {'PATH': ['C:/cygwin/bin']}
> >
> > CXX =  g++
> >
> > CC =  gcc
> >
> > scons: done reading SConscript files.
> >
> > scons: Building targets ...
> >
> >
> >
> > scons: warning: No version of Visual Studio compiler found - C/C++
> > compilers most likely not set correctly
> >
> > File "C:\Python27\Scripts\scons.py", line 204, in <module>
> >
> > g++ -o helloworld.o -c helloworld.cxx
> >
> > g++ -o helloworld.exe helloworld.o
> >
> > scons: done building targets.
> >
> >
> >
> > I?m not particularly tied to the first implementation, so using the
> > second method suits me just fine. I was just wondering if this is
> > intended, and if so, why?
> >
> >
> >
> > Regards,
> >
> > Tony Long.
> >
> >
> > _______________________________________________
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20190129/f24caf41/attachment-0001.html>


More information about the Scons-users mailing list