c++ - Adding linting to autotools-based build system -


i want add cpplint.py (https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py) autotools-based project. 1 know right way this?

let's assume want run linter on .cpp source files part of make. let's assume linter in path , not distributing copy of part of package.

first of check make sure have linter available in configure.ac:

ac_path_prog([cpplint], [cpplint.py], [true]) as_if([test "x$cpplint" = xtrue],     [ac_msg_warn([we recommend cpplint.py developing package. https://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py , put in path, or point cpplint environment variable @ it.])]) 

see below explanation of true in case not mean boolean true value. if want make linter absolute requirement, use ac_msg_error instead.

the best way make run write makefile code , hook automake's all-local target. if linter not available, nicely call true command nothing.

lint: $(myprogram_sources)     -$(cpplint) $^  all-local: lint  .phony: lint 

this assumes source files linted stored in variable myprogram_sources. depending on setup have them in different variable, or more one.

if used stamp file instead of phony target, lint changed files, using $? instead of $^.

the - @ beginning of recipe tells make ignore errors rule. important, because otherwise if have 1 linting error build fail! annoying because people write , test rough code first, , clean later. on other hand, solution lets people ignore linting errors entirely.

for reason, recommend moving linting make check. way, people can develop whichever way want to, compiling make, can require new code pass make check. this, remove - in front of $(cpplint) , change all-local check-local.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -