Skip to content

Commit

Permalink
Upgrade Waf to 1.5.16
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Apr 18, 2010
1 parent fa514a9 commit 6e715b8
Show file tree
Hide file tree
Showing 25 changed files with 749 additions and 75 deletions.
2 changes: 1 addition & 1 deletion bin/node-waf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ t = join(w, 'Tools')
sys.path = [w, t] + sys.path

import Scripting
VERSION="1.5.15"
VERSION="1.5.16"
Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
sys.exit(0)
24 changes: 14 additions & 10 deletions tools/waf-light
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if 'PSYCOWAF' in os.environ:
try:import psyco;psyco.full()
except:pass

VERSION="1.5.15"
VERSION="1.5.16"
REVISION="x"
INSTALL="x"
C1='x'
Expand Down Expand Up @@ -82,26 +82,30 @@ def unpack_wafdir(dir):
err("Cannot unpack waf lib into %s\nMove waf into a writeable directory" % dir)

os.chdir(dir)
tmp = 't.tbz2'
tmp = 't.bz2'
t = open(tmp,'wb')
t.write(txt)
t.close()

t = None
try:
t = tarfile.open(tmp)
for x in t: t.extract(x)
t.close()
except:
os.chdir(cwd)
try: shutil.rmtree(dir)
except OSError: pass
err("Waf cannot be unpacked, check that bzip2 support is present")
try:
os.system('bunzip2 t.bz2')
t = tarfile.open('t')
except:
os.chdir(cwd)
try: shutil.rmtree(dir)
except OSError: pass
err("Waf cannot be unpacked, check that bzip2 support is present")

for x in t: t.extract(x)
t.close()

for x in ['Tools', '3rdparty']:
os.chmod(join('wafadmin',x), 493)

os.unlink(tmp)

if sys.hexversion>0x300000f:
sys.path = [join(dir, 'wafadmin')] + sys.path
import py3kfixes
Expand Down
128 changes: 128 additions & 0 deletions tools/wafadmin/3rdparty/gccdeps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/usr/bin/env python
# encoding: utf-8
# Thomas Nagy, 2008-2010 (ita)

"""
Execute the tasks with gcc -MD, read the dependencies from the .d file
and prepare the dependency calculation for the next run
"""

import os, re, threading
import Task, Logs, Utils, preproc
from TaskGen import before, after, feature

lock = threading.Lock()

preprocessor_flag = '-MD'

@feature('cc')
@before('apply_core')
def add_mmd_cc(self):
if self.env.get_flat('CCFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CCFLAGS', preprocessor_flag)

@feature('cxx')
@before('apply_core')
def add_mmd_cxx(self):
if self.env.get_flat('CXXFLAGS').find(preprocessor_flag) < 0:
self.env.append_value('CXXFLAGS', preprocessor_flag)

def scan(self):
"the scanner does not do anything initially"
nodes = self.generator.bld.node_deps.get(self.unique_id(), [])
names = []
return (nodes, names)

re_o = re.compile("\.o$")
re_src = re.compile("^(\.\.)[\\/](.*)$")

def post_run(self):
# The following code is executed by threads, it is not safe, so a lock is needed...

if getattr(self, 'cached', None):
return Task.Task.post_run(self)

name = self.outputs[0].abspath(self.env)
name = re_o.sub('.d', name)
txt = Utils.readf(name)
#os.unlink(name)

txt = txt.replace('\\\n', '')

lst = txt.strip().split(':')
val = ":".join(lst[1:])
val = val.split()

nodes = []
bld = self.generator.bld

f = re.compile("^("+self.env.variant()+"|\.\.)[\\/](.*)$")
for x in val:
if os.path.isabs(x):

if not preproc.go_absolute:
continue

lock.acquire()
try:
node = bld.root.find_resource(x)
finally:
lock.release()
else:
g = re.search(re_src, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.bldnode.parent.find_resource(x)
finally:
lock.release()
else:
g = re.search(f, x)
if g:
x = g.group(2)
lock.acquire()
try:
node = bld.srcnode.find_resource(x)
finally:
lock.release()

if id(node) == id(self.inputs[0]):
# ignore the source file, it is already in the dependencies
# this way, successful config tests may be retrieved from the cache
continue

if not node:
raise ValueError('could not find %r for %r' % (x, self))
else:
nodes.append(node)

Logs.debug('deps: real scanner for %s returned %s' % (str(self), str(nodes)))

bld.node_deps[self.unique_id()] = nodes
bld.raw_deps[self.unique_id()] = []

try:
del self.cache_sig
except:
pass

Task.Task.post_run(self)

import Constants, Utils
def sig_implicit_deps(self):
try:
return Task.Task.sig_implicit_deps(self)
except Utils.WafError:
return Constants.SIG_NIL

for name in 'cc cxx'.split():
try:
cls = Task.TaskBase.classes[name]
except KeyError:
pass
else:
cls.post_run = post_run
cls.scan = scan
cls.sig_implicit_deps = sig_implicit_deps

97 changes: 97 additions & 0 deletions tools/wafadmin/3rdparty/go.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python
# encoding: utf-8
# go.py - Waf tool for the Go programming language
# By: Tom Wambold <tom5760@gmail.com>

import platform

import Task
import Utils
from TaskGen import feature, extension, after

Task.simple_task_type('gocompile', '${GOC} ${GOCFLAGS} -o ${TGT} ${SRC}', shell=False)
Task.simple_task_type('gopack', '${GOP} grc ${TGT} ${SRC}', shell=False)
Task.simple_task_type('golink', '${GOL} ${GOLFLAGS} -o ${TGT} ${SRC}', shell=False)

def detect(conf):

def set_def(var, val):
if not conf.env[var]:
conf.env[var] = val

set_def('GO_PLATFORM', platform.machine())

if conf.env.GO_PLATFORM == 'x86_64':
set_def('GO_COMPILER', '6g')
set_def('GO_LINKER', '6l')
set_def('GO_EXTENSION', '.6')
elif conf.env.GO_PLATFORM == 'i386':
set_def('GO_COMPILER', '8g')
set_def('GO_LINKER', '8l')
set_def('GO_EXTENSION', '.8')

if not (conf.env.GO_COMPILER or conf.env.GO_LINKER or conf.env.GO_EXTENSION):
raise conf.fatal('Unsupported platform ' + platform.machine())

set_def('GO_PACK', 'gopack')
set_def('GO_PACK_EXTENSION', '.a')

conf.find_program(conf.env.GO_COMPILER, var='GOC', mandatory=True)
conf.find_program(conf.env.GO_LINKER, var='GOL', mandatory=True)
conf.find_program(conf.env.GO_PACK, var='GOP', mandatory=True)

@extension('.go')
def compile_go(self, node):
try:
self.go_nodes.append(node)
except AttributeError:
self.go_nodes = [node]

@feature('go')
@after('apply_core')
def apply_compile_go(self):
try:
nodes = self.go_nodes
except AttributeError:
self.go_compile_task = None
else:
self.go_compile_task = self.create_task('gocompile',
nodes,
[self.path.find_or_declare(self.target + self.env.GO_EXTENSION)])

@feature('gopackage', 'goprogram')
@after('apply_compile_go')
def apply_goinc(self):
if not getattr(self, 'go_compile_task', None):
return

names = self.to_list(getattr(self, 'uselib_local', []))
for name in names:
obj = self.name_to_obj(name)
if not obj:
raise Utils.WafError('object %r was not found in uselib_local '
'(required by %r)' % (lib_name, self.name))
obj.post()
self.go_compile_task.set_run_after(obj.go_package_task)
self.go_compile_task.deps_nodes.extend(obj.go_package_task.outputs)
self.env.append_unique('GOCFLAGS', '-I' + obj.path.abspath(obj.env))
self.env.append_unique('GOLFLAGS', '-L' + obj.path.abspath(obj.env))

@feature('gopackage')
@after('apply_goinc')
def apply_gopackage(self):
self.go_package_task = self.create_task('gopack',
self.go_compile_task.outputs[0],
self.path.find_or_declare(self.target + self.env.GO_PACK_EXTENSION))
self.go_package_task.set_run_after(self.go_compile_task)
self.go_package_task.deps_nodes.extend(self.go_compile_task.outputs)

@feature('goprogram')
@after('apply_goinc')
def apply_golink(self):
self.go_link_task = self.create_task('golink',
self.go_compile_task.outputs[0],
self.path.find_or_declare(self.target))
self.go_link_task.set_run_after(self.go_compile_task)
self.go_link_task.deps_nodes.extend(self.go_compile_task.outputs)

Loading

0 comments on commit 6e715b8

Please sign in to comment.