Browse Source

Upgrade waf to 1.5.10

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
a73227bf28
  1. 15
      tools/waf-light
  2. 0
      tools/wafadmin/3rdparty/boost.py
  3. 27
      tools/wafadmin/3rdparty/fluid.py
  4. 5
      tools/wafadmin/Build.py
  5. 6
      tools/wafadmin/Constants.py
  6. 2
      tools/wafadmin/Environment.py
  7. 9
      tools/wafadmin/Logs.py
  8. 8
      tools/wafadmin/Node.py
  9. 9
      tools/wafadmin/Scripting.py
  10. 2
      tools/wafadmin/Task.py
  11. 16
      tools/wafadmin/TaskGen.py
  12. 41
      tools/wafadmin/Tools/UnitTest.py
  13. 5
      tools/wafadmin/Tools/bison.py
  14. 4
      tools/wafadmin/Tools/cc.py
  15. 57
      tools/wafadmin/Tools/ccroot.py
  16. 13
      tools/wafadmin/Tools/config_c.py
  17. 37
      tools/wafadmin/Tools/cs.py
  18. 4
      tools/wafadmin/Tools/cxx.py
  19. 114
      tools/wafadmin/Tools/d.py
  20. 9
      tools/wafadmin/Tools/dbus.py
  21. 4
      tools/wafadmin/Tools/gas.py
  22. 20
      tools/wafadmin/Tools/gcc.py
  23. 19
      tools/wafadmin/Tools/glib2.py
  24. 4
      tools/wafadmin/Tools/gnome.py
  25. 2
      tools/wafadmin/Tools/gnu_dirs.py
  26. 11
      tools/wafadmin/Tools/gxx.py
  27. 1
      tools/wafadmin/Tools/icc.py
  28. 5
      tools/wafadmin/Tools/intltool.py
  29. 4
      tools/wafadmin/Tools/kde4.py
  30. 5
      tools/wafadmin/Tools/libtool.py
  31. 8
      tools/wafadmin/Tools/misc.py
  32. 29
      tools/wafadmin/Tools/msvc.py
  33. 5
      tools/wafadmin/Tools/nasm.py
  34. 29
      tools/wafadmin/Tools/ocaml.py
  35. 4
      tools/wafadmin/Tools/osx.py
  36. 7
      tools/wafadmin/Tools/perl.py
  37. 17
      tools/wafadmin/Tools/python.py
  38. 138
      tools/wafadmin/Tools/qt4.py
  39. 1
      tools/wafadmin/Tools/suncc.py
  40. 20
      tools/wafadmin/Tools/tex.py
  41. 6
      tools/wafadmin/Tools/vala.py
  42. 6
      tools/wafadmin/Tools/winres.py
  43. 53
      tools/wafadmin/Utils.py
  44. 202
      tools/wafadmin/ansiterm.py
  45. 25
      tools/wafadmin/py3kfixes.py

15
tools/waf-light

@ -37,7 +37,7 @@ if 'PSYCOWAF' in os.environ:
try:import psyco;psyco.full() try:import psyco;psyco.full()
except:pass except:pass
VERSION="1.5.9" VERSION="1.5.10"
REVISION="x" REVISION="x"
INSTALL="x" INSTALL="x"
C1='x' C1='x'
@ -75,8 +75,11 @@ def unpack_wafdir(dir):
import shutil, tarfile import shutil, tarfile
try: shutil.rmtree(dir) try: shutil.rmtree(dir)
except OSError: pass except OSError: pass
try: os.makedirs(join(dir, 'wafadmin', 'Tools')) try:
except OSError: err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir) for x in ['Tools', '3rdparty']:
os.makedirs(join(dir, 'wafadmin', x))
except OSError:
err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)
os.chdir(dir) os.chdir(dir)
tmp = 't.tbz2' tmp = 't.tbz2'
@ -94,7 +97,8 @@ def unpack_wafdir(dir):
except OSError: pass except OSError: pass
err("Waf cannot be unpacked, check that bzip2 support is present") err("Waf cannot be unpacked, check that bzip2 support is present")
os.chmod(join('wafadmin','Tools'), 493) for x in ['Tools', '3rdparty']:
os.chmod(join('wafadmin',x), 493)
os.unlink(tmp) os.unlink(tmp)
@ -142,7 +146,8 @@ def find_lib():
wafdir = find_lib() wafdir = find_lib()
w = join(wafdir, 'wafadmin') w = join(wafdir, 'wafadmin')
t = join(w, 'Tools') t = join(w, 'Tools')
sys.path = [w, t] + sys.path f = join(w, '3rdparty')
sys.path = [w, t, f] + sys.path
import Scripting import Scripting
Scripting.prepare(t, cwd, VERSION, wafdir) Scripting.prepare(t, cwd, VERSION, wafdir)

0
tools/wafadmin/Tools/boost.py → tools/wafadmin/3rdparty/boost.py

27
tools/wafadmin/3rdparty/fluid.py

@ -0,0 +1,27 @@
#!/usr/bin/python
# encoding: utf-8
# Grygoriy Fuchedzhy 2009
"""
Compile fluid files (fltk graphic library). Use the 'fluid' feature in conjuction with the 'cxx' feature.
"""
import Task
from TaskGen import extension
Task.simple_task_type('fluid', '${FLUID} -c -o ${TGT[0].abspath(env)} -h ${TGT[1].abspath(env)} ${SRC}', 'BLUE', shell=False, ext_out='.cxx')
@extension('.fl')
def fluid(self, node):
"""add the .fl to the source list; the cxx file generated will be compiled when possible"""
cpp = node.change_ext('.cpp')
hpp = node.change_ext('.hpp')
self.create_task('fluid', node, [cpp, hpp])
if 'cxx' in self.features:
self.allnodes.append(cpp)
def detect(conf):
fluid = conf.find_program('fluid', var='FLUID', mandatory=True)
conf.check_cfg(path='fltk-config', package='', args='--cxxflags --ldflags', uselib_store='FLTK', mandatory=True)

5
tools/wafadmin/Build.py

@ -57,8 +57,10 @@ def group_method(fun):
postpone = kw['postpone'] postpone = kw['postpone']
del kw['postpone'] del kw['postpone']
# TODO waf 1.6 in theory there should be no reference to the TaskManager internals here
if postpone: if postpone:
m = k[0].task_manager m = k[0].task_manager
if not m.groups: m.add_group()
m.groups[m.current_group].post_funs.append((fun, k, kw)) m.groups[m.current_group].post_funs.append((fun, k, kw))
kw['cwd'] = k[0].path kw['cwd'] = k[0].path
else: else:
@ -801,6 +803,9 @@ class BuildContext(Utils.Context):
else: else:
lst = Utils.to_list(files) lst = Utils.to_list(files)
if not getattr(lst, '__iter__', False):
lst = [lst]
destpath = self.get_install_path(path, env) destpath = self.get_install_path(path, env)
Utils.check_dir(destpath) Utils.check_dir(destpath)

6
tools/wafadmin/Constants.py

@ -9,9 +9,9 @@ maintainer: the version number is updated from the top-level wscript file
""" """
# do not touch these three lines, they are updated automatically # do not touch these three lines, they are updated automatically
HEXVERSION = 0x10509 HEXVERSION = 0x105010
WAFVERSION="1.5.9" WAFVERSION="1.5.10"
WAFREVISION = "6626:6639M" WAFREVISION = "6794M"
ABI = 7 ABI = 7
# permissions # permissions

2
tools/wafadmin/Environment.py

@ -86,7 +86,7 @@ class Environment(object):
else: else:
keys = tbl.keys() keys = tbl.keys()
for x in keys: for x in keys:
tbl[x] = copy.copy(tbl[x]) tbl[x] = copy.deepcopy(tbl[x])
self.table = tbl self.table = tbl
def get_flat(self, key): def get_flat(self, key):

9
tools/wafadmin/Logs.py

@ -2,6 +2,7 @@
# encoding: utf-8 # encoding: utf-8
# Thomas Nagy, 2005 (ita) # Thomas Nagy, 2005 (ita)
import ansiterm
import os, re, logging, traceback, sys import os, re, logging, traceback, sys
from Constants import * from Constants import *
@ -11,7 +12,7 @@ verbose = 0
colors_lst = { colors_lst = {
'USE' : True, 'USE' : True,
'BOLD' :'\x1b[01;1m', 'BOLD' :'\x1b[01;1m',
'RED' :'\x1b[01;91m', 'RED' :'\x1b[01;31m',
'GREEN' :'\x1b[32m', 'GREEN' :'\x1b[32m',
'YELLOW':'\x1b[33m', 'YELLOW':'\x1b[33m',
'PINK' :'\x1b[35m', 'PINK' :'\x1b[35m',
@ -31,9 +32,13 @@ if got_tty:
import Utils import Utils
if not got_tty or sys.platform == 'win32' or 'NOCOLOR' in os.environ: if not got_tty or 'NOCOLOR' in os.environ:
colors_lst['USE'] = False colors_lst['USE'] = False
# test
#if sys.platform == 'win32':
# colors_lst['USE'] = True
def get_color(cl): def get_color(cl):
if not colors_lst['USE']: return '' if not colors_lst['USE']: return ''
return colors_lst.get(cl, '') return colors_lst.get(cl, '')

8
tools/wafadmin/Node.py

@ -6,15 +6,15 @@
Node: filesystem structure, contains lists of nodes Node: filesystem structure, contains lists of nodes
IMPORTANT: IMPORTANT:
1. Each file/folder is represented by exactly one node 1. Each file/folder is represented by exactly one node.
2. Most would-be class properties are stored in Build: nodes to depend on, signature, flags, .. 2. Most would-be class properties are stored in Build: nodes to depend on, signature, flags, ..
unused class members increase the .wafpickle file size sensibly with lots of objects unused class members increase the .wafpickle file size sensibly with lots of objects.
3. The build is launched from the top of the build dir (for example, in _build_/) 3. The build is launched from the top of the build dir (for example, in _build_/).
4. Node should not be instantiated directly. 4. Node should not be instantiated directly.
Each instance of Build.BuildContext has a Node sublass. Each instance of Build.BuildContext has a Node subclass.
(aka: 'Nodu', see BuildContext initializer) (aka: 'Nodu', see BuildContext initializer)
The BuildContext is referenced here as self.__class__.bld The BuildContext is referenced here as self.__class__.bld
Its Node class is referenced here as self.__class__ Its Node class is referenced here as self.__class__

9
tools/wafadmin/Scripting.py

@ -27,7 +27,7 @@ def prepare_impl(t, cwd, ver, wafdir):
# now find the wscript file # now find the wscript file
msg1 = 'Waf: Please run waf from a directory containing a file named "%s" or run distclean' % WSCRIPT_FILE msg1 = 'Waf: Please run waf from a directory containing a file named "%s" or run distclean' % WSCRIPT_FILE
# in theory projects can be configured in a gcc manner: # in theory projects can be configured in an autotool-like manner:
# mkdir build && cd build && ../waf configure && ../waf # mkdir build && cd build && ../waf configure && ../waf
build_dir_override = None build_dir_override = None
candidate = None candidate = None
@ -39,7 +39,7 @@ def prepare_impl(t, cwd, ver, wafdir):
candidate = cwd candidate = cwd
elif 'configure' in sys.argv and not WSCRIPT_BUILD_FILE in lst: elif 'configure' in sys.argv and not WSCRIPT_BUILD_FILE in lst:
# gcc-like configuration # autotool-like configuration
calldir = os.path.abspath(os.path.dirname(sys.argv[0])) calldir = os.path.abspath(os.path.dirname(sys.argv[0]))
if WSCRIPT_FILE in os.listdir(calldir): if WSCRIPT_FILE in os.listdir(calldir):
candidate = calldir candidate = calldir
@ -60,7 +60,10 @@ def prepare_impl(t, cwd, ver, wafdir):
break break
if Options.lockfile in dirlst: if Options.lockfile in dirlst:
env = Environment.Environment() env = Environment.Environment()
env.load(os.path.join(cwd, Options.lockfile)) try:
env.load(os.path.join(cwd, Options.lockfile))
except:
error('could not load %r' % Options.lockfile)
try: try:
os.stat(env['cwd']) os.stat(env['cwd'])
except: except:

2
tools/wafadmin/Task.py

@ -569,7 +569,7 @@ class Task(TaskBase):
def add_file_dependency(self, filename): def add_file_dependency(self, filename):
"TODO user-provided file dependencies" "TODO user-provided file dependencies"
node = self.generator.bld.current.find_resource(filename) node = self.generator.bld.path.find_resource(filename)
self.deps_nodes.append(node) self.deps_nodes.append(node)
def signature(self): def signature(self):

16
tools/wafadmin/TaskGen.py

@ -228,9 +228,13 @@ class task_gen(object):
# TODO waf 1.6: always set the environment # TODO waf 1.6: always set the environment
# TODO waf 1.6: create_task(self, name, inputs, outputs) # TODO waf 1.6: create_task(self, name, inputs, outputs)
def create_task(self, name, env=None): def create_task(self, name, src=None, tgt=None, env=None):
env = env or self.env env = env or self.env
task = Task.TaskBase.classes[name](env.copy(), generator=self) task = Task.TaskBase.classes[name](env.copy(), generator=self)
if src:
task.set_inputs(src)
if tgt:
task.set_outputs(tgt)
self.tasks.append(task) self.tasks.append(task)
return task return task
@ -260,7 +264,7 @@ class task_gen(object):
#make sure dirnames is a list helps with dirnames with spaces #make sure dirnames is a list helps with dirnames with spaces
dirnames = self.to_list(dirnames) dirnames = self.to_list(dirnames)
ext_lst = exts or self.mappings.keys() + task_gen.mappings.keys() ext_lst = exts or list(self.mappings.keys()) + list(task_gen.mappings.keys())
for name in dirnames: for name in dirnames:
anode = self.path.find_dir(name) anode = self.path.find_dir(name)
@ -375,11 +379,9 @@ def declare_chain(name='', action='', ext_in='', ext_out='', reentrant=1, color=
# XXX: useless: it will fail on Utils.to_list above... # XXX: useless: it will fail on Utils.to_list above...
raise Utils.WafError("do not know how to process %s" % str(ext)) raise Utils.WafError("do not know how to process %s" % str(ext))
tsk = self.create_task(name) tsk = self.create_task(name, node, out_source)
tsk.set_inputs(node)
tsk.set_outputs(out_source)
if node.__class__.bld.is_install == INSTALL: if node.__class__.bld.is_install:
tsk.install = install tsk.install = install
declare_extension(act.ext_in, x_file) declare_extension(act.ext_in, x_file)
@ -511,7 +513,7 @@ def exec_rule(self):
if getattr(self, 'target', None): if getattr(self, 'target', None):
cls.quiet = True cls.quiet = True
tsk.outputs=[self.path.find_or_declare(x) for x in self.to_list(self.target)] tsk.outputs = [self.path.find_or_declare(x) for x in self.to_list(self.target)]
if getattr(self, 'source', None): if getattr(self, 'source', None):
cls.quiet = True cls.quiet = True

41
tools/wafadmin/Tools/UnitTest.py

@ -19,6 +19,7 @@ Each object to use as a unit test must be a program and must have X{obj.unit_tes
""" """
import os, sys import os, sys
import Build, TaskGen, Utils, Options, Logs, Task import Build, TaskGen, Utils, Options, Logs, Task
from TaskGen import before, after, feature
from Constants import * from Constants import *
class unit_test(object): class unit_test(object):
@ -210,37 +211,58 @@ bld.add_post_fun(UnitTest.summary)
import threading import threading
testlock = threading.Lock() testlock = threading.Lock()
@TaskGen.feature('test') @feature('test')
@TaskGen.after('apply_link') @after('apply_link', 'vars_target_cprogram')
def make_test(self): def make_test(self):
if not 'cprogram' in self.features: if not 'cprogram' in self.features:
Logs.error('test cannot be executed %s' % self) Logs.error('test cannot be executed %s' % self)
return return
self.default_install_path = None
tsk = self.create_task('utest') tsk = self.create_task('utest')
tsk.set_inputs(self.link_task.outputs) tsk.set_inputs(self.link_task.outputs)
def exec_test(self): def exec_test(self):
testlock.acquire()
fail = False fail = False
try: try:
testlock.acquire()
filename = self.inputs[0].abspath(self.env) filename = self.inputs[0].abspath(self.env)
try:
fu = getattr(self.generator.bld, 'all_test_paths')
except AttributeError:
fu = os.environ.copy()
self.generator.bld.all_test_paths = fu
lst = []
for obj in self.generator.bld.all_task_gen:
link_task = getattr(obj, 'link_task', None)
if link_task:
lst.append(link_task.outputs[0].parent.abspath(obj.env))
def add_path(dct, path, var):
dct[var] = os.pathsep.join(Utils.to_list(path) + [os.environ.get(var, '')])
if sys.platform == 'win32':
add_path(fu, lst, 'PATH')
elif sys.platform == 'darwin':
add_path(fu, lst, 'DYLD_LIBRARY_PATH')
add_path(fu, lst, 'LD_LIBRARY_PATH')
else:
add_path(fu, lst, 'LD_LIBRARY_PATH')
try: try:
ret = Utils.cmd_output(filename, cwd='/cygdrive/c/home/waf-1.5.8/demos/unit_test/tests/test0') ret = Utils.cmd_output(filename, cwd=self.inputs[0].parent.abspath(self.env), env=fu)
except Exception, e: except Exception, e:
fail = True fail = True
ret = "" ret = '' + str(e)
else: else:
pass pass
stats = getattr(self.generator.bld, 'utest_results', []) stats = getattr(self.generator.bld, 'utest_results', [])
stats.append((filename, fail, ret)) stats.append((filename, fail, ret))
self.generator.bld.utest_results = stats self.generator.bld.utest_results = stats
finally:
testlock.release() testlock.release()
except Exception, e:
print e
cls = Task.task_type_from_func('utest', func=exec_test, color='RED', ext_in='.bin') cls = Task.task_type_from_func('utest', func=exec_test, color='RED', ext_in='.bin')
@ -260,6 +282,7 @@ def summary(bld):
for (f, fail, ret) in lst: for (f, fail, ret) in lst:
col = fail and 'RED' or 'GREEN' col = fail and 'RED' or 'GREEN'
Utils.pprint(col, (fail and 'FAIL' or 'ok') + " " + f) Utils.pprint(col, (fail and 'FAIL' or 'ok') + " " + f)
if fail: Utils.pprint('NORMAL', ret.replace('\\n', '\n'))
def set_options(opt): def set_options(opt):
opt.add_option('--alltests', action='store_true', default=False, help='Exec all unit tests', dest='all_tests') opt.add_option('--alltests', action='store_true', default=False, help='Exec all unit tests', dest='all_tests')

5
tools/wafadmin/Tools/bison.py

@ -14,9 +14,6 @@ cls = Task.simple_task_type('bison', bison, 'GREEN', ext_in='.yc .y .yy', ext_ou
@extension(['.y', '.yc', '.yy']) @extension(['.y', '.yc', '.yy'])
def big_bison(self, node): def big_bison(self, node):
"""when it becomes complicated (unlike flex), the old recipes work better (cwd)""" """when it becomes complicated (unlike flex), the old recipes work better (cwd)"""
tsk = self.create_task('bison')
tsk.set_inputs(node)
has_h = '-d' in self.env['BISONFLAGS'] has_h = '-d' in self.env['BISONFLAGS']
outs = [] outs = []
@ -29,7 +26,7 @@ def big_bison(self, node):
if has_h: if has_h:
outs.append(node.change_ext('.tab.h')) outs.append(node.change_ext('.tab.h'))
tsk.set_outputs(outs) tsk = self.create_task('bison', node, outs)
tsk.cwd = node.bld_dir(tsk.env) tsk.cwd = node.bld_dir(tsk.env)
# and the c/cxx file must be compiled too # and the c/cxx file must be compiled too

4
tools/wafadmin/Tools/cc.py

@ -76,14 +76,12 @@ def apply_defines_cc(self):
@extension(EXT_CC) @extension(EXT_CC)
def c_hook(self, node): def c_hook(self, node):
# create the compilation task: cpp or cc # create the compilation task: cpp or cc
task = self.create_task('cc')
if getattr(self, 'obj_ext', None): if getattr(self, 'obj_ext', None):
obj_ext = self.obj_ext obj_ext = self.obj_ext
else: else:
obj_ext = '_%d.o' % self.idx obj_ext = '_%d.o' % self.idx
task.inputs = [node] task = self.create_task('cc', node, node.change_ext(obj_ext))
task.outputs = [node.change_ext(obj_ext)]
try: try:
self.compiled_tasks.append(task) self.compiled_tasks.append(task)
except AttributeError: except AttributeError:

57
tools/wafadmin/Tools/ccroot.py

@ -10,6 +10,7 @@ from Logs import error, debug, warn
from Utils import md5 from Utils import md5
from TaskGen import taskgen, after, before, feature from TaskGen import taskgen, after, before, feature
from Constants import * from Constants import *
from Configure import conftest
try: try:
from cStringIO import StringIO from cStringIO import StringIO
except ImportError: except ImportError:
@ -136,14 +137,14 @@ def scan(self):
all_nodes = [] all_nodes = []
all_names = [] all_names = []
seen = [] seen = set()
for node in self.inputs: for node in self.inputs:
(nodes, names) = preproc.get_deps(node, self.env, nodepaths = self.env['INC_PATHS']) (nodes, names) = preproc.get_deps(node, self.env, nodepaths = self.env['INC_PATHS'])
if Logs.verbose: if Logs.verbose:
debug('deps: deps for %s: %r; unresolved %r' % (str(node), nodes, names)) debug('deps: deps for %s: %r; unresolved %r' % (str(node), nodes, names))
for x in nodes: for x in nodes:
if id(x) in seen: continue if id(x) in seen: continue
seen.append(id(x)) seen.add(id(x))
all_nodes.append(x) all_nodes.append(x)
for x in names: for x in names:
if not x in all_names: if not x in all_names:
@ -239,7 +240,7 @@ def default_link_install(self):
"""you may kill this method to inject your own installation for the first element """you may kill this method to inject your own installation for the first element
any other install should only process its own nodes and not those from the others""" any other install should only process its own nodes and not those from the others"""
if self.install_path: if self.install_path:
self.bld.install_files(self.install_path, [self.link_task.outputs[0]], env=self.env, chmod=self.chmod) self.bld.install_files(self.install_path, self.link_task.outputs[0], env=self.env, chmod=self.chmod)
@feature('cc', 'cxx') @feature('cc', 'cxx')
@after('apply_type_vars', 'apply_lib_vars', 'apply_core') @after('apply_type_vars', 'apply_lib_vars', 'apply_core')
@ -336,13 +337,13 @@ def apply_lib_vars(self):
# 1. the case of the libs defined in the project (visit ancestors first) # 1. the case of the libs defined in the project (visit ancestors first)
# the ancestors external libraries (uselib) will be prepended # the ancestors external libraries (uselib) will be prepended
uselib = self.to_list(self.uselib) self.uselib = self.to_list(self.uselib)
names = self.to_list(self.uselib_local) names = self.to_list(self.uselib_local)
seen = [] seen = set([])
tmp = names[:] # consume a copy of the list of names tmp = Utils.deque(names) # consume a copy of the list of names
while tmp: while tmp:
lib_name = tmp.pop(0) lib_name = tmp.popleft()
# visit dependencies only once # visit dependencies only once
if lib_name in seen: if lib_name in seen:
continue continue
@ -351,7 +352,7 @@ def apply_lib_vars(self):
if not y: if not y:
raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name)) raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name))
y.post() y.post()
seen.append(lib_name) seen.add(lib_name)
# object has ancestors to process (shared libraries): add them to the end of the list # object has ancestors to process (shared libraries): add them to the end of the list
if getattr(y, 'uselib_local', None): if getattr(y, 'uselib_local', None):
@ -381,12 +382,11 @@ def apply_lib_vars(self):
tmp_path = y.link_task.outputs[0].parent.bldpath(self.env) tmp_path = y.link_task.outputs[0].parent.bldpath(self.env)
if not tmp_path in env['LIBPATH']: env.prepend_value('LIBPATH', tmp_path) if not tmp_path in env['LIBPATH']: env.prepend_value('LIBPATH', tmp_path)
# add ancestors uselib too # add ancestors uselib too - but only propagate those that have no staticlib
# WARNING providing STATICLIB_FOO in env will result in broken builds
# TODO waf 1.6 prevent this behaviour somehow
for v in self.to_list(y.uselib): for v in self.to_list(y.uselib):
if v in uselib: continue if not env['STATICLIB_' + v]:
uselib = [v] + uselib if not v in self.uselib:
self.uselib.insert(0, v)
# if the library task generator provides 'export_incdirs', add to the include path # if the library task generator provides 'export_incdirs', add to the include path
# the export_incdirs must be a list of paths relative to the other library # the export_incdirs must be a list of paths relative to the other library
@ -398,13 +398,13 @@ def apply_lib_vars(self):
self.env.append_unique('INC_PATHS', node) self.env.append_unique('INC_PATHS', node)
# 2. the case of the libs defined outside # 2. the case of the libs defined outside
for x in uselib: for x in self.uselib:
for v in self.p_flag_vars: for v in self.p_flag_vars:
val = self.env[v + '_' + x] val = self.env[v + '_' + x]
if val: self.env.append_value(v, val) if val: self.env.append_value(v, val)
@feature('cprogram', 'cstaticlib', 'cshlib') @feature('cprogram', 'cstaticlib', 'cshlib')
@after('apply_link') @after('init_cc', 'init_cxx', 'apply_link')
def apply_objdeps(self): def apply_objdeps(self):
"add the .o files produced by some other object files in the same manner as uselib_local" "add the .o files produced by some other object files in the same manner as uselib_local"
if not getattr(self, 'add_objects', None): return if not getattr(self, 'add_objects', None): return
@ -542,7 +542,7 @@ def apply_implib(self):
# install the dll in the bin dir # install the dll in the bin dir
dll = self.link_task.outputs[0] dll = self.link_task.outputs[0]
self.bld.install_files(bindir, [dll], self.env, self.chmod) self.bld.install_files(bindir, dll, self.env, self.chmod)
# add linker flags to generate the import lib # add linker flags to generate the import lib
implib = self.env['implib_PATTERN'] % os.path.split(self.target)[1] implib = self.env['implib_PATTERN'] % os.path.split(self.target)[1]
@ -562,7 +562,7 @@ def apply_vnum(self):
""" """
libfoo.so is installed as libfoo.so.1.2.3 libfoo.so is installed as libfoo.so.1.2.3
""" """
if not getattr(self, 'vnum', '') or not 'cshlib' in self.features or os.name != 'posix' or self.env.DEST_BINFMT != 'elf': if not getattr(self, 'vnum', '') or not 'cshlib' in self.features or os.name != 'posix' or self.env.DEST_BINFMT not in ('elf', 'mac-o'):
return return
self.meths.remove('default_link_install') self.meths.remove('default_link_install')
@ -573,13 +573,15 @@ def apply_vnum(self):
libname = node.name libname = node.name
if libname.endswith('.dylib'): if libname.endswith('.dylib'):
name3 = libname.replace('.dylib', '.%s.dylib' % task.vnum) name3 = libname.replace('.dylib', '.%s.dylib' % self.vnum)
name2 = libname.replace('.dylib', '.%s.dylib' % nums[0]) name2 = libname.replace('.dylib', '.%s.dylib' % nums[0])
else: else:
name3 = libname + '.' + self.vnum name3 = libname + '.' + self.vnum
name2 = libname + '.' + nums[0] name2 = libname + '.' + nums[0]
self.env.append_value('LINKFLAGS', (self.env['SONAME_ST'] % name2).split()) if self.env.SONAME_ST:
v = self.env.SONAME_ST % name2
self.env.append_value('LINKFLAGS', v.split())
bld = self.bld bld = self.bld
nums = self.vnum.split('.') nums = self.vnum.split('.')
@ -597,17 +599,24 @@ def apply_vnum(self):
tsk.set_outputs(node.parent.find_or_declare(name2)) tsk.set_outputs(node.parent.find_or_declare(name2))
def exec_vnum_link(self): def exec_vnum_link(self):
path = self.inputs[0].parent.abspath(self.env) path = self.outputs[0].abspath(self.env)
try: try:
os.remove(self.outputs[0].abspath()) os.remove(path)
except OSError, e: except OSError:
pass pass
try: try:
os.symlink(self.inputs[0].name, self.outputs[0].abspath(self.env)) os.symlink(self.inputs[0].name, path)
except Exception, e: except OSError:
return 1 return 1
cls = Task.task_type_from_func('vnum', func=exec_vnum_link, ext_in='.bin', color='CYAN') cls = Task.task_type_from_func('vnum', func=exec_vnum_link, ext_in='.bin', color='CYAN')
cls.quiet = 1 cls.quiet = 1
# ============ the --as-needed flag should added during the configuration, not at runtime =========
@conftest
def add_as_needed(conf):
if conf.env.DEST_BINFMT == 'elf' and 'gcc' in (conf.env.CXX_NAME, conf.env.CC_NAME):
conf.env.append_unique('LINKFLAGS', '--as-needed')

13
tools/wafadmin/Tools/config_c.py

@ -66,8 +66,9 @@ def parse_flags(line, uselib, env):
env.append_unique('CXXFLAGS_' + uselib, x) env.append_unique('CXXFLAGS_' + uselib, x)
env.append_unique('LINKFLAGS_' + uselib, x) env.append_unique('LINKFLAGS_' + uselib, x)
elif x == '-framework': elif x == '-framework':
framework = lst.pop(0) env.append_unique('FRAMEWORK_' + uselib, lst.pop(0))
env.append_unique('FRAMEWORK_' + uselib, framework) elif x.startswith('-F'):
env.append_unique('FRAMEWORKPATH_' + uselib, x[2:])
elif x.startswith('-std'): elif x.startswith('-std'):
env.append_unique('CCFLAGS_' + uselib, x) env.append_unique('CCFLAGS_' + uselib, x)
env.append_unique('LINKFLAGS_' + uselib, x) env.append_unique('LINKFLAGS_' + uselib, x)
@ -642,9 +643,10 @@ def get_config_header(self):
config_header.append('#define %s' % key) config_header.append('#define %s' % key)
elif value is UNDEFINED: elif value is UNDEFINED:
config_header.append('/* #undef %s */' % key) config_header.append('/* #undef %s */' % key)
elif isinstance(value, str):
config_header.append('#define %s %s' % (key, repr(value)[1:-1]))
else: else:
config_header.append('#define %s %s' % (key, value)) config_header.append('#define %s %s' % (key, value))
return "\n".join(config_header) return "\n".join(config_header)
@conftest @conftest
@ -662,13 +664,16 @@ def find_cpp(conf):
def cc_add_flags(conf): def cc_add_flags(conf):
conf.add_os_flags('CFLAGS', 'CCFLAGS') conf.add_os_flags('CFLAGS', 'CCFLAGS')
conf.add_os_flags('CPPFLAGS') conf.add_os_flags('CPPFLAGS')
conf.add_os_flags('LINKFLAGS')
@conftest @conftest
def cxx_add_flags(conf): def cxx_add_flags(conf):
conf.add_os_flags('CXXFLAGS') conf.add_os_flags('CXXFLAGS')
conf.add_os_flags('CPPFLAGS') conf.add_os_flags('CPPFLAGS')
@conftest
def link_add_flags(conf):
conf.add_os_flags('LINKFLAGS') conf.add_os_flags('LINKFLAGS')
conf.add_os_flags('LDFLAGS', 'LINKFLAGS')
@conftest @conftest
def cc_load_tools(conf): def cc_load_tools(conf):

37
tools/wafadmin/Tools/cs.py

@ -4,7 +4,7 @@
"C# support" "C# support"
import TaskGen, Utils, Task import TaskGen, Utils, Task, Options
from Logs import error from Logs import error
from TaskGen import before, after, taskgen, feature from TaskGen import before, after, taskgen, feature
@ -37,33 +37,32 @@ def apply_cs(self):
except ValueError: pass except ValueError: pass
# process the flags for the assemblies # process the flags for the assemblies
assemblies_flags = []
for i in self.to_list(self.assemblies) + self.env['ASSEMBLIES']: for i in self.to_list(self.assemblies) + self.env['ASSEMBLIES']:
assemblies_flags += '/r:'+i self.env.append_unique('_ASSEMBLIES', '/r:'+i)
self.env['_ASSEMBLIES'] += assemblies_flags
# process the flags for the resources # process the flags for the resources
for i in self.to_list(self.resources): for i in self.to_list(self.resources):
self.env['_RESOURCES'].append('/resource:'+i) self.env.append_unique('_RESOURCES', '/resource:'+i)
# additional flags # what kind of assembly are we generating?
self.env['_FLAGS'] += self.to_list(self.flags) + self.env['FLAGS'] self.env['_TYPE'] = getattr(self, 'type', 'exe')
curnode = self.path # additional flags
self.env.append_unique('_FLAGS', self.to_list(self.flags))
self.env.append_unique('_FLAGS', self.env.FLAGS)
# process the sources # process the sources
nodes = [] nodes = [self.path.find_resource(i) for i in self.to_list(self.source)]
for i in self.to_list(self.source): self.create_task('mcs', nodes, self.path.find_or_declare(self.target))
nodes.append(curnode.find_resource(i))
# create the task Task.simple_task_type('mcs', '${MCS} ${SRC} /target:${_TYPE} /out:${TGT} ${_FLAGS} ${_ASSEMBLIES} ${_RESOURCES}', color='YELLOW')
task = self.create_task('mcs')
task.inputs = nodes
task.set_outputs(self.path.find_or_declare(self.target))
Task.simple_task_type('mcs', '${MCS} ${SRC} /out:${TGT} ${_FLAGS} ${_ASSEMBLIES} ${_RESOURCES}', color='YELLOW')
def detect(conf): def detect(conf):
mcs = conf.find_program('mcs', var='MCS') csc = getattr(Options.options, 'cscbinary', None)
if not mcs: mcs = conf.find_program('gmcs', var='MCS') if csc:
conf.env.MCS = csc
conf.find_program(['gmcs', 'mcs'], var='MCS')
def set_options(opt):
opt.add_option('--with-csc-binary', type='string', dest='cscbinary')

4
tools/wafadmin/Tools/cxx.py

@ -80,14 +80,12 @@ def apply_defines_cxx(self):
@extension(EXT_CXX) @extension(EXT_CXX)
def cxx_hook(self, node): def cxx_hook(self, node):
# create the compilation task: cpp or cc # create the compilation task: cpp or cc
task = self.create_task('cxx')
if getattr(self, 'obj_ext', None): if getattr(self, 'obj_ext', None):
obj_ext = self.obj_ext obj_ext = self.obj_ext
else: else:
obj_ext = '_%d.o' % self.idx obj_ext = '_%d.o' % self.idx
task.inputs = [node] task = self.create_task('cxx', node, node.change_ext(obj_ext))
task.outputs = [node.change_ext(obj_ext)]
try: try:
self.compiled_tasks.append(task) self.compiled_tasks.append(task)
except AttributeError: except AttributeError:

114
tools/wafadmin/Tools/d.py

@ -38,7 +38,7 @@ def filter_comments(filename):
else: break else: break
#print "cnt is ", str(cnt) #print "cnt is ", str(cnt)
if (cnt%2)==0: break if (cnt%2)==0: break
# i -= 1 # <- useless in practice i += 1
# skip a char # skip a char
elif c == "'": elif c == "'":
i += 1 i += 1
@ -260,66 +260,67 @@ def init_d(self):
link_task=None) link_task=None)
@feature('d') @feature('d')
@after('apply_d_link') @after('apply_d_link', 'init_d')
@before('apply_vnum') @before('apply_vnum')
def apply_d_libs(self): def apply_d_libs(self):
uselib = self.to_list(self.uselib) """after apply_link because of 'link_task'
seen = [] after default_cc because of the attribute 'uselib'"""
local_libs = self.to_list(self.uselib_local)
libs = []
libpaths = []
env = self.env env = self.env
while local_libs:
x = local_libs.pop()
# 1. the case of the libs defined in the project (visit ancestors first)
# the ancestors external libraries (uselib) will be prepended
self.uselib = self.to_list(self.uselib)
names = self.to_list(self.uselib_local)
seen = set([])
tmp = Utils.deque(names) # consume a copy of the list of names
while tmp:
lib_name = tmp.popleft()
# visit dependencies only once # visit dependencies only once
if x in seen: if lib_name in seen:
continue continue
else:
seen.append(x)
y = self.name_to_obj(x) y = self.name_to_obj(lib_name)
if not y: if not y:
raise Utils.WafError('object not found in uselib_local: obj %s uselib %s' % (self.name, x)) raise Utils.WafError('object %r was not found in uselib_local (required by %r)' % (lib_name, self.name))
y.post()
seen.add(lib_name)
# object has ancestors to process first ? update the list of names # object has ancestors to process (shared libraries): add them to the end of the list
if y.uselib_local: if getattr(y, 'uselib_local', None):
added = 0
lst = y.to_list(y.uselib_local) lst = y.to_list(y.uselib_local)
lst.reverse() if 'dshlib' in y.features or 'cprogram' in y.features:
for u in lst: lst = [x for x in lst if not 'cstaticlib' in self.name_to_obj(x).features]
if u in seen: continue tmp.extend(lst)
added = 1
local_libs = [u]+local_libs
if added: continue # list of names modified, loop
# safe to process the current object
y.post()
seen.append(x)
libname = y.target[y.target.rfind(os.sep) + 1:] # link task and flags
if 'dshlib' in y.features or 'dstaticlib' in y.features: if getattr(y, 'link_task', None):
#libs.append(y.target)
env.append_unique('DLINKFLAGS', env['DLIBPATH_ST'] % y.link_task.outputs[0].parent.bldpath(env))
env.append_unique('DLINKFLAGS', env['DLIB_ST'] % libname)
# add the link path too link_name = y.target[y.target.rfind(os.sep) + 1:]
tmp_path = y.path.bldpath(env) if 'dstaticlib' in y.features or 'dshlib' in y.features:
if not tmp_path in libpaths: libpaths = [tmp_path] + libpaths env.append_unique('DLINKFLAGS', env.DLIB_ST % link_name)
env.append_unique('DLINKFLAGS', env.DLIBPATH_ST % y.link_task.outputs[0].parent.bldpath(env))
# set the dependency over the link task # the order
if y.link_task is not None:
self.link_task.set_run_after(y.link_task) self.link_task.set_run_after(y.link_task)
# for the recompilation
dep_nodes = getattr(self.link_task, 'dep_nodes', []) dep_nodes = getattr(self.link_task, 'dep_nodes', [])
self.link_task.dep_nodes = dep_nodes + y.link_task.outputs self.link_task.dep_nodes = dep_nodes + y.link_task.outputs
# add ancestors uselib too # add ancestors uselib too - but only propagate those that have no staticlib
# TODO potential problems with static libraries ? for v in self.to_list(y.uselib):
morelibs = y.to_list(y.uselib) if not v in self.uselib:
for v in morelibs: self.uselib.insert(0, v)
if v in uselib: continue
uselib = [v]+uselib # if the library task generator provides 'export_incdirs', add to the include path
self.uselib = uselib # the export_incdirs must be a list of paths relative to the other library
if getattr(y, 'export_incdirs', None):
for x in self.to_list(y.export_incdirs):
node = y.path.find_dir(x)
if not node:
raise Utils.WafError('object %r: invalid folder %r in export_incdirs' % (y.target, x))
self.env.append_unique('INC_PATHS', node)
@feature('dprogram', 'dshlib', 'dstaticlib') @feature('dprogram', 'dshlib', 'dstaticlib')
@after('apply_core') @after('apply_core')
@ -328,12 +329,9 @@ def apply_d_link(self):
if not link: if not link:
if 'dstaticlib' in self.features: link = 'static_link' if 'dstaticlib' in self.features: link = 'static_link'
else: link = 'd_link' else: link = 'd_link'
linktask = self.create_task(link)
outputs = [t.outputs[0] for t in self.compiled_tasks]
linktask.set_inputs(outputs)
linktask.set_outputs(self.path.find_or_declare(get_target_name(self)))
self.link_task = linktask outputs = [t.outputs[0] for t in self.compiled_tasks]
self.link_task = self.create_task(link, outputs, self.path.find_or_declare(get_target_name(self)))
@feature('d') @feature('d')
@after('apply_core') @after('apply_core')
@ -343,7 +341,6 @@ def apply_d_vars(self):
lib_st = env['DLIB_ST'] lib_st = env['DLIB_ST']
libpath_st = env['DLIBPATH_ST'] libpath_st = env['DLIBPATH_ST']
#dflags = []
importpaths = self.to_list(self.importpaths) importpaths = self.to_list(self.importpaths)
libpaths = [] libpaths = []
libs = [] libs = []
@ -383,10 +380,11 @@ def apply_d_vars(self):
if env['LIBPATH_' + i]: if env['LIBPATH_' + i]:
for entry in self.to_list(env['LIBPATH_' + i]): for entry in self.to_list(env['LIBPATH_' + i]):
if not entry in libpaths: if not entry in libpaths:
libpaths += [entry] libpaths.append(entry)
libpaths = self.to_list(self.libpaths) + libpaths libpaths = self.to_list(self.libpaths) + libpaths
# now process the library paths # now process the library paths
# apply same path manipulation as used with import paths
for path in libpaths: for path in libpaths:
env.append_unique('DLINKFLAGS', libpath_st % path) env.append_unique('DLINKFLAGS', libpath_st % path)
@ -395,8 +393,12 @@ def apply_d_vars(self):
if env['LIB_' + i]: if env['LIB_' + i]:
for entry in self.to_list(env['LIB_' + i]): for entry in self.to_list(env['LIB_' + i]):
if not entry in libs: if not entry in libs:
libs += [entry] libs.append(entry)
libs = libs + self.to_list(self.libs) libs.extend(self.to_list(self.libs))
# process user flags
for flag in self.to_list(self.dflags):
env.append_unique('DFLAGS', flag)
# now process the libraries # now process the libraries
for lib in libs: for lib in libs:
@ -486,8 +488,9 @@ Task.simple_task_type('d_header', d_header_str, color='BLUE', shell=False)
@conftest @conftest
def d_platform_flags(conf): def d_platform_flags(conf):
binfmt = conf.env.DEST_BINFMT or Utils.unversioned_sys_platform_to_binary_format( v = conf.env
conf.env.DEST_OS or Utils.unversioned_sys_platform()) binfmt = v.DEST_BINFMT or Utils.unversioned_sys_platform_to_binary_format(
v.DEST_OS or Utils.unversioned_sys_platform())
if binfmt == 'pe': if binfmt == 'pe':
v['D_program_PATTERN'] = '%s.exe' v['D_program_PATTERN'] = '%s.exe'
v['D_shlib_PATTERN'] = 'lib%s.dll' v['D_shlib_PATTERN'] = 'lib%s.dll'
@ -497,7 +500,6 @@ def d_platform_flags(conf):
v['D_shlib_PATTERN'] = 'lib%s.so' v['D_shlib_PATTERN'] = 'lib%s.so'
v['D_staticlib_PATTERN'] = 'lib%s.a' v['D_staticlib_PATTERN'] = 'lib%s.a'
# quick test # # quick test #
if __name__ == "__main__": if __name__ == "__main__":
#Logs.verbose = 2 #Logs.verbose = 2

9
tools/wafadmin/Tools/dbus.py

@ -15,18 +15,15 @@ def add_dbus_file(self, filename, prefix, mode):
@before('apply_core') @before('apply_core')
def process_dbus(self): def process_dbus(self):
for filename, prefix, mode in getattr(self, 'dbus_lst', []): for filename, prefix, mode in getattr(self, 'dbus_lst', []):
env = self.env.copy()
node = self.path.find_resource(filename) node = self.path.find_resource(filename)
if not node: if not node:
raise Utils.WafError('file not found ' + filename) raise Utils.WafError('file not found ' + filename)
env['DBUS_BINDING_TOOL_PREFIX'] = prefix tsk = self.create_task('dbus_binding_tool', node, node.change_ext('.h'))
env['DBUS_BINDING_TOOL_MODE'] = mode
task = self.create_task('dbus_binding_tool', env) tsk.env.DBUS_BINDING_TOOL_PREFIX = prefix
task.set_inputs(node) tsk.env.DBUS_BINDING_TOOL_MODE = mode
task.set_outputs(node.change_ext('.h'))
Task.simple_task_type('dbus_binding_tool', Task.simple_task_type('dbus_binding_tool',
'${DBUS_BINDING_TOOL} --prefix=${DBUS_BINDING_TOOL_PREFIX} --mode=${DBUS_BINDING_TOOL_MODE} --output=${TGT} ${SRC}', '${DBUS_BINDING_TOOL} --prefix=${DBUS_BINDING_TOOL_PREFIX} --mode=${DBUS_BINDING_TOOL_MODE} --output=${TGT} ${SRC}',

4
tools/wafadmin/Tools/gas.py

@ -16,12 +16,10 @@ Task.simple_task_type('asm', as_str, 'PINK', ext_out='.o', shell=False)
@extension(EXT_ASM) @extension(EXT_ASM)
def asm_hook(self, node): def asm_hook(self, node):
# create the compilation task: cpp or cc # create the compilation task: cpp or cc
task = self.create_task('asm')
try: obj_ext = self.obj_ext try: obj_ext = self.obj_ext
except AttributeError: obj_ext = '_%d.o' % self.idx except AttributeError: obj_ext = '_%d.o' % self.idx
task.inputs = [node] task = self.create_task('asm', node, node.change_ext(obj_ext))
task.outputs = [node.change_ext(obj_ext)]
self.compiled_tasks.append(task) self.compiled_tasks.append(task)
self.meths.append('asm_incflags') self.meths.append('asm_incflags')

20
tools/wafadmin/Tools/gcc.py

@ -23,6 +23,10 @@ def gcc_common_flags(conf):
# CPPFLAGS CCDEFINES _CCINCFLAGS _CCDEFFLAGS # CPPFLAGS CCDEFINES _CCINCFLAGS _CCDEFFLAGS
v['CCFLAGS_DEBUG'] = ['-g']
v['CCFLAGS_RELEASE'] = ['-O2']
v['CC_SRC_F'] = '' v['CC_SRC_F'] = ''
v['CC_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD v['CC_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD
v['CPPPATH_ST'] = '-I%s' # template for adding include paths v['CPPPATH_ST'] = '-I%s' # template for adding include paths
@ -69,8 +73,18 @@ def gcc_modifier_win32(conf):
v['shlib_PATTERN'] = '%s.dll' v['shlib_PATTERN'] = '%s.dll'
v['implib_PATTERN'] = 'lib%s.dll.a' v['implib_PATTERN'] = 'lib%s.dll.a'
v['IMPLIB_ST'] = '-Wl,--out-implib,%s' v['IMPLIB_ST'] = '-Wl,--out-implib,%s'
v['shlib_CCFLAGS'] = ['-DPIC', '-DDLL_EXPORT'] # TODO 64-bit platforms may need -fPIC
v.append_value('LINKFLAGS', '-Wl,--enable-auto-import') # suppress information messages dest_arch = v['DEST_CPU']
if dest_arch == 'x86':
# On 32-bit x86, gcc emits a message telling the -fPIC option is ignored on this arch, so we remove that flag.
v['shlib_CCFLAGS'] = ['-DPIC'] # TODO this is a wrong define, we don't use -fPIC!
v.append_value('shlib_CCFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
# Auto-import is enabled by default even without this option,
# but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
# that the linker emits otherwise.
v.append_value('LINKFLAGS', '-Wl,--enable-auto-import')
@conftest @conftest
def gcc_modifier_cygwin(conf): def gcc_modifier_cygwin(conf):
@ -90,6 +104,7 @@ def gcc_modifier_darwin(conf):
v['SHLIB_MARKER'] = '' v['SHLIB_MARKER'] = ''
v['STATICLIB_MARKER'] = '' v['STATICLIB_MARKER'] = ''
v['SONAME_ST'] = ''
@conftest @conftest
def gcc_modifier_aix(conf): def gcc_modifier_aix(conf):
@ -118,4 +133,5 @@ def detect(conf):
conf.gcc_modifier_platform() conf.gcc_modifier_platform()
conf.cc_load_tools() conf.cc_load_tools()
conf.cc_add_flags() conf.cc_add_flags()
conf.link_add_flags()

19
tools/wafadmin/Tools/glib2.py

@ -29,10 +29,8 @@ def process_marshal(self):
h_node = node.change_ext('.h') h_node = node.change_ext('.h')
c_node = node.change_ext('.c') c_node = node.change_ext('.c')
task = self.create_task('glib_genmarshal') task = self.create_task('glib_genmarshal', node, [h_node, c_node])
task.set_inputs(node) task.env.GLIB_GENMARSHAL_PREFIX = prefix
task.set_outputs([h_node, c_node])
task.env['GLIB_GENMARSHAL_PREFIX'] = prefix
self.allnodes.append(c_node) self.allnodes.append(c_node)
def genmarshal_func(self): def genmarshal_func(self):
@ -52,7 +50,8 @@ def genmarshal_func(self):
#print self.outputs[1].abspath(self.env) #print self.outputs[1].abspath(self.env)
f = open(self.outputs[1].abspath(self.env), 'wb') f = open(self.outputs[1].abspath(self.env), 'wb')
f.write('''#include "%s"\n''' % self.outputs[0].name) c = '''#include "%s"\n''' % self.outputs[0].name
f.write(c)
f.close() f.close()
cmd2 = "%s %s --prefix=%s --body >> %s" % ( cmd2 = "%s %s --prefix=%s --body >> %s" % (
@ -107,9 +106,9 @@ def add_enums(self, source='', target='',
@before('apply_core') @before('apply_core')
def process_enums(self): def process_enums(self):
for enum in getattr(self, 'enums_list', []): for enum in getattr(self, 'enums_list', []):
# temporary task = self.create_task('glib_mkenums')
env = self.env.copy() env = task.env
task = self.create_task('glib_mkenums', env)
inputs = [] inputs = []
# process the source # process the source
@ -154,10 +153,10 @@ def process_enums(self):
task.set_outputs(tgt_node) task.set_outputs(tgt_node)
Task.task_type_from_func('glib_genmarshal', func=genmarshal_func, vars=['GLIB_GENMARSHAL_PREFIX', 'GLIB_GENMARSHAL'], Task.task_type_from_func('glib_genmarshal', func=genmarshal_func, vars=['GLIB_GENMARSHAL_PREFIX', 'GLIB_GENMARSHAL'],
color='BLUE', before='cc') color='BLUE', before='cc cxx')
Task.simple_task_type('glib_mkenums', Task.simple_task_type('glib_mkenums',
'${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}', '${GLIB_MKENUMS} ${GLIB_MKENUMS_OPTIONS} ${GLIB_MKENUMS_SOURCE} > ${GLIB_MKENUMS_TARGET}',
color='PINK', before='cc') color='PINK', before='cc cxx')
def detect(conf): def detect(conf):
glib_genmarshal = conf.find_program('glib-genmarshal', var='GLIB_GENMARSHAL') glib_genmarshal = conf.find_program('glib-genmarshal', var='GLIB_GENMARSHAL')

4
tools/wafadmin/Tools/gnome.py

@ -112,9 +112,7 @@ def init_xml_to(self):
def apply_xml_to(self): def apply_xml_to(self):
xmlfile = self.path.find_resource(self.source) xmlfile = self.path.find_resource(self.source)
xsltfile = self.path.find_resource(self.xslt) xsltfile = self.path.find_resource(self.xslt)
tsk = self.create_task('xmlto') tsk = self.create_task('xmlto', [xmlfile, xsltfile], xmlfile.change_ext('html'))
tsk.set_inputs([xmlfile, xsltfile])
tsk.set_outputs(xmlfile.change_ext('html'))
tsk.install_path = self.install_path tsk.install_path = self.install_path
def sgml_scan(self): def sgml_scan(self):

2
tools/wafadmin/Tools/gnu_dirs.py

@ -65,7 +65,7 @@ def detect(conf):
env = conf.env env = conf.env
env['EXEC_PREFIX'] = get_param('EXEC_PREFIX', env['PREFIX']) env['EXEC_PREFIX'] = get_param('EXEC_PREFIX', env['PREFIX'])
env['PACKAGE'] = Utils.g_module.APPNAME or env['PACKAGE'] env['PACKAGE'] = getattr(Utils.g_module, 'APPNAME', None) or env['PACKAGE']
complete = False complete = False
iter = 0 iter = 0

11
tools/wafadmin/Tools/gxx.py

@ -22,6 +22,8 @@ def gxx_common_flags(conf):
v = conf.env v = conf.env
# CPPFLAGS CXXDEFINES _CXXINCFLAGS _CXXDEFFLAGS # CPPFLAGS CXXDEFINES _CXXINCFLAGS _CXXDEFFLAGS
v['CXXFLAGS_DEBUG'] = ['-g']
v['CXXFLAGS_RELEASE'] = ['-O2']
v['CXX_SRC_F'] = '' v['CXX_SRC_F'] = ''
v['CXX_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD v['CXX_TGT_F'] = ['-c', '-o', ''] # shell hack for -MD
@ -69,7 +71,13 @@ def gxx_modifier_win32(conf):
v['shlib_PATTERN'] = '%s.dll' v['shlib_PATTERN'] = '%s.dll'
v['implib_PATTERN'] = 'lib%s.dll.a' v['implib_PATTERN'] = 'lib%s.dll.a'
v['IMPLIB_ST'] = '-Wl,--out-implib,%s' v['IMPLIB_ST'] = '-Wl,--out-implib,%s'
v['shlib_CXXFLAGS'] = ['-DPIC', '-DDLL_EXPORT'] # TODO 64-bit platforms may need -fPIC
dest_arch = v['DEST_CPU']
if dest_arch == 'x86':
# On 32-bit x86, gcc emits a message telling the -fPIC option is ignored on this arch, so we remove that flag.
v['shlib_CXXFLAGS'] = ['-DPIC'] # TODO this is a wrong define, we don't use -fPIC!
v.append_value('shlib_CXXFLAGS', '-DDLL_EXPORT') # TODO adding nonstandard defines like this DLL_EXPORT is not a good idea
# Auto-import is enabled by default even without this option, # Auto-import is enabled by default even without this option,
# but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages # but enabling it explicitly has the nice effect of suppressing the rather boring, debug-level messages
@ -94,6 +102,7 @@ def gxx_modifier_darwin(conf):
v['SHLIB_MARKER'] = '' v['SHLIB_MARKER'] = ''
v['STATICLIB_MARKER'] = '' v['STATICLIB_MARKER'] = ''
v['SONAME_ST'] = ''
@conftest @conftest
def gxx_modifier_aix(conf): def gxx_modifier_aix(conf):

1
tools/wafadmin/Tools/icc.py

@ -33,4 +33,5 @@ gcc_common_flags
gcc_modifier_platform gcc_modifier_platform
cc_load_tools cc_load_tools
cc_add_flags cc_add_flags
link_add_flags
''' '''

5
tools/wafadmin/Tools/intltool.py

@ -42,10 +42,7 @@ def iapply_intltool_in_f(self):
self.env['INTLPODIR'] = podirnode.srcpath(self.env) self.env['INTLPODIR'] = podirnode.srcpath(self.env)
self.env['INTLFLAGS'] = getattr(self, 'flags', ['-q', '-u', '-c']) self.env['INTLFLAGS'] = getattr(self, 'flags', ['-q', '-u', '-c'])
task = self.create_task('intltool') task = self.create_task('intltool', node, node.change_ext(''))
task.set_inputs(node)
task.set_outputs(node.change_ext(''))
task.install_path = self.install_path task.install_path = self.install_path
class intltool_po_taskgen(TaskGen.task_gen): class intltool_po_taskgen(TaskGen.task_gen):

4
tools/wafadmin/Tools/kde4.py

@ -20,9 +20,7 @@ def init_msgfmt(self):
def apply_msgfmt(self): def apply_msgfmt(self):
for lang in self.to_list(self.langs): for lang in self.to_list(self.langs):
node = self.path.find_resource(lang+'.po') node = self.path.find_resource(lang+'.po')
task = self.create_task('msgfmt') task = self.create_task('msgfmt', node, node.change_ext('.mo'))
task.set_inputs(node)
task.set_outputs(node.change_ext('.mo'))
if not self.bld.is_install: continue if not self.bld.is_install: continue
langname = lang.split('/') langname = lang.split('/')

5
tools/wafadmin/Tools/libtool.py

@ -68,10 +68,7 @@ def read_la_file(path):
def apply_link_libtool(self): def apply_link_libtool(self):
if self.type != 'program': if self.type != 'program':
linktask = self.link_task linktask = self.link_task
latask = self.create_task('fakelibtool') self.latask = self.create_task('fakelibtool', linktask.outputs, linktask.outputs[0].change_ext('.la'))
latask.set_inputs(linktask.outputs)
latask.set_outputs(linktask.outputs[0].change_ext('.la'))
self.latask = latask
if self.bld.is_install: if self.bld.is_install:
self.bld.install_files('${PREFIX}/lib', linktask.outputs[0], self.env) self.bld.install_files('${PREFIX}/lib', linktask.outputs[0], self.env)

8
tools/wafadmin/Tools/misc.py

@ -69,9 +69,7 @@ def apply_copy(self):
# TODO the file path may be incorrect # TODO the file path may be incorrect
newnode = self.path.find_or_declare(target) newnode = self.path.find_or_declare(target)
tsk = self.create_task('copy') tsk = self.create_task('copy', node, newnode)
tsk.set_inputs(node)
tsk.set_outputs(newnode)
tsk.fun = self.fun tsk.fun = self.fun
tsk.chmod = self.chmod tsk.chmod = self.chmod
@ -141,9 +139,7 @@ def apply_subst(self):
lst = [self.dict[x] for x in keys] lst = [self.dict[x] for x in keys]
self.env['DICT_HASH'] = str(Utils.h_list(lst)) self.env['DICT_HASH'] = str(Utils.h_list(lst))
tsk = self.create_task('copy') tsk = self.create_task('copy', node, newnode)
tsk.set_inputs(node)
tsk.set_outputs(newnode)
tsk.fun = self.fun tsk.fun = self.fun
tsk.dict = self.dict tsk.dict = self.dict
tsk.dep_vars = ['DICT_HASH'] tsk.dep_vars = ['DICT_HASH']

29
tools/wafadmin/Tools/msvc.py

@ -443,6 +443,7 @@ cc_load_tools
cxx_load_tools cxx_load_tools
cc_add_flags cc_add_flags
cxx_add_flags cxx_add_flags
link_add_flags
''' '''
@conftest @conftest
@ -536,7 +537,7 @@ def find_msvc(conf):
def msvc_common_flags(conf): def msvc_common_flags(conf):
v = conf.env v = conf.env
v['CPPFLAGS'] = ['/W3', '/nologo', '/EHsc'] v['CPPFLAGS'] = ['/W3', '/nologo']
v['CCDEFINES_ST'] = '/D%s' v['CCDEFINES_ST'] = '/D%s'
v['CXXDEFINES_ST'] = '/D%s' v['CXXDEFINES_ST'] = '/D%s'
@ -585,16 +586,15 @@ def msvc_common_flags(conf):
v['CCFLAGS'] = ['/TC'] v['CCFLAGS'] = ['/TC']
v['CCFLAGS_OPTIMIZED'] = ['/O2', '/DNDEBUG'] v['CCFLAGS_OPTIMIZED'] = ['/O2', '/DNDEBUG']
v['CCFLAGS_RELEASE'] = ['/O2', '/DNDEBUG'] v['CCFLAGS_RELEASE'] = ['/O2', '/DNDEBUG']
# TODO _DEBUG is defined by the compiler itself! v['CCFLAGS_DEBUG'] = ['/Od', '/RTC1', '/ZI']
v['CCFLAGS_DEBUG'] = ['/Od', '/RTC1', '/D_DEBUG', '/ZI'] v['CCFLAGS_ULTRADEBUG'] = ['/Od', '/RTC1', '/ZI']
v['CCFLAGS_ULTRADEBUG'] = ['/Od', '/RTC1', '/D_DEBUG', '/ZI']
v['CXXFLAGS'] = ['/TP'] v['CXXFLAGS'] = ['/TP', '/EHsc']
v['CXXFLAGS_OPTIMIZED'] = ['/O2', '/DNDEBUG'] v['CXXFLAGS_OPTIMIZED'] = ['/O2', '/DNDEBUG']
v['CXXFLAGS_RELEASE'] = ['/O2', '/DNDEBUG'] v['CXXFLAGS_RELEASE'] = ['/O2', '/DNDEBUG']
# TODO _DEBUG is defined by the compiler itself!
v['CXXFLAGS_DEBUG'] = ['/Od', '/RTC1', '/D_DEBUG', '/ZI'] v['CXXFLAGS_DEBUG'] = ['/Od', '/RTC1', '/ZI']
v['CXXFLAGS_ULTRADEBUG'] = ['/Od', '/RTC1', '/D_DEBUG', '/ZI'] v['CXXFLAGS_ULTRADEBUG'] = ['/Od', '/RTC1', '/ZI']
# linker # linker
v['LIB'] = [] v['LIB'] = []
@ -604,7 +604,9 @@ def msvc_common_flags(conf):
v['STATICLIB_ST'] = 'lib%s.lib' # Note: to be able to distinguish between a static lib and a dll import lib, it's a good pratice to name the static lib 'lib%s.lib' and the dll import lib '%s.lib' v['STATICLIB_ST'] = 'lib%s.lib' # Note: to be able to distinguish between a static lib and a dll import lib, it's a good pratice to name the static lib 'lib%s.lib' and the dll import lib '%s.lib'
v['STATICLIBPATH_ST'] = '/LIBPATH:%s' v['STATICLIBPATH_ST'] = '/LIBPATH:%s'
v['LINKFLAGS'] = ['/NOLOGO', '/MANIFEST'] v['LINKFLAGS'] = ['/NOLOGO', '/MANIFEST']
v['LINKFLAGS_DEBUG'] = ['/DEBUG']
v['LINKFLAGS_ULTRADEBUG'] = ['/DEBUG']
# shared library # shared library
v['shlib_CCFLAGS'] = [''] v['shlib_CCFLAGS'] = ['']
@ -628,7 +630,7 @@ def msvc_common_flags(conf):
@after('apply_link') @after('apply_link')
@feature('cc', 'cxx') @feature('cc', 'cxx')
def apply_flags_msvc(self): def apply_flags_msvc(self):
if self.env.CC_NAME != 'msvc': if self.env.CC_NAME != 'msvc' or not self.link_task:
return return
subsystem = getattr(self, 'subsystem', '') subsystem = getattr(self, 'subsystem', '')
@ -637,8 +639,9 @@ def apply_flags_msvc(self):
flags = 'cstaticlib' in self.features and 'ARFLAGS' or 'LINKFLAGS' flags = 'cstaticlib' in self.features and 'ARFLAGS' or 'LINKFLAGS'
self.env.append_value(flags, subsystem) self.env.append_value(flags, subsystem)
if 'cstaticlib' not in self.features: if getattr(self, 'link_task', None) and not 'cstaticlib' in self.features:
for d in (f.lower() for f in self.env.LINKFLAGS): for f in self.env.LINKFLAGS:
d = f.lower()
if d[1:] == 'debug': if d[1:] == 'debug':
pdbnode = self.link_task.outputs[0].change_ext('.pdb') pdbnode = self.link_task.outputs[0].change_ext('.pdb')
pdbfile = pdbnode.bldpath(self.env) pdbfile = pdbnode.bldpath(self.env)
@ -768,7 +771,7 @@ def exec_command_msvc(self, *k, **kw):
return self.generator.bld.exec_command(*k, **kw) return self.generator.bld.exec_command(*k, **kw)
for k in 'cc cxx winrc cc_link cxx_link static_link'.split(): for k in 'cc cxx winrc cc_link cxx_link static_link qxx'.split():
cls = Task.TaskBase.classes.get(k, None) cls = Task.TaskBase.classes.get(k, None)
if cls: if cls:
cls.exec_command = exec_command_msvc cls.exec_command = exec_command_msvc

5
tools/wafadmin/Tools/nasm.py

@ -36,10 +36,7 @@ def nasm_file(self, node):
try: obj_ext = self.obj_ext try: obj_ext = self.obj_ext
except AttributeError: obj_ext = '_%d.o' % self.idx except AttributeError: obj_ext = '_%d.o' % self.idx
task = self.create_task('nasm') task = self.create_task('nasm', node, node.change_ext(obj_ext))
task.inputs = [node]
task.outputs = [node.change_ext(obj_ext)]
self.compiled_tasks.append(task) self.compiled_tasks.append(task)
self.meths.append('apply_nasm_vars') self.meths.append('apply_nasm_vars')

29
tools/wafadmin/Tools/ocaml.py

@ -168,57 +168,42 @@ def apply_link_ml(self):
@extension(EXT_MLL) @extension(EXT_MLL)
def mll_hook(self, node): def mll_hook(self, node):
mll_task = self.create_task('ocamllex', self.native_env) mll_task = self.create_task('ocamllex', node, node.change_ext('.ml'), env=self.native_env)
mll_task.set_inputs(node)
mll_task.set_outputs(node.change_ext('.ml'))
self.mlltasks.append(mll_task) self.mlltasks.append(mll_task)
self.allnodes.append(mll_task.outputs[0]) self.allnodes.append(mll_task.outputs[0])
@extension(EXT_MLY) @extension(EXT_MLY)
def mly_hook(self, node): def mly_hook(self, node):
mly_task = self.create_task('ocamlyacc', self.native_env) mly_task = self.create_task('ocamlyacc', node, [node.change_ext('.ml'), node.change_ext('.mli')], env=self.native_env)
mly_task.set_inputs(node)
mly_task.set_outputs([node.change_ext('.ml'), node.change_ext('.mli')])
self.mlytasks.append(mly_task) self.mlytasks.append(mly_task)
self.allnodes.append(mly_task.outputs[0]) self.allnodes.append(mly_task.outputs[0])
task = self.create_task('ocamlcmi', self.native_env) task = self.create_task('ocamlcmi', mly_task.outputs[1], mly_task.outputs[1].change_ext('.cmi'), env=self.native_env)
task.set_inputs(mly_task.outputs[1])
task.set_outputs(mly_task.outputs[1].change_ext('.cmi'))
@extension(EXT_MLI) @extension(EXT_MLI)
def mli_hook(self, node): def mli_hook(self, node):
task = self.create_task('ocamlcmi', self.native_env) task = self.create_task('ocamlcmi', node, node.change_ext('.cmi'), env=self.native_env)
task.set_inputs(node)
task.set_outputs(node.change_ext('.cmi'))
self.mlitasks.append(task) self.mlitasks.append(task)
@extension(EXT_MLC) @extension(EXT_MLC)
def mlc_hook(self, node): def mlc_hook(self, node):
task = self.create_task('ocamlcc', self.native_env) task = self.create_task('ocamlcc', node, node.change_ext('.o'), env=self.native_env)
task.set_inputs(node)
task.set_outputs(node.change_ext('.o'))
self.compiled_tasks.append(task) self.compiled_tasks.append(task)
@extension(EXT_ML) @extension(EXT_ML)
def ml_hook(self, node): def ml_hook(self, node):
if self.native_env: if self.native_env:
task = self.create_task('ocamlx', self.native_env) task = self.create_task('ocamlx', node, node.change_ext('.cmx'), env=self.native_env)
task.set_inputs(node)
task.set_outputs(node.change_ext('.cmx'))
task.obj = self task.obj = self
task.incpaths = self.bld_incpaths_lst task.incpaths = self.bld_incpaths_lst
self.native_tasks.append(task) self.native_tasks.append(task)
if self.bytecode_env: if self.bytecode_env:
task = self.create_task('ocaml', self.bytecode_env) task = self.create_task('ocaml', node, node.change_ext('.cmo'), env=self.bytecode_env)
task.set_inputs(node)
task.obj = self task.obj = self
task.bytecode = 1 task.bytecode = 1
task.incpaths = self.bld_incpaths_lst task.incpaths = self.bld_incpaths_lst
task.set_outputs(node.change_ext('.cmo'))
self.bytecode_tasks.append(task) self.bytecode_tasks.append(task)
def compile_may_start(self): def compile_may_start(self):

4
tools/wafadmin/Tools/osx.py

@ -89,7 +89,7 @@ def create_task_macapp(self):
"""Use env['MACAPP'] to force *all* executables to be transformed into Mac applications """Use env['MACAPP'] to force *all* executables to be transformed into Mac applications
or use obj.mac_app = True to build specific targets as Mac apps""" or use obj.mac_app = True to build specific targets as Mac apps"""
if self.env['MACAPP'] or getattr(self, 'mac_app', False): if self.env['MACAPP'] or getattr(self, 'mac_app', False):
apptask = self.create_task('macapp', self.env) apptask = self.create_task('macapp')
apptask.set_inputs(self.link_task.outputs) apptask.set_inputs(self.link_task.outputs)
out = self.link_task.outputs[0] out = self.link_task.outputs[0]
@ -114,7 +114,7 @@ def create_task_macplist(self):
if not getattr(self, 'mac_plist', False): if not getattr(self, 'mac_plist', False):
self.mac_plist = app_info self.mac_plist = app_info
plisttask = self.create_task('macplist', self.env) plisttask = self.create_task('macplist')
plisttask.set_inputs(self.link_task.outputs) plisttask.set_inputs(self.link_task.outputs)
out = self.link_task.outputs[0] out = self.link_task.outputs[0]

7
tools/wafadmin/Tools/perl.py

@ -20,14 +20,11 @@ def init_perlext(self):
@extension(EXT_XS) @extension(EXT_XS)
def xsubpp_file(self, node): def xsubpp_file(self, node):
gentask = self.create_task('xsubpp')
gentask.set_inputs(node)
outnode = node.change_ext('.c') outnode = node.change_ext('.c')
gentask.set_outputs(outnode) self.create_task('xsubpp', node, outnode)
self.allnodes.append(outnode) self.allnodes.append(outnode)
Task.simple_task_type('xsubpp', xsubpp_str, color='BLUE', before="cc cxx", shell=False) Task.simple_task_type('xsubpp', xsubpp_str, color='BLUE', before='cc cxx', shell=False)
@conf @conf
def check_perl_version(conf, minver=None): def check_perl_version(conf, minver=None):

17
tools/wafadmin/Tools/python.py

@ -159,7 +159,8 @@ def check_python_headers(conf):
env = conf.env env = conf.env
python = env['PYTHON'] python = env['PYTHON']
assert python, ("python is %r !" % (python,)) if not python:
conf.fatal('could not find the python executable')
## On Mac OSX we need to use mac bundles for python plugins ## On Mac OSX we need to use mac bundles for python plugins
if Options.platform == 'darwin': if Options.platform == 'darwin':
@ -309,7 +310,8 @@ def check_python_version(conf, minver=None):
""" """
assert minver is None or isinstance(minver, tuple) assert minver is None or isinstance(minver, tuple)
python = conf.env['PYTHON'] python = conf.env['PYTHON']
assert python, ("python is %r !" % (python,)) if not python:
conf.fatal('could not find the python executable')
# Get python version string # Get python version string
cmd = [python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"] cmd = [python, "-c", "import sys\nfor x in sys.version_info: print(str(x))"]
@ -361,7 +363,7 @@ def check_python_version(conf, minver=None):
conf.check_message('Python version', ">= %s" % (minver_str,), result, option=pyver_full) conf.check_message('Python version', ">= %s" % (minver_str,), result, option=pyver_full)
if not result: if not result:
conf.fatal("Python too old.") conf.fatal('The python version is too old (%r)' % minver)
@conf @conf
def check_python_module(conf, module_name): def check_python_module(conf, module_name):
@ -372,11 +374,16 @@ def check_python_module(conf, module_name):
stderr=Utils.pproc.PIPE, stdout=Utils.pproc.PIPE).wait() stderr=Utils.pproc.PIPE, stdout=Utils.pproc.PIPE).wait()
conf.check_message('Python module', module_name, result) conf.check_message('Python module', module_name, result)
if not result: if not result:
conf.fatal("Python module not found.") conf.fatal('Could not find the python module %r' % module_name)
def detect(conf): def detect(conf):
if not conf.env.PYTHON:
conf.env.PYTHON = sys.executable
python = conf.find_program('python', var='PYTHON') python = conf.find_program('python', var='PYTHON')
if not python: return if not python:
conf.fatal('Could not find the path of the python executable')
v = conf.env v = conf.env

138
tools/wafadmin/Tools/qt4.py

@ -197,7 +197,6 @@ def scan(self):
names = [] names = []
root = self.inputs[0].parent root = self.inputs[0].parent
for x in curHandler.files: for x in curHandler.files:
x = x.encode('utf8')
nd = root.find_resource(x) nd = root.find_resource(x)
if nd: nodes.append(nd) if nd: nodes.append(nd)
else: names.append(x) else: names.append(x)
@ -207,25 +206,16 @@ def scan(self):
@extension(EXT_RCC) @extension(EXT_RCC)
def create_rcc_task(self, node): def create_rcc_task(self, node):
"hook for rcc files" "hook for rcc files"
rcnode = node.change_ext('_rc.cpp') rcnode = node.change_ext('_rc.cpp')
rcctask = self.create_task('rcc', node, rcnode)
rcctask = self.create_task('rcc') cpptask = self.create_task('cxx', rcnode, rcnode.change_ext('.o'))
rcctask.inputs = [node]
rcctask.outputs = [rcnode]
cpptask = self.create_task('cxx')
cpptask.inputs = [rcnode]
cpptask.outputs = [rcnode.change_ext('.o')]
self.compiled_tasks.append(cpptask) self.compiled_tasks.append(cpptask)
return cpptask return cpptask
@extension(EXT_UI) @extension(EXT_UI)
def create_uic_task(self, node): def create_uic_task(self, node):
"hook for uic tasks" "hook for uic tasks"
uictask = self.create_task('ui4') uictask = self.create_task('ui4', node)
uictask.inputs = [node]
uictask.outputs = [self.path.find_or_declare(self.env['ui_PATTERN'] % node.name[:-3])] uictask.outputs = [self.path.find_or_declare(self.env['ui_PATTERN'] % node.name[:-3])]
class qt4_taskgen(cxx.cxx_taskgen): class qt4_taskgen(cxx.cxx_taskgen):
@ -250,9 +240,7 @@ def apply_qt4(self):
if not isinstance(l, Node.Node): if not isinstance(l, Node.Node):
l = self.path.find_resource(l+'.ts') l = self.path.find_resource(l+'.ts')
t = self.create_task('ts2qm') t = self.create_task('ts2qm', l, l.change_ext('.qm'))
t.set_inputs(l)
t.set_outputs(l.change_ext('.qm'))
lst.append(t.outputs[0]) lst.append(t.outputs[0])
if update: if update:
@ -283,13 +271,11 @@ def apply_qt4(self):
@extension(EXT_QT4) @extension(EXT_QT4)
def cxx_hook(self, node): def cxx_hook(self, node):
# create the compilation task: cpp or cc # create the compilation task: cpp or cc
task = self.create_task('qxx')
self.compiled_tasks.append(task)
try: obj_ext = self.obj_ext try: obj_ext = self.obj_ext
except AttributeError: obj_ext = '_%d.o' % self.idx except AttributeError: obj_ext = '_%d.o' % self.idx
task.inputs = [node] task = self.create_task('qxx', node, node.change_ext(obj_ext))
task.outputs = [node.change_ext(obj_ext)] self.compiled_tasks.append(task)
def process_qm2rcc(task): def process_qm2rcc(task):
outfile = task.outputs[0].abspath(task.env) outfile = task.outputs[0].abspath(task.env)
@ -393,45 +379,6 @@ def detect_qt4(conf):
vars = "QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtWebKit Qt3Support".split() vars = "QtCore QtGui QtUiTools QtNetwork QtOpenGL QtSql QtSvg QtTest QtXml QtWebKit Qt3Support".split()
framework_ok = False
if sys.platform == "darwin" and useframework:
for i in vars:
e = conf.create_framework_configurator()
e.path = [qtlibs, '/Library/Frameworks']
e.name = i
e.remove_dot_h = True
e.run()
if not i == 'QtCore':
# strip -F flag so it don't get reduant
for r in env['CCFLAGS_' + i.upper()]:
if r.startswith('-F'):
env['CCFLAGS_' + i.upper()].remove(r)
break
# incflag = '-I%s' % os.path.join(qtincludes, i)
# if not incflag in env["CCFLAGS_" + i.upper ()]:
# env['CCFLAGS_' + i.upper ()] += [incflag]
# if not incflag in env["CXXFLAGS_" + i.upper ()]:
# env['CXXFLAGS_' + i.upper ()] += [incflag]
# now we add some static depends.
if conf.is_defined('HAVE_QTOPENGL'):
env.append_unique('FRAMEWORK_QTOPENGL', 'OpenGL')
if conf.is_defined('HAVE_QTGUI'):
env.append_unique('FRAMEWORK_QTGUI', ['AppKit', 'ApplicationServices'])
framework_ok = True
# check for the qt includes first
if not conf.is_defined("HAVE_QTGUI"):
if not qtincludes: qtincludes = os.path.join(qtdir, 'include')
env.QTINCLUDEPATH = qtincludes
lst = [qtincludes, '/usr/share/qt4/include/', '/opt/qt4/include']
conf.check(header_name='QtGui/QFont', define_name='HAVE_QTGUI', mandatory=1, includes=lst)
find_bin(['uic-qt3', 'uic3'], 'QT_UIC3') find_bin(['uic-qt3', 'uic3'], 'QT_UIC3')
find_bin(['uic-qt4', 'uic'], 'QT_UIC') find_bin(['uic-qt4', 'uic'], 'QT_UIC')
if not env['QT_UIC']: if not env['QT_UIC']:
@ -460,52 +407,51 @@ def detect_qt4(conf):
env['ui_PATTERN'] = 'ui_%s.h' env['ui_PATTERN'] = 'ui_%s.h'
env['QT_LRELEASE_FLAGS'] = ['-silent'] env['QT_LRELEASE_FLAGS'] = ['-silent']
if not framework_ok: # framework_ok is false either when the platform isn't OSX, Qt4 shall not be used as framework, or Qt4 could not be found as framework vars_debug = [a+'_debug' for a in vars]
vars_debug = [a+'_debug' for a in vars]
pkgconfig = env['pkg-config'] or 'PKG_CONFIG_PATH=%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib pkg-config --silence-errors' % (qtlibs, qtlibs) pkgconfig = env['pkg-config'] or 'PKG_CONFIG_PATH=%s:%s/pkgconfig:/usr/lib/qt4/lib/pkgconfig:/opt/qt4/lib/pkgconfig:/usr/lib/qt4/lib:/opt/qt4/lib pkg-config --silence-errors' % (qtlibs, qtlibs)
for i in vars_debug+vars: for i in vars_debug+vars:
try: try:
conf.check_cfg(package=i, args='--cflags --libs', path=pkgconfig) conf.check_cfg(package=i, args='--cflags --libs', path=pkgconfig)
except ValueError: except ValueError:
pass pass
# the libpaths are set nicely, unfortunately they make really long command-lines # the libpaths are set nicely, unfortunately they make really long command-lines
# remove the qtcore ones from qtgui, etc # remove the qtcore ones from qtgui, etc
def process_lib(vars_, coreval): def process_lib(vars_, coreval):
for d in vars_:
var = d.upper()
if var == 'QTCORE': continue
value = env['LIBPATH_'+var]
if value:
core = env[coreval]
accu = []
for lib in value:
if lib in core: continue
accu.append(lib)
env['LIBPATH_'+var] = accu
process_lib(vars, 'LIBPATH_QTCORE')
process_lib(vars_debug, 'LIBPATH_QTCORE_DEBUG')
# rpath if wanted
if Options.options.want_rpath:
def process_rpath(vars_, coreval):
for d in vars_: for d in vars_:
var = d.upper() var = d.upper()
if var == 'QTCORE': continue
value = env['LIBPATH_'+var] value = env['LIBPATH_'+var]
if value: if value:
core = env[coreval] core = env[coreval]
accu = [] accu = []
for lib in value: for lib in value:
if lib in core: continue if var != 'QTCORE':
accu.append(lib) if lib in core:
env['LIBPATH_'+var] = accu continue
accu.append('-Wl,--rpath='+lib)
process_lib(vars, 'LIBPATH_QTCORE') env['RPATH_'+var] = accu
process_lib(vars_debug, 'LIBPATH_QTCORE_DEBUG') process_rpath(vars, 'LIBPATH_QTCORE')
process_rpath(vars_debug, 'LIBPATH_QTCORE_DEBUG')
# rpath if wanted
if Options.options.want_rpath:
def process_rpath(vars_, coreval):
for d in vars_:
var = d.upper()
value = env['LIBPATH_'+var]
if value:
core = env[coreval]
accu = []
for lib in value:
if var != 'QTCORE':
if lib in core:
continue
accu.append('-Wl,--rpath='+lib)
env['RPATH_'+var] = accu
process_rpath(vars, 'LIBPATH_QTCORE')
process_rpath(vars_debug, 'LIBPATH_QTCORE_DEBUG')
env['QTLOCALE'] = str(env['PREFIX'])+'/share/locale' env['QTLOCALE'] = str(env['PREFIX'])+'/share/locale'

1
tools/wafadmin/Tools/suncc.py

@ -71,5 +71,6 @@ find_ar
scc_common_flags scc_common_flags
cc_load_tools cc_load_tools
cc_add_flags cc_add_flags
link_add_flags
''' '''

20
tools/wafadmin/Tools/tex.py

@ -176,13 +176,9 @@ def apply_tex(self):
if not node: raise Utils.WafError('cannot find %s' % filename) if not node: raise Utils.WafError('cannot find %s' % filename)
if self.type == 'latex': if self.type == 'latex':
task = self.create_task('latex') task = self.create_task('latex', node, node.change_ext('.dvi'))
task.set_inputs(node)
task.set_outputs(node.change_ext('.dvi'))
elif self.type == 'pdflatex': elif self.type == 'pdflatex':
task = self.create_task('pdflatex') task = self.create_task('pdflatex', node, node.change_ext('.pdf'))
task.set_inputs(node)
task.set_outputs(node.change_ext('.pdf'))
task.env = self.env task.env = self.env
task.curdirnode = self.path task.curdirnode = self.path
@ -200,18 +196,12 @@ def apply_tex(self):
if self.type == 'latex': if self.type == 'latex':
if 'ps' in outs: if 'ps' in outs:
pstask = self.create_task('dvips') self.create_task('dvips', task.outputs, node.change_ext('.ps'))
pstask.set_inputs(task.outputs)
pstask.set_outputs(node.change_ext('.ps'))
if 'pdf' in outs: if 'pdf' in outs:
pdftask = self.create_task('dvipdf') self.create_task('dvipdf', task.outputs, node.change_ext('.pdf'))
pdftask.set_inputs(task.outputs)
pdftask.set_outputs(node.change_ext('.pdf'))
elif self.type == 'pdflatex': elif self.type == 'pdflatex':
if 'ps' in outs: if 'ps' in outs:
pstask = self.create_task('pdf2ps') self.create_task('pdf2ps', task.outputs, node.change_ext('.ps'))
pstask.set_inputs(task.outputs)
pstask.set_outputs(node.change_ext('.ps'))
self.source = [] self.source = []
def detect(conf): def detect(conf):

6
tools/wafadmin/Tools/vala.py

@ -114,10 +114,8 @@ class valac_task(Task.Task):
api_version = version[0] + ".0" api_version = version[0] + ".0"
install_path = '${INCLUDEDIR}/%s-%s/%s' % (package, api_version, header.relpath_gen(top_src)) install_path = '${INCLUDEDIR}/%s-%s/%s' % (package, api_version, header.relpath_gen(top_src))
bld.install_as(install_path, header, self.env) bld.install_as(install_path, header, self.env)
for vapi in vapi_list: bld.install_files('${DATAROOTDIR}/vala/vapi', vapi_list, self.env)
bld.install_files('${DATAROOTDIR}/vala/vapi', vapi, self.env) bld.install_files('${DATAROOTDIR}/gir-1.0', gir_list, self.env)
for gir in gir_list:
bld.install_files('${DATAROOTDIR}/gir-1.0', gir, self.env)
def _fix_output(self, output): def _fix_output(self, output):
top_bld = self.generator.bld.srcnode.abspath(self.env) top_bld = self.generator.bld.srcnode.abspath(self.env)

6
tools/wafadmin/Tools/winres.py

@ -18,11 +18,7 @@ def rc_file(self, node):
obj_ext = '.rc.o' obj_ext = '.rc.o'
if self.env['WINRC_TGT_F'] == '/fo': obj_ext = '.res' if self.env['WINRC_TGT_F'] == '/fo': obj_ext = '.res'
rctask = self.create_task('winrc') rctask = self.create_task('winrc', node, node.change_ext(obj_ext))
rctask.set_inputs(node)
rctask.set_outputs(node.change_ext(obj_ext))
# make linker can find compiled resource files
self.compiled_tasks.append(rctask) self.compiled_tasks.append(rctask)
# create our action, for use with rc file # create our action, for use with rc file

53
tools/wafadmin/Utils.py

@ -46,6 +46,13 @@ else:
import Logs import Logs
from Constants import * from Constants import *
try:
from collections import deque
except ImportError:
class deque(list):
def popleft(self):
return self.pop(0)
is_win32 = sys.platform == 'win32' is_win32 = sys.platform == 'win32'
try: try:
@ -67,7 +74,10 @@ except ImportError:
class WafError(Exception): class WafError(Exception):
def __init__(self, *args): def __init__(self, *args):
self.args = args self.args = args
self.stack = traceback.extract_stack() try:
self.stack = traceback.extract_stack()
except:
pass
Exception.__init__(self, *args) Exception.__init__(self, *args)
def __str__(self): def __str__(self):
return str(len(self.args) == 1 and self.args[0] or self.args) return str(len(self.args) == 1 and self.args[0] or self.args)
@ -78,7 +88,10 @@ class WscriptError(WafError):
self.wscript_file = wscript_file self.wscript_file = wscript_file
self.wscript_line = None self.wscript_line = None
else: else:
(self.wscript_file, self.wscript_line) = self.locate_error() try:
(self.wscript_file, self.wscript_line) = self.locate_error()
except:
(self.wscript_file, self.wscript_line) = (None, None)
msg_file_line = '' msg_file_line = ''
if self.wscript_file: if self.wscript_file:
@ -124,7 +137,6 @@ except ImportError:
def h_file(filename): def h_file(filename):
f = open(filename, 'rb') f = open(filename, 'rb')
m = md5() m = md5()
readBytes = 100000
while (filename): while (filename):
filename = f.read(100000) filename = f.read(100000)
m.update(filename) m.update(filename)
@ -171,10 +183,12 @@ if is_win32:
try: try:
if 'stdout' not in kw: if 'stdout' not in kw:
kw['stdout'] = pproc.PIPE kw['stdout'] = pproc.PIPE
kw['stderr'] = pproc.STDOUT kw['stderr'] = pproc.PIPE
proc = pproc.Popen(s,**kw) proc = pproc.Popen(s,**kw)
(stdout, _) = proc.communicate() (stdout, stderr) = proc.communicate()
Logs.info(stdout) Logs.info(stdout)
if stderr:
Logs.error(stderr)
else: else:
proc = pproc.Popen(s,**kw) proc = pproc.Popen(s,**kw)
return proc.wait() return proc.wait()
@ -252,8 +266,11 @@ def load_module(file_path, name=WSCRIPT_FILE):
sys.path.insert(0, module_dir) sys.path.insert(0, module_dir)
try: try:
exec(code, module.__dict__) exec(code, module.__dict__)
except Exception: except Exception, e:
raise WscriptError(traceback.format_exc(), file_path) try:
raise WscriptError(traceback.format_exc(), file_path)
except:
raise e
sys.path.remove(module_dir) sys.path.remove(module_dir)
g_loaded_modules[file_path] = module g_loaded_modules[file_path] = module
@ -347,14 +364,10 @@ def def_attrs(cls, **kw):
if not hasattr(cls, k): if not hasattr(cls, k):
setattr(cls, k, v) setattr(cls, k, v)
quote_define_name_table = None
def quote_define_name(path): def quote_define_name(path):
"Converts a string to a constant name, foo/zbr-xpto.h -> FOO_ZBR_XPTO_H" fu = re.compile("[^a-zA-Z0-9]").sub("_", path)
global quote_define_name_table fu = fu.upper()
if not quote_define_name_table: return fu
invalid_chars = set([chr(x) for x in xrange(256)]) - set(string.digits + string.uppercase)
quote_define_name_table = string.maketrans(''.join(invalid_chars), '_'*len(invalid_chars))
return string.translate(string.upper(path), quote_define_name_table)
def quote_whitespace(path): def quote_whitespace(path):
return (path.strip().find(' ') > 0 and '"%s"' % path or path).replace('""', '"') return (path.strip().find(' ') > 0 and '"%s"' % path or path).replace('""', '"')
@ -524,12 +537,11 @@ def load_tool(tool, tooldir=None):
def readf(fname, m='r'): def readf(fname, m='r'):
"get the contents of a file, it is not used anywhere for the moment" "get the contents of a file, it is not used anywhere for the moment"
f = None f = open(fname, m)
try: try:
f = open(fname, m)
txt = f.read() txt = f.read()
finally: finally:
if f: f.close() f.close()
return txt return txt
def nada(*k, **kw): def nada(*k, **kw):
@ -610,8 +622,11 @@ class Context(object):
try: try:
try: try:
exec(txt, dc) exec(txt, dc)
except Exception: except Exception, e:
raise WscriptError(traceback.format_exc(), base) try:
raise WscriptError(traceback.format_exc(), base)
except:
raise e
finally: finally:
self.curdir = old self.curdir = old
if getattr(self.__class__, 'post_recurse', None): if getattr(self.__class__, 'post_recurse', None):

202
tools/wafadmin/ansiterm.py

@ -0,0 +1,202 @@
import sys, os
try:
from ctypes import *
class COORD(Structure):
_fields_ = [("X", c_short), ("Y", c_short)]
class SMALL_RECT(Structure):
_fields_ = [("Left", c_short), ("Top", c_short), ("Right", c_short), ("Bottom", c_short)]
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
_fields_ = [("Size", COORD), ("CursorPosition", COORD), ("Attributes", c_short), ("Window", SMALL_RECT), ("MaximumWindowSize", COORD)]
sbinfo = CONSOLE_SCREEN_BUFFER_INFO()
hconsole = windll.kernel32.GetStdHandle(-11)
windll.kernel32.GetConsoleScreenBufferInfo(hconsole, byref(sbinfo))
except Exception:
pass
else:
import re
to_int = lambda number, default: number and int(number) or default
STD_OUTPUT_HANDLE = -11
STD_ERROR_HANDLE = -12
class AnsiTerm(object):
def __init__(self):
self.hconsole = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
self.cursor_history = []
def screen_buffer_info(self):
sbinfo = CONSOLE_SCREEN_BUFFER_INFO()
windll.kernel32.GetConsoleScreenBufferInfo(self.hconsole, byref(sbinfo))
return sbinfo
def clear_line(self, param):
mode = param and int(param) or 0
sbinfo = self.screen_buffer_info()
if mode == 1: # Clear from begining of line to cursor position
line_start = COORD(0, sbinfo.CursorPosition.Y)
line_length = sbinfo.Size.X
elif mode == 2: # Clear entire line
line_start = COORD(sbinfo.CursorPosition.X, sbinfo.CursorPosition.Y)
line_length = sbinfo.Size.X - sbinfo.CursorPosition.X
else: # Clear from cursor position to end of line
line_start = sbinfo.CursorPosition
line_length = sbinfo.Size.X - sbinfo.CursorPosition.X
chars_written = c_int()
windll.kernel32.FillConsoleOutputCharacterA(self.hconsole, c_char(' '), line_length, line_start, byref(chars_written))
windll.kernel32.FillConsoleOutputAttribute(self.hconsole, sbinfo.Attributes, line_length, line_start, byref(chars_written))
def clear_screen(self, param):
mode = to_int(param, 0)
sbinfo = self.screen_buffer_info()
if mode == 1: # Clear from begining of screen to cursor position
clear_start = COORD(0, 0)
clear_length = sbinfo.CursorPosition.X * sbinfo.CursorPosition.Y
elif mode == 2: # Clear entire screen and return cursor to home
clear_start = COORD(0, 0)
clear_length = sbinfo.Size.X * sbinfo.Size.Y
windll.kernel32.SetConsoleCursorPosition(self.hconsole, clear_start)
else: # Clear from cursor position to end of screen
clear_start = sbinfo.CursorPosition
clear_length = ((sbinfo.Size.X - sbinfo.CursorPosition.X) +
sbinfo.Size.X * (sbinfo.Size.Y - sbinfo.CursorPosition.Y))
chars_written = c_int()
windll.kernel32.FillConsoleOutputCharacterA(self.hconsole, c_char(' '), clear_length, clear_start, byref(chars_written))
windll.kernel32.FillConsoleOutputAttribute(self.hconsole, sbinfo.Attributes, clear_length, clear_start, byref(chars_written))
def push_cursor(self, param):
sbinfo = self.screen_buffer_info()
self.cursor_history.push(sbinfo.CursorPosition)
def pop_cursor(self, param):
if self.cursor_history:
old_pos = self.cursor_history.pop()
windll.kernel32.SetConsoleCursorPosition(self.hconsole, old_pos)
def set_cursor(self, param):
x, sep, y = param.partition(';')
x = to_int(x, 1) - 1
y = to_int(y, 1) - 1
sbinfo = self.screen_buffer_info()
new_pos = COORD(
min(max(0, x), sbinfo.Size.X),
min(max(0, y), sbinfo.Size.Y)
)
windll.kernel32.SetConsoleCursorPosition(self.hconsole, new_pos)
def set_column(self, param):
x = to_int(param, 1) - 1
sbinfo = self.screen_buffer_info()
new_pos = COORD(
min(max(0, x), sbinfo.Size.X),
sbinfo.CursorPosition.Y
)
windll.kernel32.SetConsoleCursorPosition(self.hconsole, new_pos)
def move_cursor(self, x_offset=0, y_offset=0):
sbinfo = self.screen_buffer_info()
new_pos = COORD(
min(max(0, sbinfo.CursorPosition.X + x_offset), sbinfo.Size.X),
min(max(0, sbinfo.CursorPosition.Y + y_offset), sbinfo.Size.Y)
)
windll.kernel32.SetConsoleCursorPosition(self.hconsole, new_pos)
def move_up(self, param):
self.move_cursor(y_offset = -to_int(param, 1))
def move_down(self, param):
self.move_cursor(y_offset = to_int(param, 1))
def move_left(self, param):
self.move_cursor(x_offset = -to_int(param, 1))
def move_right(self, param):
self.move_cursor(x_offset = to_int(param, 1))
def next_line(self, param):
sbinfo = self.screen_buffer_info()
self.move_cursor(
x_offset = -sbinfo.CursorPosition.X,
y_offset = to_int(param, 1)
)
def prev_line(self, param):
sbinfo = self.screen_buffer_info()
self.move_cursor(
x_offset = -sbinfo.CursorPosition.X,
y_offset = -to_int(param, 1)
)
escape_to_color = { (0, 30): 0x0, #black
(0, 31): 0x4, #red
(0, 32): 0x2, #green
(0, 33): 0x4+0x2, #dark yellow
(0, 34): 0x1, #blue
(0, 35): 0x1+0x4, #purple
(0, 36): 0x2+0x4, #cyan
(0, 37): 0x1+0x2+0x4, #grey
(1, 30): 0x1+0x2+0x4, #dark gray
(1, 31): 0x4+0x8, #red
(1, 32): 0x2+0x8, #light green
(1, 33): 0x4+0x2+0x8, #yellow
(1, 34): 0x1+0x8, #light blue
(1, 35): 0x1+0x4+0x8, #light purple
(1, 36): 0x1+0x2+0x8, #light cyan
(1, 37): 0x1+0x2+0x4+0x8, #white
}
def set_color(self, param):
intensity, sep, color = param.partition(';')
intensity = to_int(intensity, 0)
color = to_int(color, 0)
if intensity and not color:
color, intensity = intensity, color
attrib = self.escape_to_color.get((intensity, color), 0x7)
windll.kernel32.SetConsoleTextAttribute(self.hconsole, attrib)
ansi_command_table = {
'A': move_up,
'B': move_down,
'C': move_right,
'D': move_left,
'E': next_line,
'F': prev_line,
'G': set_column,
'H': set_cursor,
'f': set_cursor,
'J': clear_screen,
'K': clear_line,
'm': set_color,
's': push_cursor,
'u': pop_cursor,
}
# Match either the escape sequence or text not containing escape sequence
ansi_tokans = re.compile('(?:\x1b\[([0-9;]*)([a-zA-Z])|([^\x1b]+))')
def write(self, text):
for param, cmd, txt in self.ansi_tokans.findall(text):
if cmd:
cmd_func = self.ansi_command_table.get(cmd)
if cmd_func:
cmd_func(self, param)
else:
chars_written = c_int()
if isinstance(txt, unicode):
windll.kernel32.WriteConsoleW(self.hconsole, txt, len(txt), byref(chars_written), None)
else:
windll.kernel32.WriteConsoleA(self.hconsole, txt, len(txt), byref(chars_written), None)
def flush(self):
pass
def isatty(self):
return True
sys.stderr = sys.stdout = AnsiTerm()
os.environ['TERM'] = 'vt100'

25
tools/wafadmin/py3kfixes.py

@ -12,10 +12,14 @@ all_modifs = {}
def modif(dir, name, fun): def modif(dir, name, fun):
if name == '*': if name == '*':
lst = os.listdir(dir) + ['Tools' + os.sep + x for x in os.listdir(os.path.join(dir, 'Tools'))] lst = []
for y in '. Tools 3rdparty'.split():
for x in os.listdir(os.path.join(dir, y)):
if x.endswith('.py'):
lst.append(y + os.sep + x)
#lst = [y + os.sep + x for x in os.listdir(os.path.join(dir, y)) for y in '. Tools 3rdparty'.split() if x.endswith('.py')]
for x in lst: for x in lst:
if x.endswith('.py'): modif(dir, x, fun)
modif(dir, x, fun)
return return
filename = os.path.join(dir, name) filename = os.path.join(dir, name)
@ -48,12 +52,13 @@ def r1(code):
@subst('Tools/ccroot.py') @subst('Tools/ccroot.py')
def r2(code): def r2(code):
code = code.replace("p.stdin.write('\\n')", "p.stdin.write(b'\\n')") code = code.replace("p.stdin.write('\\n')", "p.stdin.write(b'\\n')")
code = code.replace("out=str(out)", "out=out.decode('utf-8')") code = code.replace('p.communicate()[0]', 'p.communicate()[0].decode("utf-8")')
return code return code
@subst('Utils.py') @subst('Utils.py')
def r3(code): def r3(code):
code = code.replace("m.update(str(lst))", "m.update(str(lst).encode())") code = code.replace("m.update(str(lst))", "m.update(str(lst).encode())")
code = code.replace('p.communicate()[0]', 'p.communicate()[0].decode("utf-8")')
return code return code
@subst('Task.py') @subst('Task.py')
@ -87,9 +92,21 @@ def r7(code):
code = code.replace('class task_gen(object):\n\t__metaclass__=register_obj', 'class task_gen(object, metaclass=register_obj):') code = code.replace('class task_gen(object):\n\t__metaclass__=register_obj', 'class task_gen(object, metaclass=register_obj):')
return code return code
@subst('Tools/config_c.py')
def r8(code):
code = code.replace('p.communicate()[0]', 'p.communicate()[0].decode("utf-8")')
return code
@subst('Tools/glib2.py')
def r9(code):
code = code.replace('f.write(c)', 'f.write(c.encode("utf-8"))')
return code
def fixdir(dir): def fixdir(dir):
global all_modifs global all_modifs
for k in all_modifs: for k in all_modifs:
for v in all_modifs[k]: for v in all_modifs[k]:
modif(os.path.join(dir, 'wafadmin'), k, v) modif(os.path.join(dir, 'wafadmin'), k, v)
#print('substitutions finished') #print('substitutions finished')

Loading…
Cancel
Save