forked from keyianpai/hft
-
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
1 parent
8e9a82b
commit 6b51460
Showing
6 changed files
with
428 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local_rpath: | ||
wget http://waf.googlecode.com/git-history/8dc822fded66db8041a0b71f3c7e451f6d07aa43/waflib/extras/local_rpath.py | ||
|
||
unittest_gtest: | ||
wget http://github.com/tanakh/waf-unittest/raw/master/unittest_gtest.py |
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,39 @@ | ||
#! /usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
def options(opt): | ||
opt.add_option('-d', '--debug-level', | ||
action = 'store', | ||
default = 'release', | ||
help = 'Specify the debugging level [debug, release]', | ||
choices = [ 'debug', 'release' ], | ||
dest = 'debug_level') | ||
|
||
opt.load('compiler_cxx unittest_gtest lint') | ||
|
||
def configure(conf): | ||
conf.load('compiler_cxx local_rpath unittest_gtest lint') | ||
|
||
conf.env.CXXFLAGS = [ | ||
'-Werror', | ||
'-Wall', | ||
'-Woverloaded-virtual', | ||
'-Wextra', | ||
'-Wfloat-equal', | ||
'-Wno-unused-parameter', | ||
'-Wno-unused-function' ] | ||
|
||
if conf.options.debug_level == 'release': | ||
conf.env.CXXFLAGS += [ '-O2' ] | ||
else: | ||
conf.env.CXXFLAGS += [ '-g' ] | ||
conf.env.DEFINES += [ 'DEBUG' ] | ||
|
||
####################################### | ||
# Tag to disable program installation | ||
####################################### | ||
from waflib.TaskGen import before, feature | ||
@feature('noinst') | ||
@before('apply_link') | ||
def no_inst(self): | ||
self.install_path = None |
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,85 @@ | ||
#! /usr/bin/env python | ||
# encoding: utf-8 | ||
|
||
import os | ||
|
||
def configure(conf): | ||
conf.find_program('cpplint.py', var='LINT', path_list=[os.path.dirname(Context.waf_dir)]) | ||
|
||
######################################### | ||
# Lint | ||
######################################### | ||
from waflib.TaskGen import before, feature, after_method | ||
from waflib import Task, Context | ||
|
||
lint_ignore_patterns = set(['unittest-gtest']) | ||
def add_lint_ignore(pattern): | ||
lint_ignore_patterns.add(pattern) | ||
|
||
def lint_should_ignore(path): | ||
for pattern in lint_ignore_patterns: | ||
if pattern in path: | ||
return True | ||
return False | ||
|
||
files_linted = set() | ||
|
||
@feature('cxx') | ||
@after_method('process_source') | ||
def add_files_to_lint(self): | ||
if self.target != 'testprog': | ||
for task in self.compiled_tasks: | ||
if not task.inputs[0] in files_linted: | ||
files_linted.add(task.inputs[0]) | ||
lint = self.create_task('lint', task.inputs[0]) | ||
lint.source_task = task | ||
lint.lint_done = False | ||
|
||
to_lint = set() | ||
|
||
class lint(Task.Task): | ||
after = [ 'cxx' ] | ||
|
||
def __init__(self, *k, **kw): | ||
Task.Task.__init__(self, *k, **kw) | ||
self.lint_done = True | ||
|
||
def runnable_status(self): | ||
if not self.lint_done: | ||
for t in self.run_after: | ||
if not t.hasrun: | ||
return Task.ASK_LATER; | ||
self.add_lint_tasks() | ||
|
||
return Task.Task.runnable_status(self) | ||
|
||
def add_lint_tasks(self): | ||
bld = self.generator.bld | ||
deps = bld.node_deps.get(self.source_task.uid()) | ||
for dep in deps: | ||
if not dep in to_lint and not lint_should_ignore(dep.abspath()): | ||
to_lint.add(dep) | ||
|
||
task = Task.classes['lint'](env=self.env, generator=self.generator) | ||
task.set_inputs(dep) | ||
|
||
gen = bld.producer | ||
gen.outstanding.insert(0, task) | ||
gen.total += 1 | ||
|
||
self.lint_done = True | ||
|
||
def run(self): | ||
bld = self.generator.bld; | ||
path = self.inputs[0].path_from(self.generator.bld.bldnode) | ||
if lint_should_ignore(path): | ||
return 0 | ||
|
||
# Execute lint | ||
cmd = '%s %s' % (self.env['LINT'], path) | ||
try: | ||
bld.cmd_and_log(cmd, quiet=Context.BOTH, cwd=bld.variant_dir) | ||
except Exception, e: | ||
print(e.stderr) | ||
return 1 | ||
return 0 |
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,20 @@ | ||
#! /usr/bin/env python | ||
# encoding: utf-8 | ||
# Thomas Nagy, 2011 (ita) | ||
|
||
from waflib.TaskGen import after_method, feature | ||
|
||
@after_method('propagate_uselib_vars') | ||
@feature('cprogram', 'cshlib', 'cxxprogram', 'cxxshlib', 'fcprogram', 'fcshlib') | ||
def add_rpath_stuff(self): | ||
all = self.to_list(getattr(self, 'use', [])) | ||
while all: | ||
name = all.pop() | ||
try: | ||
tg = self.bld.get_tgen_by_name(name) | ||
except: | ||
continue | ||
|
||
if hasattr(tg, 'link_task'): | ||
self.env.append_value('RPATH', tg.link_task.outputs[0].parent.abspath()) | ||
all.extend(self.to_list(getattr(tg, 'use', []))) |
Oops, something went wrong.