forked from OpenOrienteering/mapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_iwyu_qt_imp.sh
executable file
·75 lines (69 loc) · 2.84 KB
/
make_iwyu_qt_imp.sh
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
74
75
#!/bin/sh
echo "["
echo "# --- Generated by ${0##*/} ---\n"
LAST_MODULE=""
for I in $(find Q* -type f -name "Q*")
do
INCLUDE="${I##*/}"
INCLUDE_LC=$(echo "$INCLUDE.h" | awk '{print tolower($0)}')
INCLUDE_DIR="${I%/*}"
MODULE="${I%%/*}"
if [ "${MODULE}" != "${LAST_MODULE}" ]
then
echo "\n # ${MODULE}"
LAST_MODULE="${MODULE}"
fi
#echo "$INCLUDE_DIR $INCLUDE $INCLUDE_LC";
if [ "${MODULE}" = "QtTest" ]
then
# Use only <QtTest> for module QtTest
if [ "${INCLUDE}" = "QtTest" ]
then
for J in $(find "${MODULE}" -type f -name "q*.h")
do
INCLUDE="${J##*/}"
echo " { include: [ \"<${INCLUDE}>\", \"private\", \"<QtTest>\", \"public\" ] },"
done
else
echo " { include: [ \"<${INCLUDE}>\", \"private\", \"<QtTest>\", \"public\" ] },"
fi
elif [ -f "$INCLUDE_DIR/$INCLUDE_LC" -a $(grep "#include \"$INCLUDE_LC" "$I" | wc -l) -eq 1 ]
then
# Use public <QFoo> include for <qfoo.h> include
grep "#include \"$INCLUDE_LC" "$I" | sed -e "s/.*\"\(.*\)\"/ { include: [ \"<\1>\", \"private\", \"<${INCLUDE}>\", \"public\" ] },/"
elif [ "${INCLUDE#Qt}" = "${INCLUDE}" ]
then
# Use public <QFoo> include for QFoo symbol
if [ $(grep "#include \"q" "$I" | wc -l) -eq 1 ]
then
echo " { symbol: [ \"${INCLUDE}\", \"private\", \"<${INCLUDE}>\", \"public\" ] },"
fi
elif [ -f "$INCLUDE_DIR/q${INCLUDE_LC#qt}" -a $(grep "#include \"q${INCLUDE_LC#qt}" "$I" | wc -l) -eq 1 ]
then
# Use public QtFoo include for private qfoo.h include
grep "#include \"q${INCLUDE_LC#qt}" "$I" | sed -e "s/.*\"\(.*\)\"/ { include: [ \"<\1>\", \"private\", \"<${INCLUDE}>\", \"public\" ] },/"
fi
done
cat << END_EXTRA
# --- Manual additions ---
# convenience
{ include: [ "<QFlag>", "public", "<QFlags>", "public" ] },
{ include: [ "<QVariantComparisonHelper>", "public", "<QVariant>", "public" ] },
# http://doc.qt.io/qt-5/qt.html
{ include: [ "<qnamespace.h>", "private", "<Qt>", "public" ] },
# http://doc.qt.io/qt-5/qtglobal.html
{ include: [ "<QtMessageHandler>", "public", "<QtGlobal>", "public" ] },
{ include: [ "<QtMsgHandler>", "public", "<QtGlobal>", "public" ] },
{ include: [ "<qcompilerdetection.h>", "private", "<QtGlobal>", "public" ] },
{ include: [ "<qprocessordetection.h>", "private", "<QtGlobal>", "public" ] },
{ include: [ "<qsystemdetection.h>", "private", "<QtGlobal>", "public" ] },
{ include: [ "<qlogging.h>", "private", "<QtGlobal>", "public" ] },
# http://doc.qt.io/qt-5/qevent.html
{ include: [ "<qevent.h>", "private", "<QEvent>", "public" ] },
{ include: [ "<qcoreevent.h>", "private", "<QEvent>", "public" ] },
# http://doc.qt.io/qt-5/qmetaobject.html
{ include: [ "<qmetaobject.h>", "private", "<QMetaObject>", "public" ] },
# http://doc.qt.io/qt-5/qobject.html
{ include: [ "<qobjectdefs.h>", "private", "<QObject>", "public" ] },
END_EXTRA
echo "]"