build: (fixes #119) Waf --lcov-report and --lcov-zerocounters options
This commit is contained in:
@@ -62,6 +62,7 @@ us a note on ns-developers mailing list.</p>
|
||||
</ul>
|
||||
<h2>Changes to build system:</h2>
|
||||
<ul>
|
||||
<li>The <b>--lcov-report</b> option to Waf was fixed, and a new <b>--lcov-zerocounters</b> option was added to improve support for lcov.</li>
|
||||
</ul>
|
||||
<h2>Changed behavior:</h2>
|
||||
<ul>
|
||||
|
||||
@@ -27,6 +27,7 @@ New user-visible features
|
||||
|
||||
Bugs fixed
|
||||
----------
|
||||
- Issue #119 - Waf --lcov-report option was broken
|
||||
- Issue #84 - Wi-Fi removing wrong header due to copy-paste error
|
||||
|
||||
Known issues
|
||||
|
||||
5648
utils/lcov/genhtml
5648
utils/lcov/genhtml
File diff suppressed because it is too large
Load Diff
3072
utils/lcov/geninfo
3072
utils/lcov/geninfo
File diff suppressed because it is too large
Load Diff
4175
utils/lcov/lcov
4175
utils/lcov/lcov
File diff suppressed because it is too large
Load Diff
49
wscript
49
wscript
@@ -162,10 +162,16 @@ def options(opt):
|
||||
|
||||
opt.add_option('--lcov-report',
|
||||
help=('Generate a code coverage report '
|
||||
'(use this option at build time, not in configure)'),
|
||||
'(use this option after configuring with --enable-gcov and running a program)'),
|
||||
action="store_true", default=False,
|
||||
dest='lcov_report')
|
||||
|
||||
opt.add_option('--lcov-zerocounters',
|
||||
help=('Zero the lcov counters'
|
||||
'(use this option before rerunning a program, when generating repeated lcov reports)'),
|
||||
action="store_true", default=False,
|
||||
dest='lcov_zerocounters')
|
||||
|
||||
opt.add_option('--run',
|
||||
help=('Run a locally built program; argument can be a program name,'
|
||||
' or a command starting with the program name.'),
|
||||
@@ -1133,6 +1139,9 @@ def shutdown(ctx):
|
||||
if Options.options.lcov_report:
|
||||
lcov_report(bld)
|
||||
|
||||
if Options.options.lcov_zerocounters:
|
||||
lcov_zerocounters(bld)
|
||||
|
||||
if Options.options.run:
|
||||
wutils.run_program(Options.options.run, env, wutils.get_command_template(env),
|
||||
visualize=Options.options.visualize)
|
||||
@@ -1313,7 +1322,20 @@ def lcov_report(bld):
|
||||
if not env['GCOV_ENABLED']:
|
||||
raise WafError("project not configured for code coverage;"
|
||||
" reconfigure with --enable-gcov")
|
||||
|
||||
try:
|
||||
subprocess.call(["lcov", "--help"], stdout=subprocess.DEVNULL)
|
||||
except OSError as e:
|
||||
if e.errno == os.errno.ENOENT:
|
||||
raise WafError("Error: lcov program not found")
|
||||
else:
|
||||
raise
|
||||
try:
|
||||
subprocess.call(["genhtml", "--help"], stdout=subprocess.DEVNULL)
|
||||
except OSError as e:
|
||||
if e.errno == os.errno.ENOENT:
|
||||
raise WafError("Error: genhtml program not found")
|
||||
else:
|
||||
raise
|
||||
os.chdir(out)
|
||||
try:
|
||||
lcov_report_dir = 'lcov-report'
|
||||
@@ -1324,15 +1346,34 @@ def lcov_report(bld):
|
||||
raise SystemExit(1)
|
||||
|
||||
info_file = os.path.join(lcov_report_dir, 'report.info')
|
||||
lcov_command = "../utils/lcov/lcov -c -d . -o " + info_file
|
||||
lcov_command = "lcov -c -d . -o " + info_file
|
||||
lcov_command += " -b " + os.getcwd()
|
||||
if subprocess.Popen(lcov_command, shell=True).wait():
|
||||
raise SystemExit(1)
|
||||
|
||||
genhtml_command = "../utils/lcov/genhtml -o " + lcov_report_dir
|
||||
genhtml_command = "genhtml -o " + lcov_report_dir
|
||||
genhtml_command += " " + info_file
|
||||
if subprocess.Popen(genhtml_command, shell=True).wait():
|
||||
raise SystemExit(1)
|
||||
finally:
|
||||
os.chdir("..")
|
||||
|
||||
def lcov_zerocounters(bld):
|
||||
env = bld.env
|
||||
|
||||
if not env['GCOV_ENABLED']:
|
||||
raise WafError("project not configured for code coverage;"
|
||||
" reconfigure with --enable-gcov")
|
||||
try:
|
||||
subprocess.call(["lcov", "--help"], stdout=subprocess.DEVNULL)
|
||||
except OSError as e:
|
||||
if e.errno == os.errno.ENOENT:
|
||||
raise WafError("Error: lcov program not found")
|
||||
else:
|
||||
raise
|
||||
|
||||
os.chdir(out)
|
||||
lcov_clear_command = "lcov -d . --zerocounters"
|
||||
if subprocess.Popen(lcov_clear_command, shell=True).wait():
|
||||
raise SystemExit(1)
|
||||
os.chdir("..")
|
||||
|
||||
Reference in New Issue
Block a user