diff --git a/scripts/prepare-commit.sh b/scripts/prepare-commit.sh index f61aebaa8e9..25a6c3c98c1 100755 --- a/scripts/prepare-commit.sh +++ b/scripts/prepare-commit.sh @@ -117,6 +117,7 @@ for f in $MODIFIED; do if ! grep -Fxq "$sip_file" python/auto_sip.blacklist; then #echo "automatic file" m=python/$sip_file.$REV.prepare + touch python/$sip_file cp python/$sip_file $m ${TOPLEVEL}/scripts/sipify.pl $f > $m if diff -u $m python/$sip_file >>$SIPIFYDIFF; then diff --git a/scripts/sipdiff b/scripts/sipdiff index 161c91579aa..d581ce263f2 100755 --- a/scripts/sipdiff +++ b/scripts/sipdiff @@ -1,18 +1,15 @@ #!/usr/bin/env bash +DIR=$(git rev-parse --show-toplevel) + # ARGUMENTS -FORCE=NO SIPIFY=NO -while getopts ":fs" opt; do +while getopts ":s" opt; do case $opt in s) # sipify header SIPIFY=YES ;; - f) - # force if sip is automatically generated - FORCE=YES - ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 @@ -31,24 +28,35 @@ for file in $*; do header="src/$d/$f.h" if ! grep -Fxq "$d/$f.sip" python/auto_sip.blacklist; then - echo -e "\033[0;31m$d/$f.sip is automatically generated using sipify.pl script\033[0m" - echo "use following command to generate the SIP file:" - echo -e " \033[0;32m./sripts/sipify.pl $header > $d/$f.sip\033[0m" - if [[ $FORCE =~ NO ]]; then - echo "use -f argument to force showing the diff" - fi - if [[ $(wc -w <<< "$input") -eq "1" ]]; then - read -n 1 -s -p "Press any key to continue" + echo -e "\033[0;31m$d/$f.sip is an automatically generated SIP file\033[0m" + echo -e " g) \x1B[4mg\x1B[0menerate the SIP file \033[0;32m./sripts/sipify.pl $header > $d/$f.sip\033[0m" + echo -e " s) \x1B[4ms\x1B[0mhow the diff" + SHOW=NO + while read -n 1 n; do echo "" - fi - if [[ $FORCE =~ NO ]]; then + case $n in + g) + echo "Genreating the SIP file ..." + ${DIR}/scripts/sipify.pl ${DIR}/$header > ${DIR}/python/$d/$f.sip + break + ;; + s) + SHOW=YES + break + ;; + *) + invalid option + ;; + esac + done + if [[ $SHOW =~ NO ]]; then continue fi fi if [[ $SIPIFY =~ YES ]]; then - tempfile=$(${GP}mktemp ${f}XXXX --suffix=.h) - ./scripts/sipify.pl $header > $tempfile + tempfile=$(mktemp ${DIR}/${f}XXXX --suffix=.h) + ${DIR}/scripts/sipify.pl ${DIR}/$header > $tempfile else tempfile=$header fi diff --git a/scripts/sipify.pl b/scripts/sipify.pl index b2681f64535..ce38dcf7a89 100755 --- a/scripts/sipify.pl +++ b/scripts/sipify.pl @@ -172,7 +172,10 @@ while(!eof $header){ } # class declaration started - if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)(\s+\w+)(\s*\:.*)?$/ ){ + if ( $line =~ m/^(\s*class)\s*([A-Z]+_EXPORT)?(\s+\w+)(\s*\:.*)?$/ ){ + do {no warnings 'uninitialized'; + $line =~ m/\bCORE_EXPORT\b/ or die 'Class shoud be exported with appropriate [LIB]_EXPORT macro.'; + }; $line = "$1$3"; # Inheritance if ($4){