3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # Usage: update_pch.sh [precompiled_xxx.hxx]
13 root
=`cd $root/.. && pwd`
16 headers
=`ls $root/*/inc/pch/precompiled_*.hxx`
23 echo updating
`echo $header | sed -e s%$root/%%`
24 module
=`readlink -f $header | sed -e s%$root/%% -e s%/.*%%`
25 name
=`echo $header | sed -e s/.*precompiled_// -e s/\.hxx//`
26 makefile
="Library_$name.mk"
30 cat "$root/$module/$makefile" |
sed 's#\\$##' | \
35 if test "$line" = "))" ; then
37 elif echo $line |
grep -q -e add_exception_objects
-e add_noexception_objects
-e add_cxxobject
-e add_cxxobjects
; then
39 if test $ifstack -ne 0 ; then
40 echo Sources
in a conditional
, ignoring
for now.
>&2
42 elif echo $line |
grep -q ^
if ; then
43 ifstack
=$
((ifstack
+ 1))
44 elif echo $line |
grep -q ^endif
; then
45 ifstack
=$
((ifstack
- 1))
46 elif test -n "$inobjects" -a $ifstack -eq 0; then
48 if echo $line |
grep -q ", "; then
49 true
# $if() probably, or something similar
50 elif ! test -f "$root/$file".cxx
; then
51 echo No
file $file in $module/$makefile >&2
54 function list_file_includes
()
57 # filter out only preprocessor lines, get the first and second "words" after the #,
58 # also replace " with @ (would cause trouble when doing echo of the line)
59 cat "$1" |
grep '^\s*#' |
sed 's/^\s*#/#/' |
sed 's/^\(#\w*\s+\w*\)\s+.*/\1/' |
sed 's/"/@/g' | \
61 # skip everything surrounded by any #if
62 if echo "$line" |
grep -q "#if" ; then
63 ifdepth
=$
((ifdepth
+ 1))
65 elif echo "$line" |
grep -q "#endif" ; then
66 ifdepth
=$
((ifdepth
- 1))
68 elif echo "$line" |
grep -q "#include"; then
69 if test $ifdepth -eq 0; then
70 echo $line |
sed 's/@/"/g'
72 echo "#include in $lastif : $line" |
sed 's/@/"/g' >&2
78 list_file_includes
"$root/$file".cxx |
sed 's/\(#include [<@][^>@]*[>@]\).*/\1/' |
sed 's#\.\./##g#' >>$tmpfile
85 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
87 * This file is part of the LibreOffice project.
89 * This Source Code Form is subject to the terms of the Mozilla Public
90 * License, v. 2.0. If a copy of the MPL was not distributed with this
91 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
95 This file has been autogenerated by update_pch.sh . It is possible to edit it
96 manually (such as when an include file has been moved/renamed/removed. All such
97 manual changes will be rewritten by the next run of update_pch.sh (which presumably
98 also fixes all possible problems, so it's usually better to use it).
103 # Library_svx needs this (sendreportw32.cxx)
104 if test "$makefile" = Library_svx.mk
; then
114 function local_file
()
117 echo "$file" |
grep -q ^
"$module"/ && exit 0
118 # find "$root/$module" -type f | grep -v "$root/$module/inc/" | grep /"$file"'$' && exit 0
119 find "$root/$module" -type f |
grep /"$file"'$' -q && exit 0
120 if echo "$file" |
grep -F .
-q; then
121 find "$root/$module" -type f |
grep -q /`echo "$file" | sed 's/\.hxx$/.sdi/'` && exit 0
127 function filter_ignore
()
129 # - filter out all files that are not normal headers
130 # - gperffasttoken.hxx is not a proper header
131 # - sores.hxx provides BMP_PLUGIN, which is redefined
132 # - some sources play ugly #define tricks with editeng/eeitemid.hxx
133 # - jerror.h and jpeglib.h are not self-contained
134 grep -e '\.h[">]$' -e '\.hpp[">]$' -e '\.hdl[">]$' -e '\.hxx[">]$' -e '^[^\.]*>$' | \
135 grep -v -F -e '#include "gperffasttoken.hxx"' | \
136 grep -v -F -e '#include <svtools/sores.hxx>' | \
137 grep -v -F -e '#include <editeng/eeitemid.hxx>' | \
138 grep -v -F -e '#include "jerror.h"' | \
139 grep -v -F -e '#include "jpeglib.h"'
142 # " in #include "foo" breaks echo down below, so " -> @
143 cat $tmpfile | LC_ALL
=C
sort -u | filter_ignore |
sed 's/"/@/g' | \
146 file=`echo $line | sed 's/.*[<"@]\([^>"@]*\)[>"@].*/\1/'`
147 if ! local_file
"$file"; then
148 echo $line |
sed 's/@/"/g' >>$header
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */