1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/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/.
#
# Create a makefile that builds every non-generated header as a source file.
# This should help to ensure the headers are self-contained and don't
# impose unnecessary requirements (unnecessary includes) on client code.
#
# This script is fully compliant with the UNIX philosophy
# (and if you can't read it you are clearly not worthy)
set -e
iwyu_INCLUDES=$(grep -h -r ":$" ${BUILDDIR}/workdir/Dep/*Object* \
| grep -v 'workdir\|config_host' | grep -v "^/usr" \
| sed -e "s,^${SRCDIR}/,," | sed -e "s/:$//" | sort -u)
iwyu_INCLUDEDIRS=$(echo "${iwyu_INCLUDES}" | sed -e "s,/[^/]*$,," | grep -v "^include" | sort -u)
iwyu_EXTERNALS=$(ls ${SRCDIR}/*/*Library*mk ${SRCDIR}/*/*Executable*mk \
| xargs awk -f ${SRCDIR}/bin/gen-iwyu-dummy-lib.awk \
| grep -v '$(\|)\|tde\|expat_x64\|zlib_x64\|mozilla\|apr\|serf')
mkdir -p ${BUILDDIR}/iwyudummy
iwyu_MOD=${BUILDDIR}/iwyudummy/Module_iwyudummy.mk
iwyu_LIB=${BUILDDIR}/iwyudummy/StaticLibrary_iwyudummy.mk
echo 'module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))' > ${BUILDDIR}/iwyudummy/Makefile
echo "include ${SRCDIR}/solenv/gbuild/partial_build.mk" >> ${BUILDDIR}/iwyudummy/Makefile
echo '$(eval $(call gb_Module_Module,iwyudummy))' > ${iwyu_MOD}
echo '$(eval $(call gb_Module_add_targets,iwyudummy,StaticLibrary_iwyudummy))' >> ${iwyu_MOD}
# prevent some common configuration errors
echo 'ifneq ($(COMPILER_PLUGINS),)' > ${iwyu_LIB}
echo ' $(call gb_Output_error,--enable-compiler-plugins does not work well with this: bailing out)' >> ${iwyu_LIB}
echo 'endif' >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary_StaticLibrary,iwyudummy))' >> ${iwyu_LIB}
# clang will "compile" headers to .gch by default
echo '$(eval $(call gb_StaticLibrary_add_cxxflags,iwyudummy,-x c++ -Wno-unused-macros -Wno-unused-const-variable))' >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary_use_custom_headers,iwyudummy,officecfg/registry))' >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary_use_sdk_api,iwyudummy))' >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary_use_externals,iwyudummy,\' >> ${iwyu_LIB}
for ext in ${iwyu_EXTERNALS}; do
echo "${ext} \\";
done >> ${iwyu_LIB}
echo '))' >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary_set_include,iwyudummy,\' >> ${iwyu_LIB}
echo '$$(INCLUDE) \' >> ${iwyu_LIB}
for dir in ${iwyu_INCLUDEDIRS}; do
if echo ${dir} | grep ".*/inc/" &>/dev/null; then
iwyu_INCLUDEDIRS_EXTRA+=" ${dir%/inc/*}/inc"
fi
done
for dir in $(echo ${iwyu_INCLUDEDIRS_EXTRA} | sed -e "s/ /\n/g" | uniq) ${iwyu_INCLUDEDIRS}; do
echo "-I${SRCDIR}/${dir} \\";
done >> ${iwyu_LIB}
# it fails to find stddef.h?
echo "-I/usr/lib/clang/$(llvm-config --version)/include \\" >> ${iwyu_LIB}
echo "))" >> ${iwyu_LIB} >> ${iwyu_LIB}
echo '$(eval $(call gb_StaticLibrary__add_iwyu_headers,iwyudummy,\' >> ${iwyu_LIB}
for hdr in ${iwyu_INCLUDES}; do
echo "${hdr} \\";
done >> ${iwyu_LIB}
echo '))' >> ${iwyu_LIB}
|