Files
unison/waf

339 lines
116 KiB
Plaintext
Raw Normal View History

#! /usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2005 (ita)
import os, sys
if 'PSYCOWAF' in os.environ:
try:
import psyco
psyco.full()
except:
pass
VERSION="1.1.1"
REVISION="1420549696"
INSTALL=sys.platform=='win32' and 'c:/temp' or '/usr/local'
cwd = os.getcwd()
def decodeAscii85(s):
out=[]
app=out.append
s=''.join(s.split()).replace('z','!!!!!')
p1,p2=divmod(len(s), 5)
stop=5*p1
p3,p4=s[0:stop],s[stop:]
for i in range(p1):
off=i*5
a=ord(p3[off])-33
b=ord(p3[off+1])-33
c=ord(p3[off+2])-33
d=ord(p3[off+3])-33
e=ord(p3[off+4])-33
num=(52200625L*a)+(614125*b)+(7225*c)+(85*d)+e
x,p=divmod(num,256)
x,o=divmod(x,256)
m,n=divmod(x,256)
app(chr(m)+chr(n)+chr(o)+chr(p))
if p2:
while len(p4)<5: p4=p4+'!'
a=ord(p4[0])-33
b=ord(p4[1])-33
c=ord(p4[2])-33
d=ord(p4[3])-33
e=ord(p4[4])-33
num=(52200625L*a)+(614125*b)+(7225*c)+(85*d)+e
x,p=divmod(num,256)
x,o=divmod(x,256)
m,n=divmod(x, 256)
if p2==2: app(chr(m))
elif p2==3: app(chr(m)+chr(n))
elif p2==4: app(chr(m)+chr(n)+chr(o))
return ''.join(out)
# wafdir is needed to parse the command-line arguments or print the version number
wafdir=None # SPECIAL LINE
def uncompress_wafdir(newdir):
file = open(sys.argv[0], 'rb')
while 1:
line = file.readline()
if not line:
print "This is a stripped-down waf, there is no wafadmin directory available"
print "Please set WAFDIR to a directory containing a directory named wafadmin"
print "Or use the full waf version available freely at http://freehackers.org/~tnagy/bksys.html"
print "\033[91mNo wafadmin: cannot execute anything (error)\033[0m"
sys.exit(1)
line=line.rstrip()
if line=='# ===>BEGIN WOOF<===':
cnt = file.readline()
if not cnt:
print "Corrupted waf (1)"
sys.exit(1)
line = file.readline().rstrip()
if line!='# ===>END WOOF<===':
print "Corrupted waf (2)"
sys.exit(1)
break
if not cnt:
print "Corrupted waf (3)"
sys.exit(1)
cnt = decodeAscii85(cnt[1:])
# create wafadmin
import shutil
try: shutil.rmtree(newdir)
except OSError: pass
try: os.makedirs(newdir)
except OSError:
print "Could uncompress waf-local into %s"%newdir
print "Please install waf system-wide or move waf in a writeable directory"
sys.exit(1)
os.chdir(newdir)
file = open('wafadmin.tar.bz2', 'wb')
file.write(cnt)
file.close()
# now we have the tar file to open
import tarfile
tar = tarfile.open('wafadmin.tar.bz2')
for tarinfo in tar:
tar.extract(tarinfo)
tar.close()
# cleanup the tarfile and chdir to the previous directory
os.chmod('wafadmin', 0755)
os.chmod('wafadmin'+os.sep+'Tools', 0755)
os.unlink('wafadmin.tar.bz2')
os.chdir(cwd)
global wafdir
wafdir = newdir
def try_wafdir(dir):
global wafdir
if wafdir: return
try:
os.stat(os.path.join(dir, 'wafadmin'))
wafdir = os.path.abspath(dir)
except OSError:
pass
def find_wafadmin():
global wafdir
name = sys.argv[0]
# wafadmin may be in $WAFDIR (developers)
if 'WAFDIR' in os.environ:
try_wafdir(os.environ['WAFDIR'])
if wafdir: return
# waf-light is a special beast
if name[-5:] == 'light':
try_wafdir(os.path.dirname(os.path.abspath(name)))
if wafdir: return
print "\033[91mwaf-light in use, wafadmin not found -> export WAFDIR=/folder\033[0m"
sys.exit(1)
if not wafdir:
dir = "/lib/waf-%s-%s/" % (VERSION, REVISION)
for i in [INSTALL, '/usr', '/usr/local', '/opt']:
try_wafdir(i+dir)
if wafdir: return
# remove $HOME/.waf-version if asked to
if wafdir:
if "--nocache" in sys.argv:
import shutil
print "removing the local wafdir", wafdir
try: shutil.rmtree(wafdir)
except OSError: pass
try: os.stat(wafdir)
except OSError: wafdir=None
if wafdir: return
# look in the directory containing waf
if sys.platform == 'win32': s='waf-%s-%s'
else: s='.waf-%s-%s'
dir = os.path.join(os.path.dirname(os.path.abspath(name)), s % (VERSION, REVISION))
try_wafdir(dir)
if wafdir: return
# not found, uncompress
wafdir = dir
uncompress_wafdir(dir)
# run the test
find_wafadmin()
if "-vv" in sys.argv: print "wafdir is ", wafdir
# Update sys.path and import our modules
wafadmindir = os.path.join(wafdir, 'wafadmin')
tooldir = os.path.join(wafadmindir, 'Tools')
sys.path = [wafadmindir, tooldir] + sys.path
import Options, Params, Utils
from Params import fatal, warning
# Set the directory containing the tools
Params.g_tooldir = [tooldir]
Params.g_cwd_launch = cwd
if Params.g_version != VERSION:
fatal('version mismatch waf %s <-> wafadmin %s (wafdir %s)' % (VERSION, Params.g_version, wafdir))
# some command-line options can be processed immediately
if '--version' in sys.argv:
opt_obj = Options.Handler()
opt_obj.parse_args()
sys.exit(0)
# now find the wscript file
msg1 = 'Waf: *** Nothing to do! Please run waf from a directory containing a file named "wscript"'
# Some people want to configure their projects gcc-style:
# mkdir build && cd build && ../waf configure && ../waf
# check that this is really what is wanted
build_dir_override = None
candidate = None
lst = os.listdir(cwd)
xml = 0
#check if a wscript or a wscript_xml file is in current directory
if (not 'wscript' in lst) and (not 'wscript_xml' in lst):
if 'configure' in sys.argv:
#set the build directory with the current directory
build_dir_override = cwd
if 'wscript_build' in lst:
#try to find the wscript root
candidate = cwd
else:
#wscript or wscript_xml is in current directory, use this directory as candidate
candidate = cwd
try:
#check the following dirs for wscript or wscript_xml
search_for_candidate = True
if not candidate:
#check first the calldir if there is wscript or wscript_xml
#for example: /usr/src/configure the calldir would be /usr/src
calldir = os.path.abspath(os.path.dirname(sys.argv[0]))
lst_calldir = os.listdir(calldir)
if 'wscript' in lst_calldir:
candidate = calldir
search_for_candidate = False
if 'wscript_xml' in lst_calldir:
candidate = calldir
xml = 1
search_for_candidate = False
if "--make-waf" in sys.argv and candidate:
search_for_candidate = False
#check all directories above current dir for wscript or wscript_xml if still not found
while search_for_candidate:
if len(cwd) <= 3:
break # stop at / or c:
dirlst = os.listdir(cwd)
if 'wscript' in dirlst:
candidate = cwd
xml = 0
if 'wscript_xml' in dirlst:
candidate = cwd
xml = 1
break
if 'configure' in sys.argv and candidate:
break
if Params.g_lockfile in dirlst:
break
cwd = cwd[:cwd.rfind(os.sep)] # climb up
except:
fatal(msg1)
if not candidate:
# check if the user only wanted to display the help
if '-h' in sys.argv or '--help' in sys.argv:
warning('No wscript file found: the help message may be incomplete')
opt_obj = Options.Handler()
opt_obj.parse_args()
sys.exit(0)
else:
fatal(msg1)
# We have found wscript, but there is no guarantee that it is valid
os.chdir(candidate)
# xml -> jump to the parser
if xml:
from XMLScripting import compile
compile(candidate+os.sep+'wscript_xml')
else:
# define the main module containing the functions init, shutdown, ..
Utils.set_main_module(os.path.join(candidate, 'wscript'))
if build_dir_override:
try:
# test if user has set the blddir in wscript.
blddir = Utils.g_module.blddir
msg = 'Overriding build directory %s with %s' % (blddir, build_dir_override)
Params.niceprint(msg, 'WARNING', 'waf')
except:
pass
Utils.g_module.blddir = build_dir_override
# fetch the custom command-line options recursively and in a procedural way
opt_obj = Options.Handler()
opt_obj.sub_options('') # will look in wscript
opt_obj.parse_args()
# use the parser results
if Params.g_commands['dist']:
# try to use the user-defined dist function first, fallback to the waf scheme
try:
Utils.g_module.dist()
sys.exit(0)
except AttributeError:
pass
try: appname = Utils.g_module.APPNAME
except: appname = 'noname'
try:
get_version = Utils.g_module.get_version
except AttributeError:
try:
version = Utils.g_module.VERSION
except AttributeError:
version = '1.0'
else:
version = get_version()
from Scripting import Dist
Dist(appname, version)
sys.exit(0)
elif Params.g_commands['distclean']:
# try to use the user-defined distclean first, fallback to the waf scheme
try:
Utils.g_module.distclean()
sys.exit(0)
except AttributeError:
pass
from Scripting import DistClean
DistClean()
sys.exit(0)
try: Utils.g_module.init()
except AttributeError: pass
import Scripting
try: Scripting.Main()
except KeyboardInterrupt: Params.fatal('build interrupted')
#import hotshot
#prof=hotshot.Profile("/tmp/proftest.txt")
#prof.runcall(Scripting.Main)
#prof.close()
# ===>BEGIN WOOF<===
#6<\%_0gSqh;d#""QRi4MNW9%Ys8;Tjs8W-!s8W-!s8W*A!!!?/+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