From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asy6L-0002kr-Tf for qemu-devel@nongnu.org; Wed, 20 Apr 2016 15:47:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1asy6I-0005f7-NW for qemu-devel@nongnu.org; Wed, 20 Apr 2016 15:47:53 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:37310) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1asy6I-0005el-6r for qemu-devel@nongnu.org; Wed, 20 Apr 2016 15:47:50 -0400 Received: by mail-wm0-x22d.google.com with SMTP id n3so99045633wmn.0 for ; Wed, 20 Apr 2016 12:47:50 -0700 (PDT) References: <1460147350-7601-1-git-send-email-pbonzini@redhat.com> <1460147350-7601-2-git-send-email-pbonzini@redhat.com> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1460147350-7601-2-git-send-email-pbonzini@redhat.com> Date: Wed, 20 Apr 2016 20:47:47 +0100 Message-ID: <87bn54uknw.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH 01/50] scripts: add script to build QEMU and analyze inclusions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org Paolo Bonzini writes: > Signed-off-by: Paolo Bonzini > --- > scripts/analyze-inclusions | 89 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 89 insertions(+) > create mode 100644 scripts/analyze-inclusions > > diff --git a/scripts/analyze-inclusions b/scripts/analyze-inclusions .sh extension to make it clear what it is? > new file mode 100644 OK the script directory is inconsistent but if we want to use it for automated testing it should be executable in the checkout. > index 0000000..e241bd4 > --- /dev/null > +++ b/scripts/analyze-inclusions > @@ -0,0 +1,89 @@ > +#! /bin/sh > +# > +# Copyright (C) 2016 Red Hat, Inc. > +# > +# Author: Paolo Bonzini > +# > +# Print statistics about header file inclusions. > +# The script configures and builds QEMU itself in a "+build" > +# subdirectory which is left around when the script exits. > +# To run the statistics on a pre-existing "+build" directory, > +# pass "--no-build" as the first argument on the command line. > +# Any other command line is passed directly to "make" (so > +# you can for example pass a "-j" argument suitable for your > +# system). > +# > +# Inspired by a post by Markus Armbruster. > + > +mkdir -p +build > +cd +build > +if test "x$1" != "x--no-build"; then > + test -f Makefile && make distclean > + ../configure > + make "$@" > +fi > + > +QEMU_CFLAGS=$(sed -n s/^QEMU_CFLAGS=//p config-host.mak) > +QEMU_INCLUDES=$(sed -n s/^QEMU_INCLUDES=//p config-host.mak | \ > + sed 's/$(SRC_PATH)/../g' ) > +CFLAGS=$(sed -n s/^CFLAGS=//p config-host.mak) > + > +grep_include() { > + find . -name "*.d" | xargs grep -l "$@" | wc -l > +} > + > +echo Found $(find . -name "*.d" | wc -l) object files > +echo $(grep_include -F 'include/qemu-common.h') files include qemu-common.h > +echo $(grep_include -F 'hw/hw.h') files include hw/hw.h > +echo $(grep_include 'target-[a-z0-9]*/cpu\.h') files include cpu.h > +echo $(grep_include -F 'qapi-types.h') files include qapi-types.h > +echo $(grep_include -F 'trace/generated-tracers.h') files include generated-tracers.h > +echo $(grep_include -F 'qapi/error.h') files include qapi/error.h > +echo $(grep_include -F 'qom/object.h') files include qom/object.h > +echo $(grep_include -F 'block/aio.h') files include block/aio.h > +echo $(grep_include -F 'exec/memory.h') files include exec/memory.h > +echo $(grep_include -F 'fpu/softfloat.h') files include fpu/softfloat.h > +echo $(grep_include -F 'qemu/bswap.h') files include qemu/bswap.h > +echo > + > +awk1=' > + /^# / { file = $3;next } > + NR>1 { bytes[file]+=length; lines[file]++ } > + END { for(i in lines) print i,lines[i],bytes[i] }' > + > +awk2=' > + {tot_l+=$2;tot_b+=$3;tot_f++} > + /\/usr.*\/glib/ {glib_l+=$2;glib_b+=$3;glib_f++;next} > + /\/usr/ {sys_l+=$2;sys_b+=$3;sys_f++;next} > + {qemu_l+=$2;qemu_b+=$3;qemu_f++;next} > + END { > + printf "%s\t %s\t %s\t %s\n", "lines", "bytes", "files", "source" > + printf "%s\t %s\t %s\t %s\n", qemu_l, qemu_b, qemu_f, "QEMU" > + printf "%s\t %s\t %s\t %s\n", sys_l, sys_b, sys_f, "system" > + printf "%s\t %s\t %s\t %s\n", glib_l, glib_b, glib_f, "glib" > + printf "%s\t %s\t %s\t %s\n", tot_l, tot_b, tot_f, "total" > + }' > + > +analyze() { > + cc $QEMU_CFLAGS $QEMU_INCLUDES $CFLAGS -E -o - "$@" | \ > + awk "$awk1" | awk "$awk2" > + echo > +} > + > +echo osdep.h: > +analyze ../include/qemu/osdep.h > + > +echo qemu-common.h: > +analyze -include ../include/qemu/osdep.h ../include/qemu-common.h > + > +echo hw/hw.h: > +analyze -include ../include/qemu/osdep.h ../include/hw/hw.h > + > +echo trace/generated-tracers.h: > +analyze -include ../include/qemu/osdep.h trace/generated-tracers.h > + > +echo target-i386/cpu.h: > +analyze -DNEED_CPU_H -I../target-i386 -Ii386-softmmu -include ../include/qemu/osdep.h ../target-i386/cpu.h > + > +echo hw/hw.h + NEED_CPU_H: > +analyze -DNEED_CPU_H -I../target-i386 -Ii386-softmmu -include ../include/qemu/osdep.h ../include/hw/hw.h If we get to be include clean we want this script to have a non-zero exit for automated testing. -- Alex Bennée