summaryrefslogtreecommitdiff
path: root/scons
diff options
context:
space:
mode:
Diffstat (limited to 'scons')
-rw-r--r--scons/gallium.py14
-rw-r--r--scons/generic.py14
-rw-r--r--scons/python.py4
-rw-r--r--scons/winsdk.py139
4 files changed, 162 insertions, 9 deletions
diff --git a/scons/gallium.py b/scons/gallium.py
index ecdeef06fd..e2cd0546c1 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -198,14 +198,17 @@ def generate(env):
env['toolchain'] = 'wcesdk'
env.Tool(env['toolchain'])
+ env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
+ env['msvc'] = env['CC'] == 'cl'
+
# shortcuts
debug = env['debug']
machine = env['machine']
platform = env['platform']
x86 = env['machine'] == 'x86'
ppc = env['machine'] == 'ppc'
- gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw'
- msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw'
+ gcc = env['gcc']
+ msvc = env['msvc']
# Put build output in a separate dir, which depends on the current
# configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
@@ -248,9 +251,12 @@ def generate(env):
('WINVER', '0x0501'),
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
'WIN32_LEAN_AND_MEAN',
- 'VC_EXTRALEAN',
- '_CRT_SECURE_NO_DEPRECATE',
]
+ if msvc:
+ cppdefines += [
+ 'VC_EXTRALEAN',
+ '_CRT_SECURE_NO_DEPRECATE',
+ ]
if debug:
cppdefines += ['_DEBUG']
if platform == 'winddk':
diff --git a/scons/generic.py b/scons/generic.py
index 01a374e363..03563e4c62 100644
--- a/scons/generic.py
+++ b/scons/generic.py
@@ -303,14 +303,17 @@ def generate(env):
# Load tool chain
env.Tool(env['toolchain'])
+ env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
+ env['msvc'] = env['CC'] == 'cl'
+
# shortcuts
debug = env['debug']
machine = env['machine']
platform = env['platform']
x86 = env['machine'] == 'x86'
ppc = env['machine'] == 'ppc'
- gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw'
- msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw'
+ gcc = env['gcc']
+ msvc = env['msvc']
# C preprocessor options
cppdefines = []
@@ -328,9 +331,12 @@ def generate(env):
#'UNICODE',
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
#'WIN32_LEAN_AND_MEAN',
- 'VC_EXTRALEAN',
- '_CRT_SECURE_NO_DEPRECATE',
]
+ if msvc:
+ cppdefines += [
+ 'VC_EXTRALEAN',
+ '_CRT_SECURE_NO_DEPRECATE',
+ ]
if debug:
cppdefines += ['_DEBUG']
if platform == 'winddk':
diff --git a/scons/python.py b/scons/python.py
index 539184dd39..9e94d056e1 100644
--- a/scons/python.py
+++ b/scons/python.py
@@ -38,7 +38,7 @@ import os.path
def generate(env):
# See http://www.scons.org/wiki/PythonExtensions
- if sys.platform in ['windows']:
+ if sys.platform in ['win32']:
python_root = sys.prefix
python_version = '%u%u' % sys.version_info[:2]
python_include = os.path.join(python_root, 'include')
@@ -56,6 +56,8 @@ def generate(env):
cppdefines = env['CPPDEFINES']
cppdefines = [define for define in cppdefines if define != '_DEBUG']
env.Replace(CPPDEFINES = cppdefines)
+ env.AppendUnique(CPPFLAGS = ['/U_DEBUG'])
+ env.AppendUnique(LINKFLAGS = ['/nodefaultlib:python25_d.lib'])
else:
#env.ParseConfig('python-config --cflags --ldflags --libs')
env.AppendUnique(CPPPATH = [distutils.sysconfig.get_python_inc()])
diff --git a/scons/winsdk.py b/scons/winsdk.py
new file mode 100644
index 0000000000..255f9c5a65
--- /dev/null
+++ b/scons/winsdk.py
@@ -0,0 +1,139 @@
+"""winsdk
+
+Tool-specific initialization for Microsoft Windows SDK.
+
+"""
+
+#
+# Copyright (c) 2001-2007 The SCons Foundation
+# Copyright (c) 2008 Tungsten Graphics, Inc.
+# Copyright (c) 2009 VMware, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os.path
+import platform
+
+import SCons.Errors
+import SCons.Util
+
+import msvc_sa
+import mslib_sa
+import mslink_sa
+
+
+def get_vs_root(env):
+ # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7
+ path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0')
+ return path
+
+def get_vs_paths(env):
+ vs_root = get_vs_root(env)
+ if vs_root is None:
+ raise SCons.Errors.InternalError, "WINSDK compiler not found"
+
+ tool_path = os.path.join(vs_root, 'Common7', 'IDE')
+
+ env.PrependENVPath('PATH', tool_path)
+
+def get_vc_root(env):
+ # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7
+ path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0', 'VC')
+ return path
+
+def get_vc_paths(env):
+ vc_root = get_vc_root(env)
+ if vc_root is None:
+ raise SCons.Errors.InternalError, "WINSDK compiler not found"
+
+ target_cpu = env['machine']
+
+ if target_cpu in ('generic', 'x86'):
+ bin_dir = 'bin'
+ lib_dir = 'lib'
+ elif target_cpu == 'x86_64':
+ # TODO: take in consideration the host cpu
+ bin_dir = r'bin\x86_amd64'
+ lib_dir = r'lib\amd64'
+ else:
+ 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)
+
+def get_sdk_root(env):
+ if SCons.Util.can_read_reg:
+ key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder'
+ try:
+ path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
+ except SCons.Util.RegError:
+ pass
+ else:
+ return path
+
+ return None
+
+def get_sdk_paths(env):
+ sdk_root = get_sdk_root(env)
+ if sdk_root is None:
+ raise SCons.Errors.InternalError, "WINSDK not found"
+
+ target_cpu = env['machine']
+
+ bin_dir = 'Bin'
+ if target_cpu in ('generic', 'x86'):
+ lib_dir = 'Lib'
+ elif target_cpu == 'x86_64':
+ lib_dir = '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)
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ get_vs_paths(env)
+ get_vc_paths(env)
+ get_sdk_paths(env)
+
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
+
+def exists(env):
+ return get_vc_root(env) is not None and get_sdk_root(env) is not None
+
+# vim:set ts=4 sw=4 et: