OSDN Git Service

mesa/es: Add OpenGL ES XMLs.
[android-x86/external-mesa.git] / scons / wcesdk.py
1 """wcesdk
2
3 Tool-specific initialization for Microsoft Window CE SDKs.
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_wce500_paths(env):
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     exe_paths = []
53     lib_paths = []
54     include_paths = []
55
56     # mymic the batch files located in Microsoft eMbedded C++ 4.0\EVC\WCExxx\BIN
57     os_version = os.environ.get('OSVERSION', 'WCE500')
58     platform = os.environ.get('PLATFORM', 'STANDARDSDK_500')
59     wce_root = os.environ.get('WCEROOT', 'C:\\Program Files\\Microsoft eMbedded C++ 4.0')
60     sdk_root = os.environ.get('SDKROOT', 'C:\\Windows CE Tools')
61
62     target_cpu = 'x86'
63     cfg = 'none'
64
65     exe_paths.append( os.path.join(wce_root, 'COMMON', 'EVC', 'bin') )
66     exe_paths.append( os.path.join(wce_root, 'EVC', os_version, 'bin') )
67     include_paths.append( os.path.join(sdk_root, os_version, platform, 'include', target_cpu) )
68     include_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'include') )
69     include_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'include') )
70     lib_paths.append( os.path.join(sdk_root, os_version, platform, 'lib', target_cpu) )
71     lib_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'lib', target_cpu) )
72     lib_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'lib', target_cpu) )
73     
74     include_path = string.join( include_paths, os.pathsep )
75     lib_path = string.join(lib_paths, os.pathsep )
76     exe_path = string.join(exe_paths, os.pathsep )
77     return (include_path, lib_path, exe_path)
78
79 def get_wce600_root(env):
80     try:
81         return os.environ['_WINCEROOT']
82     except KeyError:
83         pass
84
85     if SCons.Util.can_read_reg:
86         key = r'SOFTWARE\Microsoft\Platform Builder\6.00\Directories\OS Install Dir'
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
93
94     default_path = os.path.join(r'C:\WINCE600', version)
95     if os.path.exists(default_path):
96         return default_path
97     
98     return None 
99
100 def get_wce600_paths(env):
101     """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
102     of those three environment variables that should be set
103     in order to execute the MSVC tools properly."""
104     
105     exe_paths = []
106     lib_paths = []
107     include_paths = []
108
109     # See also C:\WINCE600\public\common\oak\misc\wince.bat
110
111     wince_root = get_wce600_root(env)
112     if wince_root is None:
113         raise SCons.Errors.InternalError, "Windows CE 6.0 SDK not found"
114     
115     os_version = os.environ.get('_WINCEOSVER', '600')
116     platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
117     sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
118
119     platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
120     sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
121
122     host_cpu = os.environ.get('_HOSTCPUTYPE', 'i386')
123     target_cpu = os.environ.get('_TGTCPU', 'x86')
124
125     if env['debug']:
126         build = 'debug'
127     else:
128         build = 'retail'
129
130     try:
131         project_root = os.environ['_PROJECTROOT']
132     except KeyError:
133         # No project root defined -- use the common stuff instead
134         project_root = os.path.join(wince_root, 'public', 'common')
135
136     exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu) )
137     exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu, target_cpu) )
138     exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'bin', host_cpu) )
139     exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'misc') )
140
141     include_paths.append( os.path.join(project_root, 'sdk', 'inc') )
142     include_paths.append( os.path.join(project_root, 'oak', 'inc') )
143     include_paths.append( os.path.join(project_root, 'ddk', 'inc') )
144     include_paths.append( os.path.join(sdk_root, 'CE', 'inc') )
145     
146     lib_paths.append( os.path.join(project_root, 'sdk', 'lib', target_cpu, build) )
147     lib_paths.append( os.path.join(project_root, 'oak', 'lib', target_cpu, build) )
148     lib_paths.append( os.path.join(project_root, 'ddk', 'lib', target_cpu, build) )
149
150     include_path = string.join( include_paths, os.pathsep )
151     lib_path = string.join(lib_paths, os.pathsep )
152     exe_path = string.join(exe_paths, os.pathsep )
153     return (include_path, lib_path, exe_path)
154
155 def generate(env):
156
157     msvc_sa.generate(env)
158     mslib_sa.generate(env)
159     mslink_sa.generate(env)
160
161     if not env.has_key('ENV'):
162         env['ENV'] = {}
163     
164     try:
165         include_path, lib_path, exe_path = get_wce600_paths(env)
166
167         env.PrependENVPath('INCLUDE', include_path)
168         env.PrependENVPath('LIB', lib_path)
169         env.PrependENVPath('PATH', exe_path)
170     except (SCons.Util.RegError, SCons.Errors.InternalError):
171         pass
172
173 def exists(env):
174     return get_wce600_root(env) is not None
175
176 # vim:set ts=4 sw=4 et: