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