i965: Request that returns be lowered in shader main
[mesa/nouveau-pmpeg.git] / scons / winsdk.py
blob7e874a507b8b6e75c71a93d826dcfe0a0c7d02ba
1 """winsdk
3 Tool-specific initialization for Microsoft Windows SDK.
5 """
8 # Copyright (c) 2001-2007 The SCons Foundation
9 # Copyright (c) 2008 Tungsten Graphics, Inc.
10 # Copyright (c) 2009 VMware, Inc.
12 # Permission is hereby granted, free of charge, to any person obtaining
13 # a copy of this software and associated documentation files (the
14 # "Software"), to deal in the Software without restriction, including
15 # without limitation the rights to use, copy, modify, merge, publish,
16 # distribute, sublicense, and/or sell copies of the Software, and to
17 # permit persons to whom the Software is furnished to do so, subject to
18 # the following conditions:
20 # The above copyright notice and this permission notice shall be included
21 # in all copies or substantial portions of the Software.
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
24 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
25 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 import os.path
33 import platform
35 import SCons.Errors
36 import SCons.Util
38 import msvc_sa
39 import mslib_sa
40 import mslink_sa
43 def get_vs_root(env):
44 # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7
45 path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0')
46 return path
48 def get_vs_paths(env):
49 vs_root = get_vs_root(env)
50 if vs_root is None:
51 raise SCons.Errors.InternalError, "WINSDK compiler not found"
53 tool_path = os.path.join(vs_root, 'Common7', 'IDE')
55 env.PrependENVPath('PATH', tool_path)
57 def get_vc_root(env):
58 # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7
59 path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0', 'VC')
60 return path
62 def get_vc_paths(env):
63 vc_root = get_vc_root(env)
64 if vc_root is None:
65 raise SCons.Errors.InternalError, "WINSDK compiler not found"
67 target_cpu = env['machine']
69 if target_cpu in ('generic', 'x86'):
70 bin_dir = 'bin'
71 lib_dir = 'lib'
72 elif target_cpu == 'x86_64':
73 # TODO: take in consideration the host cpu
74 bin_dir = r'bin\x86_amd64'
75 lib_dir = r'lib\amd64'
76 else:
77 raise SCons.Errors.InternalError, "Unsupported target machine"
78 include_dir = 'include'
80 env.PrependENVPath('PATH', os.path.join(vc_root, bin_dir))
81 env.PrependENVPath('INCLUDE', os.path.join(vc_root, include_dir))
82 env.PrependENVPath('LIB', os.path.join(vc_root, lib_dir))
84 def get_sdk_root(env):
85 if SCons.Util.can_read_reg:
86 key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder'
87 try:
88 path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
89 except SCons.Util.RegError:
90 pass
91 else:
92 return path
94 return None
96 def get_sdk_paths(env):
97 sdk_root = get_sdk_root(env)
98 if sdk_root is None:
99 raise SCons.Errors.InternalError, "WINSDK not found"
101 target_cpu = env['machine']
103 bin_dir = 'Bin'
104 if target_cpu in ('generic', 'x86'):
105 lib_dir = 'Lib'
106 elif target_cpu == 'x86_64':
107 lib_dir = r'Lib\x64'
108 else:
109 raise SCons.Errors.InternalError, "Unsupported target machine"
110 include_dir = 'Include'
112 env.PrependENVPath('PATH', os.path.join(sdk_root, bin_dir))
113 env.PrependENVPath('INCLUDE', os.path.join(sdk_root, include_dir))
114 env.PrependENVPath('LIB', os.path.join(sdk_root, lib_dir))
116 def generate(env):
117 if not env.has_key('ENV'):
118 env['ENV'] = {}
120 get_vs_paths(env)
121 get_vc_paths(env)
122 get_sdk_paths(env)
124 msvc_sa.generate(env)
125 mslib_sa.generate(env)
126 mslink_sa.generate(env)
128 def exists(env):
129 return get_vc_root(env) is not None and get_sdk_root(env) is not None
131 # vim:set ts=4 sw=4 et: