Update Waf to 1.8.11
Changes: * run_c_code() is replaced by check() * nice_path() got removed, and is replaced by bldpath() * check_compilation_flag() is updated to work with 1.8 API
This commit is contained in:
14
src/wscript
14
src/wscript
@@ -335,7 +335,7 @@ class ns3pcfile_task(Task.Task):
|
||||
|
||||
def __str__(self):
|
||||
"string to display to the user"
|
||||
tgt_str = ' '.join([a.nice_path(self.env) for a in self.outputs])
|
||||
tgt_str = ' '.join([a.bldpath() for a in self.outputs])
|
||||
return 'pcfile: %s\n' % (tgt_str)
|
||||
|
||||
def runnable_status(self):
|
||||
@@ -473,8 +473,8 @@ class ns3header_task(Task.Task):
|
||||
def __str__(self):
|
||||
"string to display to the user"
|
||||
env = self.env
|
||||
src_str = ' '.join([a.nice_path(env) for a in self.inputs])
|
||||
tgt_str = ' '.join([a.nice_path(env) for a in self.outputs])
|
||||
src_str = ' '.join([a.bldpath() for a in self.inputs])
|
||||
tgt_str = ' '.join([a.bldpath() for a in self.outputs])
|
||||
if self.outputs: sep = ' -> '
|
||||
else: sep = ''
|
||||
if self.mode == 'remove':
|
||||
@@ -565,8 +565,8 @@ class ns3privateheader_task(Task.Task):
|
||||
def __str__(self):
|
||||
"string to display to the user"
|
||||
env = self.env
|
||||
src_str = ' '.join([a.nice_path(env) for a in self.inputs])
|
||||
tgt_str = ' '.join([a.nice_path(env) for a in self.outputs])
|
||||
src_str = ' '.join([a.bldpath() for a in self.inputs])
|
||||
tgt_str = ' '.join([a.bldpath() for a in self.outputs])
|
||||
if self.outputs: sep = ' -> '
|
||||
else: sep = ''
|
||||
if self.mode == 'remove':
|
||||
@@ -644,8 +644,8 @@ class gen_ns3_module_header_task(Task.Task):
|
||||
def __str__(self):
|
||||
"string to display to the user"
|
||||
env = self.env
|
||||
src_str = ' '.join([a.nice_path(env) for a in self.inputs])
|
||||
tgt_str = ' '.join([a.nice_path(env) for a in self.outputs])
|
||||
src_str = ' '.join([a.bldpath() for a in self.inputs])
|
||||
tgt_str = ' '.join([a.bldpath() for a in self.outputs])
|
||||
if self.outputs: sep = ' -> '
|
||||
else: sep = ''
|
||||
if self.mode == 'remove':
|
||||
|
||||
66
waf-tools/clang_compilation_database.py
Normal file
66
waf-tools/clang_compilation_database.py
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
# Christoph Koke, 2013
|
||||
|
||||
"""
|
||||
Writes the c and cpp compile commands into build/compile_commands.json
|
||||
see http://clang.llvm.org/docs/JSONCompilationDatabase.html
|
||||
|
||||
Usage:
|
||||
|
||||
def configure(conf):
|
||||
conf.load('compiler_cxx')
|
||||
...
|
||||
conf.load('clang_compilation_database')
|
||||
"""
|
||||
|
||||
import sys, os, json, shlex, pipes
|
||||
from waflib import Logs, TaskGen
|
||||
from waflib.Tools import c, cxx
|
||||
|
||||
if sys.hexversion >= 0x3030000:
|
||||
quote = shlex.quote
|
||||
else:
|
||||
quote = pipes.quote
|
||||
|
||||
@TaskGen.feature('*')
|
||||
@TaskGen.after_method('process_use')
|
||||
def collect_compilation_db_tasks(self):
|
||||
"Add a compilation database entry for compiled tasks"
|
||||
try:
|
||||
clang_db = self.bld.clang_compilation_database_tasks
|
||||
except AttributeError:
|
||||
clang_db = self.bld.clang_compilation_database_tasks = []
|
||||
self.bld.add_post_fun(write_compilation_database)
|
||||
|
||||
for task in getattr(self, 'compiled_tasks', []):
|
||||
if isinstance(task, (c.c, cxx.cxx)):
|
||||
clang_db.append(task)
|
||||
|
||||
def write_compilation_database(ctx):
|
||||
"Write the clang compilation database as JSON"
|
||||
database_file = ctx.bldnode.make_node('compile_commands.json')
|
||||
Logs.info("Build commands will be stored in %s" % database_file.path_from(ctx.path))
|
||||
try:
|
||||
root = json.load(database_file)
|
||||
except IOError:
|
||||
root = []
|
||||
clang_db = dict((x["file"], x) for x in root)
|
||||
for task in getattr(ctx, 'clang_compilation_database_tasks', []):
|
||||
try:
|
||||
cmd = task.last_cmd
|
||||
except AttributeError:
|
||||
continue
|
||||
directory = getattr(task, 'cwd', ctx.variant_dir)
|
||||
f_node = task.inputs[0]
|
||||
filename = os.path.relpath(f_node.abspath(), directory)
|
||||
cmd = " ".join(map(quote, cmd))
|
||||
entry = {
|
||||
"directory": directory,
|
||||
"command": cmd,
|
||||
"file": filename,
|
||||
}
|
||||
clang_db[filename] = entry
|
||||
root = list(clang_db.values())
|
||||
database_file.write(json.dumps(root, indent=2))
|
||||
|
||||
17
wscript
17
wscript
@@ -238,40 +238,39 @@ def _check_compilation_flag(conf, flag, mode='cxx', linkflags=None):
|
||||
conf.start_msg('Checking for compilation %s support' % (flag_str,))
|
||||
env = conf.env.derive()
|
||||
|
||||
retval = False
|
||||
if mode == 'cc':
|
||||
mode = 'c'
|
||||
|
||||
if mode == 'cxx':
|
||||
fname = 'test.cc'
|
||||
env.append_value('CXXFLAGS', flag)
|
||||
else:
|
||||
fname = 'test.c'
|
||||
env.append_value('CFLAGS', flag)
|
||||
|
||||
if linkflags is not None:
|
||||
env.append_value("LINKFLAGS", linkflags)
|
||||
|
||||
try:
|
||||
retval = conf.run_c_code(code='#include <stdio.h>\nint main() { return 0; }\n',
|
||||
env=env, compile_filename=fname,
|
||||
features=[mode, mode+'program'], execute=False)
|
||||
retval = conf.check(compiler=mode, fragment='int main() { return 0; }', features='c')
|
||||
except Errors.ConfigurationError:
|
||||
ok = False
|
||||
else:
|
||||
ok = (retval == 0)
|
||||
ok = (retval == True)
|
||||
conf.end_msg(ok)
|
||||
return ok
|
||||
|
||||
|
||||
|
||||
def report_optional_feature(conf, name, caption, was_enabled, reason_not_enabled):
|
||||
conf.env.append_value('NS3_OPTIONAL_FEATURES', [(name, caption, was_enabled, reason_not_enabled)])
|
||||
|
||||
|
||||
def check_optional_feature(conf, name):
|
||||
for (name1, caption, was_enabled, reason_not_enabled) in conf.env.NS3_OPTIONAL_FEATURES:
|
||||
if name1 == name:
|
||||
return was_enabled
|
||||
raise KeyError("Feature %r not declared yet" % (name,))
|
||||
|
||||
|
||||
# starting with waf 1.6, conf.check() becomes fatal by default if the
|
||||
# test fails, this alternative method makes the test non-fatal, as it
|
||||
# was in waf <= 1.5
|
||||
@@ -281,6 +280,7 @@ def _check_nonfatal(conf, *args, **kwargs):
|
||||
except conf.errors.ConfigurationError:
|
||||
return None
|
||||
|
||||
|
||||
def configure(conf):
|
||||
conf.load('relocation', tooldir=['waf-tools'])
|
||||
|
||||
@@ -292,12 +292,13 @@ def configure(conf):
|
||||
conf.env['NS3_OPTIONAL_FEATURES'] = []
|
||||
|
||||
conf.load('compiler_c')
|
||||
cc_string='.'.join(conf.env['CC_VERSION'])
|
||||
cc_string = '.'.join(conf.env['CC_VERSION'])
|
||||
conf.msg('Checking for cc version',cc_string,'GREEN')
|
||||
conf.load('compiler_cxx')
|
||||
conf.load('cflags', tooldir=['waf-tools'])
|
||||
conf.load('command', tooldir=['waf-tools'])
|
||||
conf.load('gnu_dirs')
|
||||
conf.load('clang_compilation_database', tooldir=['waf-tools'])
|
||||
|
||||
env = conf.env
|
||||
|
||||
|
||||
Reference in New Issue
Block a user