speed up build_ui.sh

This commit is contained in:
Damien Elmes 2011-11-30 15:41:11 +09:00
parent b9522487ad
commit 0d37223c88

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# generate python files based on the designer ui files # generate python files based on the designer ui files. pyuic4 and pyrcc4
# should be on the path.
# #
if [ ! -d "designer" ] if [ ! -d "designer" ]
@ -11,42 +12,6 @@ fi
mkdir -p aqt/forms mkdir -p aqt/forms
pyuic=`which pyuic4`
pyrcc=`which pyrcc4`
if [ $? != 0 ]; then
if [ xDarwin = x$(uname) ]
then
if [ -e /Library/Frameworks/Python.framework/Versions/2.7/bin/pyuic4 ]
then
pyuic=/Library/Frameworks/Python.framework/Versions/2.7/bin/pyuic4
pyrcc=/Library/Frameworks/Python.framework/Versions/2.7/bin/pyrcc4
elif [ -e /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pyuic4 ]
then
pyuic=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pyuic4
pyrcc=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pyrcc4
elif [ -e /System/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4 ]
then
pyuic=/System/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4
pyrcc=/System/Library/Frameworks/Python.framework/Versions/2.6/bin/pyrcc4
elif [ -e /Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4 ]
then
pyuic=/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4
pyrcc=/Library/Frameworks/Python.framework/Versions/2.6/bin/pyrcc4
elif [ -f /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4 ]
then
pyuic=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/pyuic4
pyrcc=/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/pyrcc4
else
echo 'Unable to find pyuic4. If you use macports try `port install py-pyqt4`. If you use homebrew try `brew install pyqt`.'
exit 1
fi
else
echo "Unable to find pyuic4 on your path! Please install it and try this script again."
exit 1
fi
fi
init=aqt/forms/__init__.py init=aqt/forms/__init__.py
temp=aqt/forms/scratch temp=aqt/forms/scratch
rm -f $init $temp rm -f $init $temp
@ -56,21 +21,21 @@ echo "__all__ = [" >> $init
echo "Generating forms.." echo "Generating forms.."
for i in designer/*.ui for i in designer/*.ui
do do
base=$(echo $i | perl -pe 's/\.ui//; s%designer/%%;') base=$(basename -s.ui $i)
py=$(echo $i | perl -pe 's/\.ui/.py/; s%designer%aqt/forms%;') py="aqt/forms/${base}.py"
echo " * "$py
$pyuic $i -o $py
echo " \"$base\"," >> $init echo " \"$base\"," >> $init
echo "import $base" >> $temp echo "import $base" >> $temp
# munge the output to use gettext if [ $i -nt $py ]; then
perl -pi.bak -e 's/QtGui.QApplication.translate\(".*?", /_(/; s/, None, QtGui.*/))/' $py echo " * "$py
# remove the 'created' time, to avoid flooding the version control system pyuic4 $i -o $py
perl -pi.bak -e 's/^# Created:.*$//' $py # munge the output to use gettext
rm $py.bak perl -pi.bak -e 's/QtGui.QApplication.translate\(".*?", /_(/; s/, None, QtGui.*/))/' $py
rm $py.bak
fi
done done
echo "]" >> $init echo "]" >> $init
cat $temp >> $init cat $temp >> $init
rm $temp rm $temp
echo "Building resources.." echo "Building resources.."
$pyrcc designer/icons.qrc -o aqt/forms/icons_rc.py pyrcc4 designer/icons.qrc -o aqt/forms/icons_rc.py