mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Poetzl <herbert@13thfloor.at>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Linux Kernel ML <linux-kernel@vger.kernel.org>
Subject: [RFC] duplicate #include check for build system
Date: Tue, 21 Feb 2006 02:48:24 +0100	[thread overview]
Message-ID: <20060221014824.GA19998@MAIL.13thfloor.at> (raw)


Hi Sam! Folks!

recently had the idea to utilize cpp or sparse to
do some automated #include checking, and I came up
with the following proof of concept:

I just replaced the sparse binary by the following
script (basically hijacking the make C=1 system)

it would allow kernel developers to easily identify
duplicate includes, which in turn, might reduce
dependancies and thus build time ...


----------------
#!/bin/bash

while [ $# -gt 1 ]; do
  case $1 in
        -D*) DEF="$DEF $1";;
        -W*) ;;
          *) OPT="$OPT $1";;
  esac
  shift
done

# ( $CPP $DEF -H -dI $OPT $1 1>&2 ) 2>&1 | grep "^[#.]"
$CPP $DEF -H  $OPT $1 2>&1 >/dev/null | gawk -vFILE="$1" '

BEGIN	{ I[0]=FILE; }

/^[.]+/ { D=length($1);

	  for (i=0; i<D; i++)
    	    C[i,$2]++; 
	    
	  I[D]=$2;

	  for (i=0; i<D; i++)
	    M[i,$2]=I[i];

	  if (C[D-1,$2]>1) {
	    printf "··· %s in %s ",$2,I[D-1];

	    for (i=D; M[i,$2]; i++) 
	      printf "%c%s", (i==D)?"[":"·", M[i,$2];

	    printf (i>D) ? "]\n" :
	    	((X[D,$2]==I[D-1]) ? "(dup)\n" : "\n");
	  }

          X[D,$2]=I[D-1];
        }
' 1>&2

true
----------------

of course, most of it would not be required if
there was support in the kernel build system,
and, if there is any preference for perl over
bash/gawk it could be easily rewritten ...

please let me know what you think of this and if
you could imagine adding something similar to the
build system 

TIA,
Herbert


             reply	other threads:[~2006-02-21  1:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-21  1:48 Herbert Poetzl [this message]
2006-02-21  6:10 ` Sam Ravnborg
2006-02-21  7:29 ` Daniel Barkalow
2006-02-21 17:52   ` Sam Ravnborg
2006-02-22  0:11     ` Herbert Poetzl
2006-02-22  0:18       ` Randy.Dunlap
2006-02-22  0:26         ` Herbert Poetzl
2006-02-22  0:28           ` Randy.Dunlap
2006-02-22  5:57       ` Sam Ravnborg
2006-02-24  7:23     ` Jan Engelhardt
2006-02-25  2:59       ` Randy.Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060221014824.GA19998@MAIL.13thfloor.at \
    --to=herbert@13thfloor.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®