Move most of the code from the scons script into a SCons module.
[scons.git] / src / script / scons.py
1 #! /usr/bin/env python
2 #
3 # SCons - a Software Constructor
4 #
5 # Copyright (c) 2001 Steven Knight
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 #
26
27 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28
29 import sys
30 import os.path
31 import os
32
33 #XXX once we migrate to the new scheme of using /usr/lib/scons
34 #    instead of /usr/lib/scons-X.Y this hardcoding will go away:
35 scons_lib_dir = "scons-0.01"
36
37 script_dir = sys.path[0]
38 if os.environ.has_key("SCONS_LIB_DIR"):
39     lib_dir = os.environ["SCONS_LIB_DIR"]
40 elif script_dir and script_dir != os.curdir:
41     (head, tail) = os.path.split(script_dir)
42     lib_dir = os.path.join(head, "lib", scons_lib_dir)
43 else:
44     lib_dir = os.path.join(os.pardir, "lib", scons_lib_dir)
45
46 sys.path = [lib_dir] + sys.path
47
48 import SCons.Script
49 SCons.Script.main()