Skip to content
This repository
Newer
Older
100755 197 lines (168 sloc) 6.876 kb
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
1 #! /usr/bin/env python
2 #
3 # SCons - a Software Constructor
4 #
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
5 # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 The SCons Foundation
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
6 #
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
14 #
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
17 #
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
26 __revision__ = "src/script/scons.py issue-2856:2676:d23b7a2f45e8 2012/08/05 15:38:28 garyo"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
27
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
28 __version__ = "2.2.0"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
29
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
30 __build__ = "issue-2856:2676:d23b7a2f45e8[MODIFIED]"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
31
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
32 __buildsys__ = "oberbrunner-dev"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
33
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
34 __date__ = "2012/08/05 15:38:28"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
35
02e07f9c »
2012-08-16 + update scons to the latest version 2.2.0
36 __developer__ = "garyo"
d3bb1a2a »
2011-10-04 + upgrade scons to 2.1.0 series
37
38 import os
39 import sys
40
41 ##############################################################################
42 # BEGIN STANDARD SCons SCRIPT HEADER
43 #
44 # This is the cut-and-paste logic so that a self-contained script can
45 # interoperate correctly with different SCons versions and installation
46 # locations for the engine. If you modify anything in this section, you
47 # should also change other scripts that use this same header.
48 ##############################################################################
49
50 # Strip the script directory from sys.path() so on case-insensitive
51 # (WIN32) systems Python doesn't think that the "scons" script is the
52 # "SCons" package. Replace it with our own library directories
53 # (version-specific first, in case they installed by hand there,
54 # followed by generic) so we pick up the right version of the build
55 # engine modules if they're in either directory.
56
57
58 # Check to see if the python version is > 3.0 which is currently unsupported
59 # If so exit with error message
60 try:
61 if sys.version_info >= (3,0,0):
62 msg = "scons: *** SCons version %s does not run under Python version %s.\n\
63 Python 3.0 and later are not yet supported.\n"
64 sys.stderr.write(msg % (__version__, sys.version.split()[0]))
65 sys.exit(1)
66 except AttributeError:
67 # Pre-1.6 Python has no sys.version_info
68 # No need to check version as we then know the version is < 3.0.0 and supported
69 pass
70
71 script_dir = sys.path[0]
72
73 if script_dir in sys.path:
74 sys.path.remove(script_dir)
75
76 libs = []
77
78 if "SCONS_LIB_DIR" in os.environ:
79 libs.append(os.environ["SCONS_LIB_DIR"])
80
81 local_version = 'scons-local-' + __version__
82 local = 'scons-local'
83 if script_dir:
84 local_version = os.path.join(script_dir, local_version)
85 local = os.path.join(script_dir, local)
86 libs.append(os.path.abspath(local_version))
87 libs.append(os.path.abspath(local))
88
89 scons_version = 'scons-%s' % __version__
90
91 # preferred order of scons lookup paths
92 prefs = []
93
94 try:
95 import pkg_resources
96 except ImportError:
97 pass
98 else:
99 # when running from an egg add the egg's directory
100 try:
101 d = pkg_resources.get_distribution('scons')
102 except pkg_resources.DistributionNotFound:
103 pass
104 else:
105 prefs.append(d.location)
106
107 if sys.platform == 'win32':
108 # sys.prefix is (likely) C:\Python*;
109 # check only C:\Python*.
110 prefs.append(sys.prefix)
111 prefs.append(os.path.join(sys.prefix, 'Lib', 'site-packages'))
112 else:
113 # On other (POSIX) platforms, things are more complicated due to
114 # the variety of path names and library locations. Try to be smart
115 # about it.
116 if script_dir == 'bin':
117 # script_dir is `pwd`/bin;
118 # check `pwd`/lib/scons*.
119 prefs.append(os.getcwd())
120 else:
121 if script_dir == '.' or script_dir == '':
122 script_dir = os.getcwd()
123 head, tail = os.path.split(script_dir)
124 if tail == "bin":
125 # script_dir is /foo/bin;
126 # check /foo/lib/scons*.
127 prefs.append(head)
128
129 head, tail = os.path.split(sys.prefix)
130 if tail == "usr":
131 # sys.prefix is /foo/usr;
132 # check /foo/usr/lib/scons* first,
133 # then /foo/usr/local/lib/scons*.
134 prefs.append(sys.prefix)
135 prefs.append(os.path.join(sys.prefix, "local"))
136 elif tail == "local":
137 h, t = os.path.split(head)
138 if t == "usr":
139 # sys.prefix is /foo/usr/local;
140 # check /foo/usr/local/lib/scons* first,
141 # then /foo/usr/lib/scons*.
142 prefs.append(sys.prefix)
143 prefs.append(head)
144 else:
145 # sys.prefix is /foo/local;
146 # check only /foo/local/lib/scons*.
147 prefs.append(sys.prefix)
148 else:
149 # sys.prefix is /foo (ends in neither /usr or /local);
150 # check only /foo/lib/scons*.
151 prefs.append(sys.prefix)
152
153 temp = [os.path.join(x, 'lib') for x in prefs]
154 temp.extend([os.path.join(x,
155 'lib',
156 'python' + sys.version[:3],
157 'site-packages') for x in prefs])
158 prefs = temp
159
160 # Add the parent directory of the current python's library to the
161 # preferences. On SuSE-91/AMD64, for example, this is /usr/lib64,
162 # not /usr/lib.
163 try:
164 libpath = os.__file__
165 except AttributeError:
166 pass
167 else:
168 # Split /usr/libfoo/python*/os.py to /usr/libfoo/python*.
169 libpath, tail = os.path.split(libpath)
170 # Split /usr/libfoo/python* to /usr/libfoo
171 libpath, tail = os.path.split(libpath)
172 # Check /usr/libfoo/scons*.
173 prefs.append(libpath)
174
175 # Look first for 'scons-__version__' in all of our preference libs,
176 # then for 'scons'.
177 libs.extend([os.path.join(x, scons_version) for x in prefs])
178 libs.extend([os.path.join(x, 'scons') for x in prefs])
179
180 sys.path = libs + sys.path
181
182 ##############################################################################
183 # END STANDARD SCons SCRIPT HEADER
184 ##############################################################################
185
186 if __name__ == "__main__":
187 import SCons.Script
188 # this does all the work, and calls sys.exit
189 # with the proper exit status when done.
190 SCons.Script.main()
191
192 # Local Variables:
193 # tab-width:4
194 # indent-tabs-mode:nil
195 # End:
196 # vim: set expandtab tabstop=4 shiftwidth=4:
Something went wrong with that request. Please try again.