summaryrefslogtreecommitdiff
path: root/solenv/bin
diff options
context:
space:
mode:
authorPeter Foley <pefoley2@verizon.net>2012-12-15 17:35:28 -0500
committerLuboš Luňák <l.lunak@suse.cz>2012-12-17 17:10:30 +0000
commit34e79c19babc0e6cc281025b40635b91dca444f3 (patch)
tree73e2bd1ab4122cec69780da6ea83770a879048c1 /solenv/bin
parentf55f86e016e8d1b509be1e7ba59919301dc17d67 (diff)
add script to regenerate pch files
based on a script by Lubos Lunak (http://article.gmane.org/gmane.comp.documentfoundation.libreoffice.devel/40210) Change-Id: Ib32de8be8a57b3b430f4b5b298b7f417e5a02ccb Reviewed-on: https://gerrit.libreoffice.org/1350 Reviewed-by: Luboš Luňák <l.lunak@suse.cz> Tested-by: Luboš Luňák <l.lunak@suse.cz>
Diffstat (limited to 'solenv/bin')
-rwxr-xr-xsolenv/bin/update_pch.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/solenv/bin/update_pch.sh b/solenv/bin/update_pch.sh
new file mode 100755
index 000000000000..864d0df3bdcb
--- /dev/null
+++ b/solenv/bin/update_pch.sh
@@ -0,0 +1,92 @@
+#! /bin/bash
+#
+# 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/.
+#
+
+root=`dirname $0`
+root=`cd $root/../.. && pwd`
+
+if test -z $1; then
+headers=`ls $root/*/inc/pch/precompiled_*.hxx`
+else
+headers="$1"
+fi
+
+for x in $headers; do
+header=$x
+echo updating `echo $header | sed -e s%$root/%%`
+module=`echo $header | sed -e s%$root/%% -e s%/.*%%`
+name=`echo $header | sed -e s/.*precompiled_// -e s/\.hxx//`
+makefile="$root/$module/Library_$name.mk"
+
+tmpfile=`mktemp`
+
+cat "$makefile" | sed 's#\\$##' | \
+ (
+ inobjects=
+ while read line ; do
+ if (test "$line" = "))") || (echo $line | grep -q ", "); then
+ inobjects=
+ elif echo $line | grep -q -e add_exception_objects -e add_noexception_objects -e add_cxxobject -e add_cxxobjects ; then
+ inobjects=1
+ elif test -n "$inobjects"; then
+ file=$line
+ if ! test -f "$root/$file".cxx ; then
+ echo No file $file in makefile `echo $makefile | sed -e s%$root/%%` >&2
+ else
+ cat "$root/$file".cxx | grep -e '^\s*#include' | sed 's/\(#include [<"][^<"]*[>"]\).*/\1/' | sed 's#\.\./##g#' >>$tmpfile
+ fi
+ fi
+ done
+ )
+
+cat >$header <<EOF
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+EOF
+
+localdir="`dirname $makefile`"
+
+function local_file()
+(
+ file="$1"
+ find "$localdir" -type f | grep /"$file"'$' -q
+)
+
+function skip_ignore()
+(
+ grep -v -F -e '#include "gperffasttoken.hxx"'
+)
+
+# " in #include "foo" breaks echo down below, so " -> @
+cat $tmpfile | sort -u | skip_ignore | sed 's/"/@/g' | \
+ (
+ while read line; do
+ file=`echo $line | sed 's/.*[<"@]\(.*\)[>"@].*/\1/'`
+ if ! local_file "$file"; then
+ echo $line | sed 's/@/"/g' >>$header
+ fi
+ done
+ )
+
+cat >>$header <<EOF
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+EOF
+
+
+rm $tmpfile
+done
+#echo Done.
+exit 0