aboutsummaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-09-27 18:09:29 +0200
committerDavid Robillard <d@drobilla.net>2020-09-27 18:09:29 +0200
commit4d4222c583f6169159bb9d02868488ea03569aad (patch)
tree9aa51b68af4c859f61e38251f017473aca5c29bc /wscript
parent7550f8ed8eb0a48ae677c944d4d36923f2e73022 (diff)
downloadlv2-4d4222c583f6169159bb9d02868488ea03569aad.tar.xz
Strengthen lint target
Diffstat (limited to 'wscript')
-rw-r--r--wscript63
1 files changed, 50 insertions, 13 deletions
diff --git a/wscript b/wscript
index 58e6d2f..081f031 100644
--- a/wscript
+++ b/wscript
@@ -4,7 +4,7 @@ import os
import re
import sys
-from waflib import Context, Logs, Options, Scripting, Utils
+from waflib import Build, Context, Logs, Options, Scripting, Utils
from waflib.extras import autowaf as autowaf
# Mandatory waf variables
@@ -83,6 +83,12 @@ def configure(conf):
conf.load('autowaf', cache=True)
autowaf.set_c_lang(conf, 'c99')
+ if Options.options.strict:
+ # Check for programs used by lint target
+ conf.find_program("flake8", var="FLAKE8", mandatory=False)
+ conf.find_program("clang-tidy", var="CLANG_TIDY", mandatory=False)
+ conf.find_program("iwyu_tool", var="IWYU_TOOL", mandatory=False)
+
if Options.options.ultra_strict:
autowaf.add_compiler_flags(conf.env, 'c', {
'gcc': [
@@ -534,22 +540,53 @@ def build(bld):
bld.recurse('plugins')
+class LintContext(Build.BuildContext):
+ fun = cmd = 'lint'
+
+
def lint(ctx):
"checks code for style issues"
import subprocess
+ import glob
+
+ st = 0
+
+ if "FLAKE8" in ctx.env:
+ Logs.info("Running flake8")
+ st = subprocess.call([ctx.env.FLAKE8[0],
+ "wscript",
+ "--ignore",
+ "E101,E129,W191,E221,W504,E251,E241,E741"])
+ else:
+ Logs.warn("Not running flake8")
+
+ if "IWYU_TOOL" in ctx.env:
+ Logs.info("Running include-what-you-use")
+ cmd = [ctx.env.IWYU_TOOL[0], "-o", "clang", "-p", "build"]
+ output = subprocess.check_output(cmd).decode('utf-8')
+ if 'error: ' in output:
+ sys.stdout.write(output)
+ st += 1
+ else:
+ Logs.warn("Not running include-what-you-use")
+
+ if "CLANG_TIDY" in ctx.env and "clang" in ctx.env.CC[0]:
+ Logs.info("Running clang-tidy")
+ sources = glob.glob('**/*.h', recursive=True)
+ sources = list(map(os.path.abspath, sources))
+ procs = []
+ for source in sources:
+ cmd = [ctx.env.CLANG_TIDY[0], "--quiet", "-p=.", source]
+ procs += [subprocess.Popen(cmd, cwd="build")]
+
+ for proc in procs:
+ stdout, stderr = proc.communicate()
+ st += proc.returncode
+ else:
+ Logs.warn("Not running clang-tidy")
- subprocess.call("flake8 --ignore E101,E129,W191,E221,W504,E251,E241,E741 "
- "wscript lv2specgen/lv2docgen.py lv2specgen/lv2specgen.py "
- "plugins/literasc.py",
- shell=True)
-
- cmd = ("clang-tidy -p=. -header-filter=.* -checks=\"*," +
- "-hicpp-signed-bitwise," +
- "-llvm-header-guard," +
- "-misc-unused-parameters," +
- "-readability-else-after-return\" " +
- "build-test.c")
- subprocess.call(cmd, cwd='build', shell=True)
+ if st != 0:
+ sys.exit(st)
def test_vocabularies(check, specs, files):