#!/bin/sh
ROOT=...
QTPATH=...

BUILD_KEY=py2.7-qt5.6.2-64bit-debug
INSTALL=$ROOT/pyside_install/$BUILD_KEY
BUILD=$ROOT/pyside_build/$BUILD_KEY
FIXOPTIONS="--generator-set=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic \
 --use-isnull-as-nb_nonzero --api-version=5.6 --drop-type-entries="

TARGET=QtCore/typesystem_core.xml

# TARGET=QtQuickWidgets/typesystem_quickwidgets.xml
 
CMD="$INSTALL/bin/shiboken2 $FIXOPTIONS $BUILD/pyside2/PySide2/pyside2_global.h \
 --include-paths=$ROOT/sources/pyside2/PySide2:$QTPATH/qtbase/include/ \
 --typesystem-paths=$ROOT/sources/pyside2/PySide2:$ROOT/sources/pyside2/PySide2/QtCore:$ROOT/sources/pyside2/PySide2/QtGui:$ROOT/sources/pyside2/PySide2/QtWidgets:$BUILD/pyside2/PySide2/QtCore:$BUILD/pyside2/PySide2/QtGui:$BUILD/pyside2/PySide2/QtWidgets:$ROOT/sources/pyside2/PySide2/QtNetwork:$BUILD/pyside2/PySide2/QtNetwork:$ROOT/sources/pyside2/PySide2/QtQuick:$BUILD/pyside2/PySide2/QtQuick:$ROOT/sources/pyside2/PySide2/QtQml:$BUILD/pyside2/PySide2/QtQml:$ROOT/sources/pyside2/PySide2/QtQuickWidgets --output-directory=$BUILD/pyside2/PySide2/QtQuickWidgets --license-file=$ROOT/sources/pyside2/PySide2/QtQuickWidgets/../licensecomment.txt \
 $ROOT/sources/pyside2/PySide2/$TARGET"
 
FILE=verrlog
echo "Valgrind on $CMD"
echo "Logging to $FILE"

export TYPESYSTEMPATH=$ROOT/pyside_package/PySide2/typesystems

VAL_OPTIONS="--num-callers=50 --tool=memcheck --leak-check=full --smc-check=all"
valgrind $VAL_OPTIONS $CMD 2>$FILE
echo Done $?
ls -l  $FILE
