2010-03-18 12:06:43 +01:00
|
|
|
#!/bin/bash
|
2010-03-03 11:38:33 +01:00
|
|
|
|
2012-09-10 13:08:23 +02:00
|
|
|
# This is the script that generates the copy of the QmlJS parser from the sources
|
|
|
|
|
# in the qtdeclarative source tree.
|
|
|
|
|
#
|
|
|
|
|
# It applies a bunch of renames to make the source compatible with the Qt Creator
|
|
|
|
|
# sources as well as rewrites of the licenses.
|
|
|
|
|
#
|
|
|
|
|
# Example:
|
|
|
|
|
# cd src/libs/qmljs/parser
|
|
|
|
|
# QTDIR=~/path/to/qtdeclarative-checkout ./gen-parser.sh
|
|
|
|
|
|
2021-07-07 10:46:16 +02:00
|
|
|
###
|
|
|
|
|
# to update this script:
|
|
|
|
|
# 1. do all changes & commit them
|
|
|
|
|
# 2. run this script commenting out the two patch commands in the last lines below
|
|
|
|
|
# 3. update the first patch using
|
|
|
|
|
# # git diff > grammar.patch
|
|
|
|
|
# 4. uncomment the first (grammar) patch, re-run script
|
|
|
|
|
# 5. update the second patch with
|
|
|
|
|
# # git diff > parser.patch
|
|
|
|
|
# 6. parser.patch needs to be manually edited to remove the patching
|
|
|
|
|
# of non relevant files (gen-parser.sh, grammar.patch, parser.patch, qmljs.g)
|
|
|
|
|
# 7. test by running again with the patch commands activated and verify the diffs.
|
|
|
|
|
# 8. commit the updated .patch files
|
|
|
|
|
###
|
|
|
|
|
|
2020-02-28 17:51:32 +01:00
|
|
|
if [ -z "$QTDIR" -o -z "$QLALR" ]; then
|
|
|
|
|
echo "Usage: QTDIR=~/path/to/qtdeclarative-checkout QLALR=~/path/to/qlalr $0" 1>&2
|
2018-04-05 15:52:27 +03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2020-02-28 17:51:32 +01:00
|
|
|
|
2010-03-03 11:38:33 +01:00
|
|
|
me=$(dirname $0)
|
|
|
|
|
|
2021-07-07 10:46:16 +02:00
|
|
|
for i in $QTDIR/src/qml/parser/*.{g,h,cpp}; do
|
2018-04-05 15:52:27 +03:00
|
|
|
if ! echo $i | grep -q qmljsglobal; then
|
|
|
|
|
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqmljs/qmljs/)
|
|
|
|
|
fi
|
2010-03-03 11:38:33 +01:00
|
|
|
done
|
|
|
|
|
|
2020-02-28 17:51:32 +01:00
|
|
|
for i in $QTDIR/src/qml/qmldirparser/*.{h,cpp}; do
|
|
|
|
|
if ! echo $i | grep -q qmljsglobal; then
|
|
|
|
|
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqml/qml/)
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
for i in $QTDIR/src/qml/common/qqmljs{sourcelocation,memorypool}_p.h; do
|
|
|
|
|
sed -f $me/cmd.sed $i > $me/$(echo $(basename $i) | sed s/qqmljs/qmljs/)
|
2010-03-18 12:06:43 +01:00
|
|
|
done
|
2010-03-03 11:38:33 +01:00
|
|
|
|
2020-02-28 17:51:32 +01:00
|
|
|
# remove qmlapiversion_p.h include
|
|
|
|
|
#include "qmlapiversion_p.h"
|
|
|
|
|
perl -p -0777 -i -e 's/#include \"qmlapiversion_p.h\"//' qmljsdiagnosticmessage_p.h
|
2012-07-31 10:12:26 +02:00
|
|
|
# remove qmlglobal_p.h include
|
|
|
|
|
perl -p -0777 -i -e 's/#include \"qmlglobal_p.h\"//' qmldirparser.cpp
|
|
|
|
|
# remove qmlglobal_p.h include
|
|
|
|
|
perl -p -0777 -i -e 's/#include \<QtQml\/qmlfile.h\>//' qmldirparser.cpp
|
|
|
|
|
# replace private/qhashedstring_p.h include and QHashedStringRef
|
|
|
|
|
perl -p -0777 -i -e 's/#include \<private\/qhashedstring_p.h\>//' qmldirparser_p.h
|
|
|
|
|
perl -p -0777 -i -e 's/QHashedStringRef/QString/g' qmldirparser_p.h qmldirparser.cpp
|
2018-04-05 15:52:27 +03:00
|
|
|
# replace include guards with #pragma once
|
|
|
|
|
for i in *.h; do
|
|
|
|
|
grep -q generate $i || perl -p -0777 -i -e 's/#ifndef ([A-Z_]*)\n#define \1\n*([\s\S]*)\n#endif( \/\/ .*)?/#pragma once\n\n\2/' $i
|
|
|
|
|
done
|
2012-07-31 10:12:26 +02:00
|
|
|
# don't use the new QVarLengthArray::length()
|
|
|
|
|
sed -i -e 's/chars.length()/chars.size()/' $me/qmljslexer.cpp
|
2014-01-15 00:18:53 +01:00
|
|
|
sed -i -e 's/DiagnosticMessage::Error/Severity::Error/g' $me/qmljsparser.cpp
|
|
|
|
|
sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser.cpp
|
|
|
|
|
sed -i -e 's/DiagnosticMessage::Warning/Severity::Warning/g' $me/qmljsparser_p.h
|
|
|
|
|
sed -i -e 's|#include <QtCore/qstring.h>|#include <QString>|g' $me/qmljsengine_p.h
|
|
|
|
|
sed -i -e 's|#include <QtCore/qset.h>|#include <QSet>|g' $me/qmljsengine_p.h
|
2018-04-05 15:52:27 +03:00
|
|
|
sed -i -e 's/qt_qnan/qQNaN/' $me/qmljsengine_p.cpp
|
|
|
|
|
sed -i -e 's|#include <QtCore/private/qnumeric_p.h>|#include <QtCore/qnumeric.h>|' $me/qmljsengine_p.cpp
|
2014-01-15 00:18:53 +01:00
|
|
|
perl -p -0777 -i -e 's/QT_QML_BEGIN_NAMESPACE/#include <qmljs\/qmljsconstants.h>\nQT_QML_BEGIN_NAMESPACE/' qmljsengine_p.h
|
2011-05-12 13:25:35 +02:00
|
|
|
|
2021-07-07 10:46:16 +02:00
|
|
|
patch -R -p5 < grammar.patch
|
2020-02-28 17:51:32 +01:00
|
|
|
$QLALR qmljs.g
|
|
|
|
|
|
2011-05-12 13:25:35 +02:00
|
|
|
./changeLicense.py $me/../qmljs_global.h qml*.{cpp,h}
|
2020-02-28 17:51:32 +01:00
|
|
|
|
2021-07-07 10:46:16 +02:00
|
|
|
patch -p5 -R < parser.patch
|