| Paste number 73164: | scons nsis diff |
| Pasted by: | tkho |
| When: | 5 months, 3 weeks ago |
| Share: | Tweet this! | http://paste.lisp.org/+1KGC |
| Channel: | None |
| Paste contents: |
tkm:Tool thomaskho$ diff mingw.py ~/Desktop/nsis-2.42-src/SCons/Tools/crossmingw.py -u
--- mingw.py 2009-01-05 21:59:59.000000000 -0800
+++ /Users/thomaskho/Desktop/nsis-2.42-src/SCons/Tools/crossmingw.py 2008-12-12 09:57:54.000000000 -0800
@@ -9,7 +9,7 @@
"""
#
-# __COPYRIGHT__
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -31,7 +31,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+__revision__ = "/home/scons/scons/branch.0/branch.96/baseline/src/engine/SCons/Tool/mingw.py 0.96.90.D001 2005/02/15 20:11:37 knight"
import os
import os.path
@@ -39,16 +39,30 @@
import SCons.Action
import SCons.Builder
-import SCons.Defaults
import SCons.Tool
import SCons.Util
# This is what we search for to find mingw:
-key_program = 'mingw32-gcc'
+prefixes = SCons.Util.Split("""
+ mingw32-
+ mingw32msvc-
+ i386-mingw32-
+ i486-mingw32-
+ i586-mingw32-
+ i686-mingw32-
+ i386-mingw32msvc-
+ i486-mingw32msvc-
+ i586-mingw32msvc-
+ i686-mingw32msvc-
+""")
def find(env):
- # First search in the SCons path and then the OS path:
- return env.WhereIs(key_program) or SCons.Util.WhereIs(key_program)
+ for prefix in prefixes:
+ # First search in the SCons path and then the OS path:
+ if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
+ return prefix
+
+ return ''
def shlib_generator(target, source, env, for_signature):
cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
@@ -61,7 +75,7 @@
implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature))
- def_target = env.FindIxes(target, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature))
return [cmd]
@@ -85,12 +99,12 @@
# or a def file source. There is no option to disable def file
# target emitting, because I can't figure out why someone would ever
# want to turn it off.
- def_source = env.FindIxes(source, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
- def_target = env.FindIxes(target, 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX')
+ def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
if not def_source and not def_target:
target.append(env.ReplaceIxes(dll,
'SHLIBPREFIX', 'SHLIBSUFFIX',
- 'WINDOWSDEFPREFIX', 'WINDOWSDEFSUFFIX'))
+ 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX'))
return (target, source)
@@ -104,48 +118,62 @@
SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
def generate(env):
- mingw = find(env)
- if mingw:
- dir = os.path.dirname(mingw)
- env.PrependENVPath('PATH', dir )
-
+ mingw_prefix = find(env)
+
+ if mingw_prefix:
+ dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc'))
+
+ # The mingw bin directory must be added to the path:
+ path = env['ENV'].get('PATH', [])
+ if not path:
+ path = []
+ if SCons.Util.is_String(path):
+ path = string.split(path, os.pathsep)
+
+ env['ENV']['PATH'] = string.join([dir] + path, os.pathsep)
# Most of mingw is the same as gcc and friends...
- gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas', 'm4']
+ gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
for tool in gnu_tools:
SCons.Tool.Tool(tool)(env)
#... but a few things differ:
- env['CC'] = 'gcc'
+ env['CC'] = mingw_prefix + 'gcc'
env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
- env['CXX'] = 'g++'
+ env['CXX'] = mingw_prefix + 'g++'
env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
env['SHLINKCOM'] = shlib_action
- env['LDMODULECOM'] = shlib_action
env.Append(SHLIBEMITTER = [shlib_emitter])
- env['AS'] = 'as'
-
+ env['LINK'] = mingw_prefix + 'g++'
+ env['AS'] = mingw_prefix + 'as'
+ env['AR'] = mingw_prefix + 'ar'
+ env['RANLIB'] = mingw_prefix + 'ranlib'
env['WIN32DEFPREFIX'] = ''
env['WIN32DEFSUFFIX'] = '.def'
- env['WINDOWSDEFPREFIX'] = '${WIN32DEFPREFIX}'
- env['WINDOWSDEFSUFFIX'] = '${WIN32DEFSUFFIX}'
-
env['SHOBJSUFFIX'] = '.o'
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
- env['RC'] = 'windres'
+ env['RC'] = mingw_prefix + 'windres'
env['RCFLAGS'] = SCons.Util.CLVar('')
- env['RCINCFLAGS'] = '$( ${_concat(RCINCPREFIX, CPPPATH, RCINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)'
- env['RCINCPREFIX'] = '--include-dir '
- env['RCINCSUFFIX'] = ''
- env['RCCOM'] = '$RC $_CPPDEFFLAGS $RCINCFLAGS ${RCINCPREFIX} ${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
+ env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
env['BUILDERS']['RES'] = res_builder
# Some setting from the platform also have to be overridden:
- env['OBJSUFFIX'] = '.o'
- env['LIBPREFIX'] = 'lib'
- env['LIBSUFFIX'] = '.a'
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ '$LIBPREFIX' ]
+ env['LIBSUFFIXES'] = [ '$LIBSUFFIX' ]
def exists(env):
return find(env)
This paste has no annotations.