2012-12-15 16:35:28 -06:00
|
|
|
#! /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/.
|
|
|
|
#
|
|
|
|
|
2013-03-12 11:22:32 -05:00
|
|
|
# Usage: update_pch.sh [precompiled_xxx.hxx]
|
|
|
|
|
2012-12-15 16:35:28 -06:00
|
|
|
root=`dirname $0`
|
2013-03-15 18:40:30 -05:00
|
|
|
root=`cd $root/.. && pwd`
|
2012-12-15 16:35:28 -06:00
|
|
|
|
2012-12-18 07:30:37 -06:00
|
|
|
if test -z "$1"; then
|
2012-12-18 09:46:40 -06:00
|
|
|
headers=`ls $root/*/inc/pch/precompiled_*.hxx`
|
2012-12-15 16:35:28 -06:00
|
|
|
else
|
2012-12-18 09:46:40 -06:00
|
|
|
headers="$1"
|
2012-12-15 16:35:28 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
for x in $headers; do
|
2012-12-18 09:46:40 -06:00
|
|
|
header=$x
|
|
|
|
echo updating `echo $header | sed -e s%$root/%%`
|
2013-03-12 11:22:32 -05:00
|
|
|
module=`readlink -f $header | sed -e s%$root/%% -e s%/.*%%`
|
2012-12-18 09:46:40 -06:00
|
|
|
name=`echo $header | sed -e s/.*precompiled_// -e s/\.hxx//`
|
|
|
|
makefile="Library_$name.mk"
|
2012-12-15 16:35:28 -06:00
|
|
|
|
2012-12-18 09:46:40 -06:00
|
|
|
tmpfile=`mktemp`
|
|
|
|
|
|
|
|
cat "$root/$module/$makefile" | sed 's#\\$##' | \
|
|
|
|
(
|
|
|
|
inobjects=
|
|
|
|
ifstack=0
|
|
|
|
while read line ; do
|
2012-12-18 09:53:31 -06:00
|
|
|
if test "$line" = "))" ; then
|
2012-12-18 09:46:40 -06:00
|
|
|
inobjects=
|
2013-07-17 06:28:18 -05:00
|
|
|
elif echo $line | grep -q -e add_exception_objects -e add_cxxobject -e add_cxxobjects ; then
|
2012-12-18 09:46:40 -06:00
|
|
|
inobjects=1
|
|
|
|
if test $ifstack -ne 0 ; then
|
|
|
|
echo Sources in a conditional, ignoring for now. >&2
|
|
|
|
fi
|
|
|
|
elif echo $line | grep -q ^if ; then
|
|
|
|
ifstack=$((ifstack + 1))
|
|
|
|
elif echo $line | grep -q ^endif ; then
|
|
|
|
ifstack=$((ifstack - 1))
|
|
|
|
elif test -n "$inobjects" -a $ifstack -eq 0; then
|
|
|
|
file=$line
|
2012-12-18 09:53:31 -06:00
|
|
|
if echo $line | grep -q ", "; then
|
|
|
|
true # $if() probably, or something similar
|
|
|
|
elif ! test -f "$root/$file".cxx ; then
|
2012-12-18 09:46:40 -06:00
|
|
|
echo No file $file in $module/$makefile >&2
|
|
|
|
else
|
2012-12-26 10:33:02 -06:00
|
|
|
|
|
|
|
function list_file_includes()
|
|
|
|
(
|
|
|
|
ifdepth=0
|
|
|
|
# filter out only preprocessor lines, get the first and second "words" after the #,
|
|
|
|
# also replace " with @ (would cause trouble when doing echo of the line)
|
|
|
|
cat "$1" | grep '^\s*#' | sed 's/^\s*#/#/' | sed 's/^\(#\w*\s+\w*\)\s+.*/\1/' | sed 's/"/@/g' | \
|
|
|
|
while read line; do
|
|
|
|
# skip everything surrounded by any #if
|
|
|
|
if echo "$line" | grep -q "#if" ; then
|
|
|
|
ifdepth=$((ifdepth + 1))
|
|
|
|
lastif="$line"
|
|
|
|
elif echo "$line" | grep -q "#endif" ; then
|
|
|
|
ifdepth=$((ifdepth - 1))
|
|
|
|
lastif="#if"
|
|
|
|
elif echo "$line" | grep -q "#include"; then
|
|
|
|
if test $ifdepth -eq 0; then
|
|
|
|
echo $line | sed 's/@/"/g'
|
|
|
|
else
|
|
|
|
echo "#include in $lastif : $line" | sed 's/@/"/g' >&2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
)
|
|
|
|
|
|
|
|
list_file_includes "$root/$file".cxx | sed 's/\(#include [<@][^>@]*[>@]\).*/\1/' | sed 's#\.\./##g#' >>$tmpfile
|
2012-12-18 09:46:40 -06:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
)
|
|
|
|
|
|
|
|
cat >$header <<EOF
|
2012-12-15 16:35:28 -06:00
|
|
|
/* -*- 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/.
|
|
|
|
*/
|
|
|
|
|
2013-03-12 11:23:18 -05:00
|
|
|
/*
|
|
|
|
This file has been autogenerated by update_pch.sh . It is possible to edit it
|
|
|
|
manually (such as when an include file has been moved/renamed/removed. All such
|
|
|
|
manual changes will be rewritten by the next run of update_pch.sh (which presumably
|
|
|
|
also fixes all possible problems, so it's usually better to use it).
|
|
|
|
*/
|
|
|
|
|
2012-12-15 16:35:28 -06:00
|
|
|
EOF
|
|
|
|
|
2012-12-18 09:46:40 -06:00
|
|
|
# Library_svx needs this (sendreportw32.cxx)
|
|
|
|
if test "$makefile" = Library_svx.mk ; then
|
|
|
|
cat >>$header <<EOF
|
2012-12-18 07:30:37 -06:00
|
|
|
#ifdef WNT
|
|
|
|
#define UNICODE
|
|
|
|
#define _UNICODE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EOF
|
2012-12-18 09:46:40 -06:00
|
|
|
fi
|
2012-12-15 16:35:28 -06:00
|
|
|
|
|
|
|
function local_file()
|
|
|
|
(
|
|
|
|
file="$1"
|
2012-12-18 07:30:37 -06:00
|
|
|
echo "$file" | grep -q ^"$module"/ && exit 0
|
|
|
|
# find "$root/$module" -type f | grep -v "$root/$module/inc/" | grep /"$file"'$' && exit 0
|
|
|
|
find "$root/$module" -type f | grep /"$file"'$' -q && exit 0
|
|
|
|
if echo "$file" | grep -F . -q; then
|
|
|
|
find "$root/$module" -type f | grep -q /`echo "$file" | sed 's/\.hxx$/.sdi/'` && exit 0
|
|
|
|
fi
|
|
|
|
# not local
|
|
|
|
exit 1
|
2012-12-15 16:35:28 -06:00
|
|
|
)
|
|
|
|
|
2012-12-18 07:30:37 -06:00
|
|
|
function filter_ignore()
|
2012-12-15 16:35:28 -06:00
|
|
|
(
|
2012-12-18 07:30:37 -06:00
|
|
|
# - filter out all files that are not normal headers
|
2012-12-26 05:37:52 -06:00
|
|
|
# - gperffasttoken.hxx is not a proper header
|
2012-12-18 07:30:37 -06:00
|
|
|
# - sores.hxx provides BMP_PLUGIN, which is redefined
|
|
|
|
# - some sources play ugly #define tricks with editeng/eeitemid.hxx
|
2012-12-26 09:30:18 -06:00
|
|
|
# - jerror.h and jpeglib.h are not self-contained
|
2013-07-12 11:12:34 -05:00
|
|
|
# - service1.hxx/service2.hxx are inside comments in frameworks/
|
2012-12-18 07:30:37 -06:00
|
|
|
grep -e '\.h[">]$' -e '\.hpp[">]$' -e '\.hdl[">]$' -e '\.hxx[">]$' -e '^[^\.]*>$' | \
|
|
|
|
grep -v -F -e '#include "gperffasttoken.hxx"' | \
|
|
|
|
grep -v -F -e '#include <svtools/sores.hxx>' | \
|
2012-12-26 09:30:18 -06:00
|
|
|
grep -v -F -e '#include <editeng/eeitemid.hxx>' | \
|
2013-07-12 11:12:34 -05:00
|
|
|
grep -v -F -e '#include <service1.hxx>' | \
|
|
|
|
grep -v -F -e '#include <service2.hxx>' | \
|
2012-12-26 09:30:18 -06:00
|
|
|
grep -v -F -e '#include "jerror.h"' | \
|
2012-12-26 10:33:02 -06:00
|
|
|
grep -v -F -e '#include "jpeglib.h"'
|
2012-12-15 16:35:28 -06:00
|
|
|
)
|
|
|
|
|
2012-12-18 09:46:40 -06:00
|
|
|
# " in #include "foo" breaks echo down below, so " -> @
|
2012-12-26 06:27:09 -06:00
|
|
|
cat $tmpfile | LC_ALL=C sort -u | filter_ignore | sed 's/"/@/g' | \
|
2012-12-18 09:46:40 -06:00
|
|
|
(
|
|
|
|
while read line; do
|
|
|
|
file=`echo $line | sed 's/.*[<"@]\([^>"@]*\)[>"@].*/\1/'`
|
|
|
|
if ! local_file "$file"; then
|
|
|
|
echo $line | sed 's/@/"/g' >>$header
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
)
|
2012-12-15 16:35:28 -06:00
|
|
|
|
2012-12-18 09:46:40 -06:00
|
|
|
cat >>$header <<EOF
|
2012-12-15 16:35:28 -06:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
|
|
EOF
|
|
|
|
|
2012-12-18 09:46:40 -06:00
|
|
|
rm $tmpfile
|
2012-12-15 16:35:28 -06:00
|
|
|
done
|
2012-12-18 07:30:37 -06:00
|
|
|
|
2012-12-15 16:35:28 -06:00
|
|
|
#echo Done.
|
|
|
|
exit 0
|