blob: bdaab7d19fd6503c7798c08f0fb32f3bdbb1b993 [file] [log] [blame]
José Fonsecaf78cc242008-06-23 12:49:45 +09001"""wcesdk
2
3Tool-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
31import os.path
32import re
33import string
34
35import SCons.Action
36import SCons.Builder
37import SCons.Errors
38import SCons.Platform.win32
39import SCons.Tool
40import SCons.Util
41import SCons.Warnings
42
43import msvc_sa
44import mslib_sa
45import mslink_sa
46
47def 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
79def get_wce600_paths(env):
80 """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
81 of those three environment variables that should be set
82 in order to execute the MSVC tools properly."""
83
84 exe_paths = []
85 lib_paths = []
86 include_paths = []
87
88 # See also C:\WINCE600\public\common\oak\misc\wince.bat
89
90 os_version = os.environ.get('_winceosver', '600')
91 wince_root = os.environ.get('_winceroot', r'C:\WINCE600')
92 platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform'))
93 sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk'))
94
95 platform_root = os.environ.get('_platformroot', os.path.join(wince_root, 'platform'))
96 sdk_root = os.environ.get('_sdkroot' ,os.path.join(wince_root, 'sdk'))
97
98 host_cpu = os.environ.get('_hostcputype', 'i386')
99 target_cpu = os.environ.get('_tgtcpu', 'x86')
100
101 if env['debug']:
102 build = 'debug'
103 else:
104 build = 'retail'
105
106 try:
107 project_root = os.environ['_projectroot']
108 except KeyError:
109 # No project root defined -- use the common stuff instead
110 project_root = os.path.join(wince_root, 'public', 'common')
111
112 exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu) )
113 exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu, target_cpu) )
114 exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'bin', host_cpu) )
115 exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'misc') )
116
117 include_paths.append( os.path.join(project_root, 'sdk', 'inc') )
118 include_paths.append( os.path.join(project_root, 'oak', 'inc') )
119 include_paths.append( os.path.join(project_root, 'ddk', 'inc') )
120 include_paths.append( os.path.join(sdk_root, 'CE', 'inc') )
121
122 lib_paths.append( os.path.join(project_root, 'sdk', 'lib', target_cpu, build) )
123 lib_paths.append( os.path.join(project_root, 'oak', 'lib', target_cpu, build) )
124 lib_paths.append( os.path.join(project_root, 'ddk', 'lib', target_cpu, build) )
125
126 include_path = string.join( include_paths, os.pathsep )
127 lib_path = string.join(lib_paths, os.pathsep )
128 exe_path = string.join(exe_paths, os.pathsep )
129 return (include_path, lib_path, exe_path)
130
131def generate(env):
132
133 msvc_sa.generate(env)
134 mslib_sa.generate(env)
135 mslink_sa.generate(env)
136
137 if not env.has_key('ENV'):
138 env['ENV'] = {}
139
140 try:
141 include_path, lib_path, exe_path = get_wce600_paths(env)
142
143 env.PrependENVPath('INCLUDE', include_path)
144 env.PrependENVPath('LIB', lib_path)
145 env.PrependENVPath('PATH', exe_path)
146 except (SCons.Util.RegError, SCons.Errors.InternalError):
147 pass
148
149def exists(env):
150 if not msvc_sa.exits(env):
151 return 0
152 if not mslib_sa.exits(env):
153 return 0
154 if not mslink_sa.exits(env):
155 return 0
156 return 1
157
158# vim:set ts=4 sw=4 et: