2012-02-05 01:14:35 +04:00
|
|
|
#!/bin/bash
|
2010-01-16 04:00:00 +03:00
|
|
|
#
|
|
|
|
# This script creates a binary release of OpenSCAD.
|
2011-10-16 11:39:17 +04:00
|
|
|
# This should work under Mac OS X, Windows (msys), and Linux cross-compiling
|
|
|
|
# for windows using mingw-cross-env (use like: OS=LINXWIN release-common.sh).
|
|
|
|
# Linux support pending.
|
2010-01-16 04:00:00 +03:00
|
|
|
# The script will create a file called openscad-<versionstring>.zip
|
|
|
|
# in the current directory.
|
|
|
|
#
|
2012-01-14 20:37:34 +04:00
|
|
|
# Usage: release-common.sh [-v <versionstring>] [-c]
|
2010-01-16 04:00:00 +03:00
|
|
|
# -v Version string (e.g. -v 2010.01)
|
2012-01-14 20:37:34 +04:00
|
|
|
# -c Build with commit info
|
2010-01-16 04:00:00 +03:00
|
|
|
#
|
|
|
|
# If no version string is given, todays date will be used (YYYY-MM-DD)
|
|
|
|
# If no make target is given, release will be used on Windows, none one Mac OS X
|
|
|
|
#
|
2012-01-14 20:37:34 +04:00
|
|
|
# The commit info will extracted from git and be passed to qmake as OPENSCAD_COMMIT
|
|
|
|
# to identify a build in the about box.
|
2010-01-16 04:00:00 +03:00
|
|
|
|
|
|
|
printUsage()
|
|
|
|
{
|
2012-01-14 20:37:34 +04:00
|
|
|
echo "Usage: $0 -v <versionstring> -c
|
2010-01-16 04:00:00 +03:00
|
|
|
echo
|
|
|
|
echo " Example: $0 -v 2010.01
|
|
|
|
}
|
|
|
|
|
2012-02-05 01:14:35 +04:00
|
|
|
if [[ "$OSTYPE" =~ "darwin" ]]; then
|
2010-01-16 04:00:00 +03:00
|
|
|
OS=MACOSX
|
2010-01-16 04:03:42 +03:00
|
|
|
elif [[ $OSTYPE == "msys" ]]; then
|
2010-01-16 04:00:00 +03:00
|
|
|
OS=WIN
|
2012-02-05 01:14:35 +04:00
|
|
|
elif [[ $OSTYPE == "linux-gnu" ]]; then
|
|
|
|
OS=LINUX
|
|
|
|
if [[ `uname -m` == "x86_64" ]]; then
|
|
|
|
ARCH=64
|
|
|
|
else
|
|
|
|
ARCH=32
|
|
|
|
fi
|
|
|
|
echo "Detected ARCH: $ARCH"
|
|
|
|
elif [[ $OSTYPE == "mingw-cross-env" ]]; then
|
|
|
|
OS=LINXWIN
|
2010-01-16 04:00:00 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Detected OS: $OS"
|
|
|
|
|
2012-01-14 20:37:34 +04:00
|
|
|
while getopts 'v:c' c
|
2010-01-16 04:00:00 +03:00
|
|
|
do
|
|
|
|
case $c in
|
|
|
|
v) VERSION=$OPTARG;;
|
2012-01-14 20:37:34 +04:00
|
|
|
c) OPENSCAD_COMMIT=`git log -1 --pretty=format:"%h"`
|
2010-01-16 04:00:00 +03:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -z "$VERSION"; then
|
|
|
|
VERSION=`date "+%Y.%m.%d"`
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Building openscad-$VERSION $CONFIGURATION..."
|
|
|
|
|
|
|
|
case $OS in
|
2012-02-05 01:14:35 +04:00
|
|
|
LINUX|MACOSX)
|
2010-05-07 20:24:26 +04:00
|
|
|
CONFIG=deploy
|
2010-01-16 04:00:00 +03:00
|
|
|
TARGET=
|
|
|
|
;;
|
|
|
|
WIN)
|
|
|
|
unset CONFIG
|
|
|
|
export QTDIR=/c/devmingw/qt2009.03
|
|
|
|
export QTMAKESPEC=win32-g++
|
|
|
|
export PATH=$PATH:/c/devmingw/qt2009.03/bin:/c/devmingw/qt2009.03/qt/bin
|
|
|
|
ZIP="/c/Program Files/7-Zip/7z.exe"
|
|
|
|
ZIPARGS="a -tzip"
|
|
|
|
TARGET=release
|
|
|
|
;;
|
2011-10-16 11:39:17 +04:00
|
|
|
LINXWIN)
|
|
|
|
unset CONFIG
|
|
|
|
TARGET=release
|
2011-11-07 05:06:50 +04:00
|
|
|
ZIP="zip"
|
|
|
|
ZIPARGS="-r"
|
2011-10-16 11:39:17 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $OS in
|
|
|
|
LINXWIN)
|
2012-01-14 20:37:34 +04:00
|
|
|
i686-pc-mingw32-qmake VERSION=$VERSION OPENSCAD_COMMIT=$OPENSCAD_COMMIT CONFIG+=$CONFIG CONFIG+=mingw-cross-env CONFIG-=debug openscad.pro
|
2011-10-16 11:39:17 +04:00
|
|
|
;;
|
|
|
|
*)
|
2012-01-14 20:37:34 +04:00
|
|
|
qmake VERSION=$VERSION OPENSCAD_COMMIT=$OPENSCAD_COMMIT CONFIG+=$CONFIG CONFIG-=debug openscad.pro
|
2011-10-16 11:39:17 +04:00
|
|
|
;;
|
2010-01-16 04:00:00 +03:00
|
|
|
esac
|
|
|
|
|
|
|
|
make -s clean
|
2010-01-16 04:54:16 +03:00
|
|
|
case $OS in
|
|
|
|
MACOSX)
|
|
|
|
rm -rf OpenSCAD.app
|
|
|
|
;;
|
|
|
|
WIN)
|
2012-02-05 01:14:35 +04:00
|
|
|
#if the following files are missing their tried removal stops the build process on msys
|
2010-01-16 04:54:16 +03:00
|
|
|
touch -t 200012121010 parser_yacc.h parser_yacc.cpp lexer_lex.cpp
|
|
|
|
;;
|
|
|
|
esac
|
2010-01-16 04:00:00 +03:00
|
|
|
|
|
|
|
make -j2 $TARGET
|
|
|
|
|
2010-01-30 20:43:14 +03:00
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo "Error building OpenSCAD. Aborting."
|
2010-02-10 03:50:02 +03:00
|
|
|
exit 1
|
2010-01-30 20:43:14 +03:00
|
|
|
fi
|
|
|
|
|
2010-01-16 04:00:00 +03:00
|
|
|
echo "Creating directory structure..."
|
|
|
|
|
|
|
|
case $OS in
|
|
|
|
MACOSX)
|
2010-02-15 21:39:28 +03:00
|
|
|
EXAMPLESDIR=OpenSCAD.app/Contents/Resources/examples
|
2011-09-08 05:27:18 +04:00
|
|
|
LIBRARYDIR=OpenSCAD.app/Contents/Resources/libraries
|
2010-02-15 21:39:28 +03:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
EXAMPLESDIR=openscad-$VERSION/examples/
|
2011-09-08 05:27:18 +04:00
|
|
|
LIBRARYDIR=openscad-$VERSION/libraries/
|
2010-02-15 21:39:28 +03:00
|
|
|
rm -rf openscad-$VERSION
|
|
|
|
mkdir openscad-$VERSION
|
2010-01-16 04:00:00 +03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-01-26 01:06:27 +04:00
|
|
|
if [ -d .git ]; then
|
2012-01-25 19:43:43 +04:00
|
|
|
git submodule update
|
|
|
|
fi
|
|
|
|
|
2011-09-08 05:27:18 +04:00
|
|
|
if [ -n $EXAMPLESDIR ]; then
|
|
|
|
echo $EXAMPLESDIR
|
|
|
|
mkdir -p $EXAMPLESDIR
|
|
|
|
cp examples/* $EXAMPLESDIR
|
|
|
|
chmod -R 644 $EXAMPLESDIR/*
|
|
|
|
fi
|
|
|
|
if [ -n $LIBRARYDIR ]; then
|
|
|
|
echo $LIBRARYDIR
|
|
|
|
mkdir -p $LIBRARYDIR
|
|
|
|
cp -R libraries/* $LIBRARYDIR
|
|
|
|
chmod -R u=rwx,go=r,+X $LIBRARYDIR/*
|
|
|
|
rm -rf `find $LIBRARYDIR -name ".git"`
|
|
|
|
fi
|
2010-01-22 19:09:00 +03:00
|
|
|
|
2010-01-16 04:54:16 +03:00
|
|
|
echo "Creating archive.."
|
2010-02-15 21:39:28 +03:00
|
|
|
|
2010-01-22 19:09:00 +03:00
|
|
|
case $OS in
|
|
|
|
MACOSX)
|
2010-02-15 21:39:28 +03:00
|
|
|
macdeployqt OpenSCAD.app -dmg -no-strip
|
|
|
|
mv OpenSCAD.dmg OpenSCAD-$VERSION.dmg
|
2010-01-22 19:09:00 +03:00
|
|
|
hdiutil internet-enable -yes -quiet OpenSCAD-$VERSION.dmg
|
2010-01-25 02:20:45 +03:00
|
|
|
echo "Binary created: OpenSCAD-$VERSION.dmg"
|
2010-02-15 21:39:28 +03:00
|
|
|
;;
|
|
|
|
WIN)
|
|
|
|
#package
|
|
|
|
cp win32deps/* openscad-$VERSION
|
|
|
|
cp $TARGET/openscad.exe openscad-$VERSION
|
2010-01-22 19:09:00 +03:00
|
|
|
rm -f openscad-$VERSION.zip
|
|
|
|
"$ZIP" $ZIPARGS openscad-$VERSION.zip openscad-$VERSION
|
2010-02-15 21:39:28 +03:00
|
|
|
rm -rf openscad-$VERSION
|
2010-01-22 19:09:00 +03:00
|
|
|
echo "Binary created: openscad-$VERSION.zip"
|
|
|
|
;;
|
2011-10-16 11:39:17 +04:00
|
|
|
LINXWIN)
|
|
|
|
#package
|
|
|
|
cp $TARGET/openscad.exe openscad-$VERSION
|
|
|
|
rm -f OpenSCAD-$VERSION.zip
|
|
|
|
"$ZIP" $ZIPARGS OpenSCAD-$VERSION.zip openscad-$VERSION
|
2011-11-07 05:06:50 +04:00
|
|
|
cp scripts/installer.nsi openscad-$VERSION/
|
|
|
|
cd openscad-$VERSION && makensis installer.nsi && cd ..
|
|
|
|
cp openscad-$VERSION/openscad_setup.exe OpenSCAD-$VERSION-Installer.exe
|
2011-10-16 11:39:17 +04:00
|
|
|
rm -rf openscad-$VERSION
|
|
|
|
echo "Binary created: OpenSCAD-$VERSION.zip"
|
|
|
|
echo "Installer created: OpenSCAD-$VERSION-Installer.exe"
|
|
|
|
;;
|
2012-02-05 01:14:35 +04:00
|
|
|
LINUX)
|
|
|
|
# Do stuff from release-linux.sh
|
|
|
|
mkdir openscad-$VERSION/bin
|
|
|
|
mkdir -p openscad-$VERSION/lib/openscad
|
|
|
|
cp scripts/openscad-linux openscad-$VERSION/bin/openscad
|
|
|
|
cp openscad openscad-$VERSION/lib/openscad/
|
|
|
|
if [[ $ARCH == 64 ]]; then
|
|
|
|
gcc -o chrpath_linux -DSIZEOF_VOID_P=8 scripts/chrpath_linux.c
|
|
|
|
else
|
|
|
|
gcc -o chrpath_linux -DSIZEOF_VOID_P=4 scripts/chrpath_linux.c
|
|
|
|
fi
|
|
|
|
./chrpath_linux -d openscad-$VERSION/lib/openscad/openscad
|
|
|
|
ldd openscad | sed -re 's,.* => ,,; s,[\t ].*,,;' -e '/Qt|boost/ { p; d; };' \
|
|
|
|
-e '/lib(icu.*|stdc.*|audio|CGAL|GLEW|opencsg|png|gmp|gmpxx|mpfr)\.so/ { p; d; };' \
|
|
|
|
-e 'd;' | xargs cp -vt openscad-$VERSION/lib/openscad/
|
|
|
|
strip openscad-$VERSION/lib/openscad/*
|
|
|
|
cp scripts/installer-linux.sh openscad-$VERSION/install.sh
|
|
|
|
chmod 755 -R openscad-$VERSION/
|
2012-06-19 19:39:06 +04:00
|
|
|
tar cz openscad-$VERSION > openscad-$VERSION.x86-$ARCH.tar.gz
|
2012-02-05 01:14:35 +04:00
|
|
|
;;
|
2010-01-22 19:09:00 +03:00
|
|
|
esac
|