forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
749 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
Oops, something went wrong.