-
Notifications
You must be signed in to change notification settings - Fork 109
/
make_iwyu_qt_imp.sh
executable file
·83 lines (77 loc) · 3.64 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
76
77
78
79
80
81
82
83
#!/bin/sh
echo "["
echo "# --- Generated by ${0##*/} ---"
LAST_MODULE=""
for MODULE in QtAndroidExtras QtCore QtGui QtNetwork QtPositioning QtPrintSupport QtSensors QtSerialPort QtTest QtWidgets
do
echo "\n # ${MODULE}"
for I in $(find "${MODULE}" -type f -name "Q*")
do
INCLUDE="${I##*/}"
INCLUDE_LC=$(echo "$INCLUDE.h" | awk '{print tolower($0)}')
INCLUDE_DIR="${I%/*}"
#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 | sort
done # module
cat << END_EXTRA
# --- Manual additions ---
# convenience
{ include: [ "<qbasicatomic.h>", "public", "<QAtomicInteger>", "public" ] },
{ include: [ "<QFlag>", "public", "<QFlags>", "public" ] },
{ include: [ "<QNoDebug>", "public", "<QDebug>", "public" ] },
{ include: [ "<QStaticByteArrayData>", "public", "<QByteArray>", "public" ] },
{ include: [ "<QStaticStringData>", "public", "<QString>", "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" ] },
# http://doc.qt.io/qt-5/qstring.html
{ include: [ "<qstringliteral.h>", "private", "<QString>", "public" ] },
# http://doc.qt.io/qt-5/qtconcurrent.html
{ include: [ "<qtconcurrentfilter.h>", "private", "<QtConcurrent>", "public" ] },
{ include: [ "<qtconcurrentmap.h>", "private", "<QtConcurrent>", "public" ] },
{ include: [ "<qtconcurrentrun.h>", "private", "<QtConcurrent>", "public" ] },
END_EXTRA
echo "]"