6a99b83a835ff9df9b2dfad71c15c79bf36437d4
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
47 def get_winddk_root(env
):
49 return os
.environ
['BASEDIR']
55 if SCons
.Util
.can_read_reg
:
56 key
= r
'SOFTWARE\Microsoft\WINDDK\%s\LFNDirectory' % version
58 path
, t
= SCons
.Util
.RegGetValue(SCons
.Util
.HKEY_LOCAL_MACHINE
, key
)
59 except SCons
.Util
.RegError
:
64 default_path
= os
.path
.join(r
'C:\WINDDK', version
)
65 if os
.path
.exists(default_path
):
70 def get_winddk_paths(env
):
71 """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
72 of those three environment variables that should be set
73 in order to execute the MSVC tools properly."""
80 WINDDKdir
= get_winddk_root(env
)
82 raise SCons
.Errors
.InternalError
, "WINDDK not found"
84 exe_paths
.append( os
.path
.join(WINDDKdir
, 'bin') )
85 exe_paths
.append( os
.path
.join(WINDDKdir
, 'bin', 'x86') )
86 include_paths
.append( os
.path
.join(WINDDKdir
, 'inc', 'wxp') )
87 lib_paths
.append( os
.path
.join(WINDDKdir
, 'lib') )
92 env
['SDK_INC_PATH'] = os
.path
.join(WINDDKdir
, 'inc', target_os
)
93 env
['CRT_INC_PATH'] = os
.path
.join(WINDDKdir
, 'inc', 'crt')
94 env
['DDK_INC_PATH'] = os
.path
.join(WINDDKdir
, 'inc', 'ddk', target_os
)
95 env
['WDM_INC_PATH'] = os
.path
.join(WINDDKdir
, 'inc', 'ddk', 'wdm', target_os
)
97 env
['SDK_LIB_PATH'] = os
.path
.join(WINDDKdir
, 'lib', target_os
, target_cpu
)
98 env
['CRT_LIB_PATH'] = os
.path
.join(WINDDKdir
, 'lib', 'crt', target_cpu
)
99 env
['DDK_LIB_PATH'] = os
.path
.join(WINDDKdir
, 'lib', target_os
, target_cpu
)
100 env
['WDM_LIB_PATH'] = os
.path
.join(WINDDKdir
, 'lib', target_os
, target_cpu
)
102 include_path
= string
.join( include_paths
, os
.pathsep
)
103 lib_path
= string
.join(lib_paths
, os
.pathsep
)
104 exe_path
= string
.join(exe_paths
, os
.pathsep
)
105 return (include_path
, lib_path
, exe_path
)
109 msvc_sa
.generate(env
)
110 mslib_sa
.generate(env
)
111 mslink_sa
.generate(env
)
113 if not env
.has_key('ENV'):
117 include_path
, lib_path
, exe_path
= get_winddk_paths(env
)
119 # since other tools can set these, we just make sure that the
120 # relevant stuff from WINDDK is in there somewhere.
121 env
.PrependENVPath('INCLUDE', include_path
)
122 env
.PrependENVPath('LIB', lib_path
)
123 env
.PrependENVPath('PATH', exe_path
)
124 except (SCons
.Util
.RegError
, SCons
.Errors
.InternalError
):
128 return get_winddk_root(env
) is not None
130 # vim:set ts=4 sw=4 et: