summaryrefslogtreecommitdiff
path: root/scons
diff options
context:
space:
mode:
Diffstat (limited to 'scons')
-rw-r--r--scons/gallium.py50
-rw-r--r--scons/generic.py2
-rw-r--r--scons/mslib_sa.py88
-rw-r--r--scons/winddk.py137
-rw-r--r--scons/winsdk.py22
5 files changed, 190 insertions, 109 deletions
diff --git a/scons/gallium.py b/scons/gallium.py
index e2cd0546c1..6e924da303 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -42,11 +42,18 @@ import SCons.Scanner
def quietCommandLines(env):
# Quiet command lines
# See also http://www.scons.org/wiki/HidingCommandLinesInOutput
- env['CCCOMSTR'] = "Compiling $SOURCE ..."
- env['CXXCOMSTR'] = "Compiling $SOURCE ..."
- env['ARCOMSTR'] = "Archiving $TARGET ..."
- env['RANLIBCOMSTR'] = ""
- env['LINKCOMSTR'] = "Linking $TARGET ..."
+ env['ASCOMSTR'] = " Assembling $SOURCE ..."
+ env['ASPPCOMSTR'] = " Assembling $SOURCE ..."
+ env['CCCOMSTR'] = " Compiling $SOURCE ..."
+ env['SHCCCOMSTR'] = " Compiling $SOURCE ..."
+ env['CXXCOMSTR'] = " Compiling $SOURCE ..."
+ env['SHCXXCOMSTR'] = " Compiling $SOURCE ..."
+ env['ARCOMSTR'] = " Archiving $TARGET ..."
+ env['RANLIBCOMSTR'] = " Indexing $TARGET ..."
+ env['LINKCOMSTR'] = " Linking $TARGET ..."
+ env['SHLINKCOMSTR'] = " Linking $TARGET ..."
+ env['LDMODULECOMSTR'] = " Linking $TARGET ..."
+ env['SWIGCOMSTR'] = " Generating $TARGET ..."
def createConvenienceLibBuilder(env):
@@ -185,9 +192,8 @@ def num_jobs():
def generate(env):
"""Common environment generation code"""
- # FIXME: this is already too late
- #if env.get('quiet', False):
- # quietCommandLines(env)
+ if env.get('quiet', True):
+ quietCommandLines(env)
# Toolchain
platform = env['platform']
@@ -252,21 +258,24 @@ def generate(env):
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
'WIN32_LEAN_AND_MEAN',
]
- if msvc:
+ if msvc and env['toolchain'] != 'winddk':
cppdefines += [
'VC_EXTRALEAN',
'_CRT_SECURE_NO_DEPRECATE',
]
if debug:
cppdefines += ['_DEBUG']
- if platform == 'winddk':
+ if env['toolchain'] == 'winddk':
# Mimic WINDDK's builtin flags. See also:
# - WINDDK's bin/makefile.new i386mk.inc for more info.
# - buildchk_wxp_x86.log files, generated by the WINDDK's build
# - http://alter.org.ua/docs/nt_kernel/vc8_proj/
+ if machine == 'x86':
+ cppdefines += ['_X86_', 'i386']
+ if machine == 'x86_64':
+ cppdefines += ['_AMD64_', 'AMD64']
+ if platform == 'winddk':
cppdefines += [
- ('_X86_', '1'),
- ('i386', '1'),
'STD_CALL',
('CONDITION_HANDLING', '1'),
('NT_INST', '0'),
@@ -309,20 +318,13 @@ def generate(env):
cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
env.Append(CPPDEFINES = cppdefines)
- # C preprocessor includes
- if platform == 'winddk':
- env.Append(CPPPATH = [
- env['SDK_INC_PATH'],
- env['DDK_INC_PATH'],
- env['WDM_INC_PATH'],
- env['CRT_INC_PATH'],
- ])
-
# C compiler options
cflags = []
if gcc:
if debug:
cflags += ['-O0', '-g3']
+ elif env['toolchain'] == 'crossmingw':
+ cflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
else:
cflags += ['-O3', '-g3']
if env['profile']:
@@ -362,10 +364,8 @@ def generate(env):
]
else:
cflags += [
- '/Ox', # maximum optimizations
- '/Oi', # enable intrinsic functions
- '/Ot', # favor code speed
- #'/fp:fast', # fast floating point
+ '/O2', # optimize for speed
+ #'/fp:fast', # fast floating point
]
if env['profile']:
cflags += [
diff --git a/scons/generic.py b/scons/generic.py
index 03563e4c62..29ddf76d6f 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -398,6 +398,8 @@ def generate(env):
if gcc:
if debug:
ccflags += ['-O0', '-g3']
+ elif env['toolchain'] == 'crossmingw':
+ ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
else:
ccflags += ['-O3', '-g0']
if env['profile']:
diff --git a/scons/mslib_sa.py b/scons/mslib_sa.py
index da51c574b6..50d47ee37b 100644
--- a/scons/mslib_sa.py
+++ b/scons/mslib_sa.py
@@ -29,21 +29,105 @@ Based on SCons.Tool.mslib, without the MSVC detection.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
+import os
+import tempfile
+import string
+
import SCons.Defaults
import SCons.Tool
import SCons.Util
+import SCons.Errors
+
+class TempFileMunge:
+ """Same as SCons.Platform.TempFileMunge, but preserves LINK /LIB
+ together."""
+
+ def __init__(self, cmd):
+ self.cmd = cmd
+
+ def __call__(self, target, source, env, for_signature):
+ if for_signature:
+ return self.cmd
+ cmd = env.subst_list(self.cmd, 0, target, source)[0]
+ try:
+ maxline = int(env.subst('$MAXLINELENGTH'))
+ except ValueError:
+ maxline = 2048
+
+ if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
+ return self.cmd
+
+ # We do a normpath because mktemp() has what appears to be
+ # a bug in Windows that will use a forward slash as a path
+ # delimiter. Windows's link mistakes that for a command line
+ # switch and barfs.
+ #
+ # We use the .lnk suffix for the benefit of the Phar Lap
+ # linkloc linker, which likes to append an .lnk suffix if
+ # none is given.
+ tmp = os.path.normpath(tempfile.mktemp('.lnk'))
+ native_tmp = SCons.Util.get_native_path(tmp)
+
+ if env['SHELL'] and env['SHELL'] == 'sh':
+ # The sh shell will try to escape the backslashes in the
+ # path, so unescape them.
+ native_tmp = string.replace(native_tmp, '\\', r'\\\\')
+ # In Cygwin, we want to use rm to delete the temporary
+ # file, because del does not exist in the sh shell.
+ rm = env.Detect('rm') or 'del'
+ else:
+ # Don't use 'rm' if the shell is not sh, because rm won't
+ # work with the Windows shells (cmd.exe or command.com) or
+ # Windows path names.
+ rm = 'del'
+
+ prefix = env.subst('$TEMPFILEPREFIX')
+ if not prefix:
+ prefix = '@'
+
+ if cmd[0:2] == ['link', '/lib']:
+ split = 2
+ else:
+ split = 1
+
+ args = map(SCons.Subst.quote_spaces, cmd[split:])
+ open(tmp, 'w').write(string.join(args, " ") + "\n")
+ # XXX Using the SCons.Action.print_actions value directly
+ # like this is bogus, but expedient. This class should
+ # really be rewritten as an Action that defines the
+ # __call__() and strfunction() methods and lets the
+ # normal action-execution logic handle whether or not to
+ # print/execute the action. The problem, though, is all
+ # of that is decided before we execute this method as
+ # part of expanding the $TEMPFILE construction variable.
+ # Consequently, refactoring this will have to wait until
+ # we get more flexible with allowing Actions to exist
+ # independently and get strung together arbitrarily like
+ # Ant tasks. In the meantime, it's going to be more
+ # user-friendly to not let obsession with architectural
+ # purity get in the way of just being helpful, so we'll
+ # reach into SCons.Action directly.
+ if SCons.Action.print_actions:
+ print("Using tempfile "+native_tmp+" for command line:\n"+
+ " ".join(map(str,cmd)))
+ return cmd[:split] + [ prefix + native_tmp + '\n' + rm, native_tmp ]
def generate(env):
"""Add Builders and construction variables for lib to an Environment."""
SCons.Tool.createStaticLibBuilder(env)
- env['AR'] = 'lib'
+ if env.Detect('lib'):
+ env['AR'] = 'lib'
+ else:
+ # Recent WINDDK versions do not ship with lib.
+ env['AR'] = 'link /lib'
+ env['TEMPFILE'] = TempFileMunge
env['ARFLAGS'] = SCons.Util.CLVar('/nologo')
env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}"
env['LIBPREFIX'] = ''
env['LIBSUFFIX'] = '.lib'
def exists(env):
- return env.Detect('lib')
+ return env.Detect('lib') or env.Detect('link')
# vim:set ts=4 sw=4 et:
diff --git a/scons/winddk.py b/scons/winddk.py
index 6a99b83a83..afcea9909a 100644
--- a/scons/winddk.py
+++ b/scons/winddk.py
@@ -44,87 +44,90 @@ import msvc_sa
import mslib_sa
import mslink_sa
-def get_winddk_root(env):
- try:
- return os.environ['BASEDIR']
- except KeyError:
- pass
-
- version = "3790.1830"
-
- if SCons.Util.can_read_reg:
- key = r'SOFTWARE\Microsoft\WINDDK\%s\LFNDirectory' % version
- try:
- path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
- except SCons.Util.RegError:
- pass
- else:
- return path
-
+versions = [
+ '6001.18002',
+ '3790.1830',
+]
+
+def cpu_bin(target_cpu):
+ if target_cpu == 'i386':
+ return 'x86'
+ else:
+ return target_cpu
+
+def get_winddk_root(env, version):
default_path = os.path.join(r'C:\WINDDK', version)
if os.path.exists(default_path):
return default_path
-
return None
-def get_winddk_paths(env):
- """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
- of those three environment variables that should be set
- in order to execute the MSVC tools properly."""
+def get_winddk_paths(env, version, root):
+ version_major, version_minor = map(int, version.split('.'))
- WINDDKdir = None
- exe_paths = []
- lib_paths = []
- include_paths = []
-
- WINDDKdir = get_winddk_root(env)
- if WINDDKdir is None:
- raise SCons.Errors.InternalError, "WINDDK not found"
-
- exe_paths.append( os.path.join(WINDDKdir, 'bin') )
- exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') )
- include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') )
- lib_paths.append( os.path.join(WINDDKdir, 'lib') )
-
- target_os = 'wxp'
- target_cpu = 'i386'
+ if version_major >= 6000:
+ target_os = 'wlh'
+ else:
+ target_os = 'wxp'
+
+ if env['machine'] in ('generic', 'x86'):
+ target_cpu = 'i386'
+ elif env['machine'] == 'x86_64':
+ target_cpu = 'amd64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+
+ if version_major >= 6000:
+ # TODO: take in consideration the host cpu
+ bin_dir = os.path.join(root, 'bin', 'x86', cpu_bin(target_cpu))
+ else:
+ if target_cpu == 'i386':
+ bin_dir = os.path.join(root, 'bin', 'x86')
+ else:
+ # TODO: take in consideration the host cpu
+ bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
+
+ env.PrependENVPath('PATH', [bin_dir])
- env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os)
- env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt')
- env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os)
- env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os)
-
- env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
- env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu)
- env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
- env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
-
- include_path = string.join( include_paths, os.pathsep )
- lib_path = string.join(lib_paths, os.pathsep )
- exe_path = string.join(exe_paths, os.pathsep )
- return (include_path, lib_path, exe_path)
+ crt_inc_dir = os.path.join(root, 'inc', 'crt')
+ if version_major >= 6000:
+ sdk_inc_dir = os.path.join(root, 'inc', 'api')
+ ddk_inc_dir = os.path.join(root, 'inc', 'ddk')
+ wdm_inc_dir = os.path.join(root, 'inc', 'ddk')
+ else:
+ ddk_inc_dir = os.path.join(root, 'inc', 'ddk', target_os)
+ sdk_inc_dir = os.path.join(root, 'inc', target_os)
+ wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
+
+ env.PrependENVPath('INCLUDE', [
+ wdm_inc_dir,
+ ddk_inc_dir,
+ crt_inc_dir,
+ sdk_inc_dir,
+ ])
+
+ env.PrependENVPath('LIB', [
+ os.path.join(root, 'lib', 'crt', target_cpu),
+ os.path.join(root, 'lib', target_os, target_cpu),
+ ])
def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ for version in versions:
+ root = get_winddk_root(env, version)
+ if root is not None:
+ get_winddk_paths(env, version, root)
+ break
msvc_sa.generate(env)
mslib_sa.generate(env)
mslink_sa.generate(env)
- if not env.has_key('ENV'):
- env['ENV'] = {}
-
- try:
- include_path, lib_path, exe_path = get_winddk_paths(env)
-
- # since other tools can set these, we just make sure that the
- # relevant stuff from WINDDK is in there somewhere.
- env.PrependENVPath('INCLUDE', include_path)
- env.PrependENVPath('LIB', lib_path)
- env.PrependENVPath('PATH', exe_path)
- except (SCons.Util.RegError, SCons.Errors.InternalError):
- pass
-
def exists(env):
- return get_winddk_root(env) is not None
+ for version in versions:
+ if get_winddk_root(env, version) is not None:
+ return True
+ return False
# vim:set ts=4 sw=4 et:
diff --git a/scons/winsdk.py b/scons/winsdk.py
index 255f9c5a65..7e874a507b 100644
--- a/scons/winsdk.py
+++ b/scons/winsdk.py
@@ -77,13 +77,9 @@ def get_vc_paths(env):
raise SCons.Errors.InternalError, "Unsupported target machine"
include_dir = 'include'
- exe_path = os.path.join(vc_root, bin_dir)
- include_path = os.path.join(vc_root, include_dir)
- lib_path = os.path.join(vc_root, lib_dir)
-
- env.PrependENVPath('INCLUDE', include_path)
- env.PrependENVPath('LIB', lib_path)
- env.PrependENVPath('PATH', exe_path)
+ env.PrependENVPath('PATH', os.path.join(vc_root, bin_dir))
+ env.PrependENVPath('INCLUDE', os.path.join(vc_root, include_dir))
+ env.PrependENVPath('LIB', os.path.join(vc_root, lib_dir))
def get_sdk_root(env):
if SCons.Util.can_read_reg:
@@ -108,18 +104,14 @@ def get_sdk_paths(env):
if target_cpu in ('generic', 'x86'):
lib_dir = 'Lib'
elif target_cpu == 'x86_64':
- lib_dir = 'Lib/x64'
+ lib_dir = r'Lib\x64'
else:
raise SCons.Errors.InternalError, "Unsupported target machine"
include_dir = 'Include'
- exe_path = os.path.join(sdk_root, bin_dir)
- include_path = os.path.join(sdk_root, include_dir)
- lib_path = os.path.join(sdk_root, lib_dir)
-
- env.PrependENVPath('INCLUDE', include_path)
- env.PrependENVPath('LIB', lib_path)
- env.PrependENVPath('PATH', exe_path)
+ env.PrependENVPath('PATH', os.path.join(sdk_root, bin_dir))
+ env.PrependENVPath('INCLUDE', os.path.join(sdk_root, include_dir))
+ env.PrependENVPath('LIB', os.path.join(sdk_root, lib_dir))
def generate(env):
if not env.has_key('ENV'):