[Scons-users] compiler detection
Evan Driscoll
driscoll at cs.wisc.edu
Mon Oct 29 22:16:44 EDT 2012
On 10/29/2012 06:21 PM, Kraus Philipp wrote:
> $ scons
> scons: Reading SConscript files ...
> shell: 'C:\\opt\\mingw\\msys\\1.0\\bin\\sh.exe'
> scons: done reading SConscript files.
> scons: Building targets ...
> /bin/ls -l
> /C: /C: is a directory
> scons: *** [testcmd3] Error 126
> scons: building terminated because of errors.
>
> => mingw is installed under C:\opt\mingw
I must confess to being a little frustrated, as it seems like you are
ignoring several things I say (and in this case, that Gary sent a
reminder of). This version should work, at least for things that don't
require fancy quoting, if you also replaced env["SPAWN"].
Note that the error here is not that it couldn't find the shell, the
error here is because it is trying to run 'C:\...\sh.exe /C "/bin/ls
-l"'. (I'll admit that the "/C is a directory" error is a bit
inscrutable if you don't know or realize what is going on.)
The following SConstruct works for me. Can you change the path to your
installation and try it?
from SCons.Platform.win32 import exec_spawn
import os
env = Environment(ENV = {'PATH' : os.environ["PATH"]})
env["SHELL"]="P:/programs/msys/bin/sh.exe"
env["SPAWN"] = (lambda sh, esc, cmd, args, env_param:
exec_spawn([sh, '-c', ' '.join(args)], env_param))
env.Command("test", "", "/bin/ls -l")
> My question is, in which case detect scons the shell? It seems that scons detects on Windows always the cmd.exe
> On Cygwin Scons uses also the bash / sh, which is my local running shell, mingw uses also the sh. On Cygwin
> works always fine, so I expect that the detection on mingw works equal.
*There is no detection at all.*
SCons will always behave the same regardless of how you start it. If
'scons' runs the native SCons, it will always use cmd.exe by default
regardless of whether it is being started under Cygwin or cmd. If
'scons' runs Cygwin SCons, then it will always use Cygwin's sh.exe by
default regardless of whether it is being started under Cygwin or cmd.
(But see below.)
If you are seeing 'scons' from cmd.exe use cmd.exe and 'scons' from a
Cygwin shell use sh.exe, that's because you have BOTH versions
installed, and %PATH% ($PATH) is set such that from cmd.exe it runs the
native version and from a Cygwin shell it runs the Cygwin version.
Actually, if 'scons' works from both shells that's almost certainly
what's going on, as running the Cygwin version from cmd.exe and running
the native version from Cygwin are both... interesting... tasks. Under
cmd.exe and native SCons, 'scons' actually runs 'scons.bat'. However,
.bat files aren't picked up by Cygwin (or probably Msys, though I didn't
try) and so if you only have native SCons, you have to do some extra
work to run it from a Cygwin shell. Under a Cygwin shell with Cygwin
SCons, 'scons' will actually run a Bash shell script which won't be
picked up by cmd.exe, so in both cases you have to try extra hard to get
things to work. If you install both, you'll see the differing behavior
you saw, but that's because they're running different things not because
SCons is doing anything.
You can show yourself that this is true by explicitly running something like
p:/programs/python27/python p:/programs/Python27/Scripts/scons.py
from the Cygwin shell (obviously you'll need to correct the paths to
match your Python) and seeing that it uses cmd.exe as its env["SHELL"]
by default:
/cygdrive/i/temp$ p:/programs/python27/python
"p:\programs\Python27\Scripts\scons.py" -Q
SHELL starts as C:\Windows\System32\cmd.exe
Evan
More information about the Scons-users
mailing list