3 Tool-specific initialization for Microsoft Windows DDK.
8 # Copyright (c) 2001-2007 The SCons Foundation
9 # Copyright (c) 2008 Tungsten Graphics, Inc.
11 # Permission is hereby granted, free of charge, to any person obtaining
12 # a copy of this software and associated documentation files (the
13 # "Software"), to deal in the Software without restriction, including
14 # without limitation the rights to use, copy, modify, merge, publish,
15 # distribute, sublicense, and/or sell copies of the Software, and to
16 # permit persons to whom the Software is furnished to do so, subject to
17 # the following conditions:
19 # The above copyright notice and this permission notice shall be included
20 # in all copies or substantial portions of the Software.
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
23 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 import SCons.Platform.win32
52 def cpu_bin(target_cpu):
53 if target_cpu == 'i386':
58 def get_winddk_root(env, version):
59 default_path = os.path.join(r'C:\WINDDK', version)
60 if os.path.exists(default_path):
64 def get_winddk_paths(env, version, root):
65 version_major, version_minor = map(int, version.split('.'))
67 if version_major >= 6000:
72 if env['machine'] in ('generic', 'x86'):
74 elif env['machine'] == 'x86_64':
77 raise SCons.Errors.InternalError, "Unsupported target machine"
79 if version_major >= 6000:
80 # TODO: take in consideration the host cpu
81 bin_dir = os.path.join(root, 'bin', 'x86', cpu_bin(target_cpu))
83 if target_cpu == 'i386':
84 bin_dir = os.path.join(root, 'bin', 'x86')
86 # TODO: take in consideration the host cpu
87 bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
89 crt_inc_dir = os.path.join(root, 'inc', 'crt')
90 if version_major >= 6000:
91 sdk_inc_dir = os.path.join(root, 'inc', 'api')
92 ddk_inc_dir = os.path.join(root, 'inc', 'ddk')
93 wdm_inc_dir = os.path.join(root, 'inc', 'ddk')
95 ddk_inc_dir = os.path.join(root, 'inc', 'ddk', target_os)
96 sdk_inc_dir = os.path.join(root, 'inc', target_os)
97 wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
99 if env['toolchain'] == 'winddk':
100 env.PrependENVPath('PATH', [bin_dir])
101 env.PrependENVPath('INCLUDE', [
107 env.PrependENVPath('LIB', [
108 os.path.join(root, 'lib', 'crt', target_cpu),
109 os.path.join(root, 'lib', target_os, target_cpu),
111 elif env['toolchain'] == 'crossmingw':
112 env.Prepend(CPPFLAGS = [
113 '-isystem', ddk_inc_dir,
114 '-isystem', sdk_inc_dir,
117 env.Prepend(CPPPATH = [
122 env.Prepend(LIBPATH = [
123 os.path.join(root, 'lib', target_os, target_cpu),
128 if not env.has_key('ENV'):
131 for version in versions:
132 root = get_winddk_root(env, version)
134 get_winddk_paths(env, version, root)
137 if env['toolchain'] == 'winddk':
138 msvc_sa.generate(env)
139 mslib_sa.generate(env)
140 mslink_sa.generate(env)
143 for version in versions:
144 if get_winddk_root(env, version) is not None:
148 # vim:set ts=4 sw=4 et: