From 61e5a6aab4808f04a473de863f5a902dab216b93 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 10 Dec 2007 06:24:02 -0200 Subject: Add a tool for checking codingstyle and report to emacs "Compile" command From: Mauro Carvalho Chehab For those who develp using emacs, checking a patch is now a matter of asking emacs to compile, using "make checkemacs" command. Signed-off-by: Mauro Carvalho Chehab --- INSTALL | 2 ++ v4l/Makefile | 5 +++++ v4l/scripts/check.pl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100755 v4l/scripts/check.pl diff --git a/INSTALL b/INSTALL index 0a0647bb5..5812774d9 100644 --- a/INSTALL +++ b/INSTALL @@ -106,3 +106,5 @@ update - updates the tree from master repository commit - commits the change, asking for a commit msg push - sends outgoing stuff to master repository + +checkemacs - checks codingstyle and reports to emacs diff --git a/v4l/Makefile b/v4l/Makefile index 75e9c50ef..f78842c70 100644 --- a/v4l/Makefile +++ b/v4l/Makefile @@ -394,6 +394,11 @@ commit cvscommit hgcommit:: push:: make -C .. push +################################################# +# Consistency checks +checkemacs:: + scripts/check.pl + ################################################# # Help help:: diff --git a/v4l/scripts/check.pl b/v4l/scripts/check.pl new file mode 100755 index 000000000..3e6eb6e47 --- /dev/null +++ b/v4l/scripts/check.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +my $cmd=shift; + +if ($cmd) { + $cmd="diff -upr /dev/null $cmd"; +} else { + $cmd="hg diff"; +} + +$checkpatch=$ENV{CHECKPATCH}; + +if (!$checkpatch) { + $checkpatch="/lib/modules/`uname -r`/build/scripts/checkpatch.pl"; +} + +my $cp_version; +open IN,"$checkpatch|"; +while () { + tr/A-Z/a-z/; + if (m/version\s*:\s*([\d\.]+)/) { + $cp_version = $1; + } +} +close IN; + +my $intree_checkpatch = "scripts/checkpatch.pl --no-tree"; +if (!open IN,"$intree_checkpatch|") { + $intree_checkpatch = "v4l/".$intree_checkpatch; + open IN,"$intree_checkpatch|"; +} +while () { + tr/A-Z/a-z/; + if (m/version\s*:\s*([\d\.]+)/) { + if ($1 > $cp_version) { + print "# WARNING: $checkpatch version $cp_version is\n" + ."# older than $intree_checkpatch version" + ." $1.\n# Using in-tree one.\n#\n"; + $cp_version = $1; + $checkpatch = $intree_checkpatch; + } + } +} +close IN; + +open IN,"$cmd | $checkpatch -q --nosignoff --emacs -|"; +while () { + s|#[\d]+:\s*FILE:\s*|../|; + print "$_"; +} +close IN; -- cgit v1.2.3