Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / scons / winddk.py
1 """winddk
2
3 Tool-specific initialization for Microsoft Windows DDK.
4
5 """
6
7 #
8 # Copyright (c) 2001-2007 The SCons Foundation
9 # Copyright (c) 2008 Tungsten Graphics, Inc.
10 #
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:
18 #
19 # The above copyright notice and this permission notice shall be included
20 # in all copies or substantial portions of the Software.
21 #
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.
29 #
30
31 import os.path
32 import re
33 import string
34
35 import SCons.Action
36 import SCons.Builder
37 import SCons.Errors
38 import SCons.Platform.win32
39 import SCons.Tool
40 import SCons.Util
41 import SCons.Warnings
42
43 import msvc_sa
44 import mslib_sa
45 import mslink_sa
46
47 def get_winddk_paths(env, version=None):
48 """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
49 of those three environment variables that should be set
50 in order to execute the MSVC tools properly."""
51
52 WINDDKdir = None
53 exe_paths = []
54 lib_paths = []
55 include_paths = []
56
57 if 'BASEDIR' in os.environ:
58 WINDDKdir = os.environ['BASEDIR']
59 else:
60 WINDDKdir = "C:\\WINDDK\\3790.1830"
61
62 exe_paths.append( os.path.join(WINDDKdir, 'bin') )
63 exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') )
64 include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') )
65 lib_paths.append( os.path.join(WINDDKdir, 'lib') )
66
67 target_os = 'wxp'
68 target_cpu = 'i386'
69
70 env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os)
71 env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt')
72 env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os)
73 env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os)
74
75 env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
76 env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu)
77 env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
78 env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
79
80 include_path = string.join( include_paths, os.pathsep )
81 lib_path = string.join(lib_paths, os.pathsep )
82 exe_path = string.join(exe_paths, os.pathsep )
83 return (include_path, lib_path, exe_path)
84
85 def generate(env):
86
87 msvc_sa.generate(env)
88 mslib_sa.generate(env)
89 mslink_sa.generate(env)
90
91 if not env.has_key('ENV'):
92 env['ENV'] = {}
93
94 try:
95 include_path, lib_path, exe_path = get_winddk_paths(env)
96
97 # since other tools can set these, we just make sure that the
98 # relevant stuff from WINDDK is in there somewhere.
99 env.PrependENVPath('INCLUDE', include_path)
100 env.PrependENVPath('LIB', lib_path)
101 env.PrependENVPath('PATH', exe_path)
102 except (SCons.Util.RegError, SCons.Errors.InternalError):
103 pass
104
105 def exists(env):
106 if not msvc_sa.exits(env):
107 return 0
108 if not mslib_sa.exits(env):
109 return 0
110 if not mslink_sa.exits(env):
111 return 0
112 return 1
113
114 # vim:set ts=4 sw=4 et: