Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / bin / includebloat.awk
blob3792ef95072172e9bad3a6b1faff609dda17229f
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 print "sum total bytes included (excluding system headers): " totalsize
46 for (inc in totals) {
47 print totals[inc], sizes[inc], includes[inc], inc
51 # vim: set noet sw=4 ts=4: