X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;ds=inline;f=packages%2Flang%2Fpyqt4%2Ffiles%2Fqt_versioning.sh;fp=packages%2Flang%2Fpyqt4%2Ffiles%2Fqt_versioning.sh;h=ec4fe94808c071a04d942c315ce2e30e590c4d56;hb=c1c94620ebf47c0a0f9e1d1a12ff1e9d83b5b312;hp=0000000000000000000000000000000000000000;hpb=ecab1f5bd82201477a9cd0c6ad712085ecef5866;p=librewrt%2F.git diff --git a/packages/lang/pyqt4/files/qt_versioning.sh b/packages/lang/pyqt4/files/qt_versioning.sh new file mode 100755 index 0000000..ec4fe94 --- /dev/null +++ b/packages/lang/pyqt4/files/qt_versioning.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +die() +{ + echo "PyQt qt_versioning.sh: $*" >&2 + exit 1 +} + +[ $# -eq 3 ] || die "Invalid arguments" + +action="$1" +qtincdir="$2" +tmpfile="$3" + +cp -f "$qtincdir/QtCore/qglobal.h" "$tmpfile" || die "cp failed" +echo "int QT_VERSION_IS = QT_VERSION;" >> "$tmpfile" || die "patching failed (1)" +echo "int QT_EDITION_IS = QT_EDITION;" >> "$tmpfile" || die "patching failed (2)" +# First resolve all preprocessor macros +cpp -x c++ -traditional-cpp "-I$qtincdir" "$tmpfile" > "$tmpfile.processed" || die "CPP failed" + +if [ "$action" = "version" ]; then + raw="$(grep -e 'QT_VERSION_IS' "$tmpfile.processed" | cut -d'=' -f2 | cut -d';' -f1)" +elif [ "$action" = "edition" ]; then + raw="$(grep -e 'QT_EDITION_IS' "$tmpfile.processed" | cut -d'=' -f2 | cut -d';' -f1)" +else + die "Invalid action" +fi +# We use python to evaluate the arithmetic C++ expression. Languages are similar +# enough in that area for this to succeed. +python -c "print \"%d\" % ($raw)" || die "C++ evaluation failed" + +exit 0