Update git submodules
[LibreOffice.git] / bin / includebloat.awk
blob2ec182335bc0f2b138720c746931773e3ec87d20
1 #!/usr/bin/gawk -f
2 # -*- tab-width: 4; indent-tabs-mode: t -*-
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 # Generate a list of files included by the C++ compiler during the build
12 # sorted by the total bytes an included file contributed to preprocessor input.
13 # usage: first do a full build with "make check", then run this from $BUILDDIR
15 # NOTE: by default gbuild does not generate dependencies for system headers
16 # (in particular the C++ standard library), so those will NOT be counted
18 BEGIN {
19 cmd = "find workdir/Dep/CxxObject/ -name *.d | xargs cat"
20 while ((cmd | getline) > 0) {
21 if ($0 ~ /^ .*\\$/) {
22 gsub(/^ /, "");
23 gsub(/ *\\$/, "");
24 includes[$1]++
25 if ($2) {
26 # GCC emits 2 per line if short enough!
27 includes[$2]++
31 exit
34 END {
35 for (inc in includes) {
36 cmd = "wc -c " inc
37 if ((cmd | getline) < 0)
38 print "ERROR on: " cmd
39 sizes[inc] = $1 # $0 is wc -c output, $1 is size
40 totals[inc] = $1 * includes[inc]
41 totalsize += totals[inc]
42 close(cmd)
44 PROCINFO["sorted_in"] = "@val_num_desc"
45 printf "Sum total bytes included (excluding system headers): %'d\n", totalsize
46 print "Total bytes\tSize\t Occurrences\tFilename"
47 OFS="\t"
48 for (inc in totals) {
49 printf "%'13d\t%'7d\t%'8d\t%s\n", totals[inc], sizes[inc], includes[inc], inc
53 # vim: set noet sw=4 ts=4: