mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC] duplicate #include check for build system
@ 2006-02-21  1:48 Herbert Poetzl
  2006-02-21  6:10 ` Sam Ravnborg
  2006-02-21  7:29 ` Daniel Barkalow
  0 siblings, 2 replies; 11+ messages in thread
From: Herbert Poetzl @ 2006-02-21  1:48 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Linux Kernel ML


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-02-25  2:57 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-21  1:48 [RFC] duplicate #include check for build system Herbert Poetzl
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

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®