summaryrefslogtreecommitdiffstats
path: root/bin/includebloat.awk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /bin/includebloat.awk
parentInitial commit. (diff)
downloadlibreoffice-upstream.tar.xz
libreoffice-upstream.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-xbin/includebloat.awk51
1 files changed, 51 insertions, 0 deletions
diff --git a/bin/includebloat.awk b/bin/includebloat.awk
new file mode 100755
index 000000000..3792ef950
--- /dev/null
+++ b/bin/includebloat.awk
@@ -0,0 +1,51 @@
+#!/usr/bin/gawk -f
+# -*- tab-width: 4; indent-tabs-mode: t -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+# Generate a list of files included by the C++ compiler during the build
+# sorted by the total bytes an included file contributed to preprocessor input.
+# usage: first do a full build with "make check", then run this from $BUILDDIR
+
+# NOTE: by default gbuild does not generate dependencies for system headers
+# (in particular the C++ standard library), so those will NOT be counted
+
+BEGIN {
+ cmd = "find workdir/Dep/CxxObject/ -name *.d | xargs cat"
+ while ((cmd | getline) > 0) {
+ if ($0 ~ /^ .*\\$/) {
+ gsub(/^ /, "");
+ gsub(/ *\\$/, "");
+ includes[$1]++
+ if ($2) {
+ # GCC emits 2 per line if short enough!
+ includes[$2]++
+ }
+ }
+ }
+ exit
+}
+
+END {
+ for (inc in includes) {
+ cmd = "wc -c " inc
+ if ((cmd | getline) < 0)
+ print "ERROR on: " cmd
+ sizes[inc] = $1 # $0 is wc -c output, $1 is size
+ totals[inc] = $1 * includes[inc]
+ totalsize += totals[inc]
+ close(cmd)
+ }
+ PROCINFO["sorted_in"] = "@val_num_desc"
+ print "sum total bytes included (excluding system headers): " totalsize
+ for (inc in totals) {
+ print totals[inc], sizes[inc], includes[inc], inc
+ }
+}
+
+# vim: set noet sw=4 ts=4: