File indexing completed on 2024-05-19 04:32:41

0001 #!/bin/sh
0002 #
0003 #set -x
0004 #
0005 startdir=$PWD
0006 
0007 
0008 # ---------------------------------------------------------
0009 #
0010 # set 'versionname' to overwrite generated one based on 'ver'
0011 #
0012 
0013 #versionname=Kst-2.0.8-rc2
0014 
0015 ver=2.0.x
0016 date=`date --utc '+%Y.%m.%d-%H.%M'`
0017 if [ -z $versionname ]; then
0018     buildinstaller=0
0019     versionname=Kst-$ver-$date
0020 else
0021     buildinstaller=1
0022 fi
0023 
0024 #if [ "$1" = "qt5" ]; then
0025 #    versionname=$versionname-Qt5
0026 #fi
0027 
0028 dep=$HOME/dep
0029 mkdir -p $dep
0030 
0031 
0032 echo ---------------------------------------------------------
0033 echo ---------- Building $versionname
0034 echo ---------------------------------------------------------
0035 
0036 
0037 if [ -f "/usr/bin/ninja" ] || [ -f "/usr/local/bin/ninja" ]; then
0038     generator=-GNinja
0039     buildcmd=ninja
0040     buildcmd_parallel=ninja
0041     export NINJA_STATUS="[%f/%t %o/s, %es] "
0042 else
0043     buildcmd=make
0044     buildcmd_parallel="make -j2"
0045 fi
0046 
0047 # ---------------------------------------------------------
0048 #
0049 # print some info about the system
0050 #
0051 echo
0052 echo Build system:
0053 echo
0054 uname -a
0055 lsb_release -a
0056 processors=`grep -c processor /proc/cpuinfo`
0057 echo number of processors: $processors
0058 dpkg --get-selections | grep mingw
0059 iam=`whoami`
0060 travis=travis
0061 echo ---------------------------------------------------------
0062 echo
0063 
0064 if [ "$iam" = "$travis" ]; then
0065     deploybinary=1
0066 else
0067     deploybinary=0
0068 fi
0069 
0070 # ---------------------------------------------------------
0071 #
0072 # helper function to check return code
0073 #
0074 checkExitCode() {
0075     exitcode=$?
0076     if [ $exitcode -ne 0 ]; then
0077         echo Command failed
0078         exit 1
0079     fi
0080 }
0081 
0082 
0083 
0084 # ---------------------------------------------------------
0085 #
0086 # checkout kstbinary
0087 #
0088 if [ $deploybinary -eq 1 ]; then
0089     if [ "$iam" = "$travis" ]; then
0090         cd ~
0091         tar xf $startdir/cmake/kstdeploy.tar.gz
0092         checkExitCode
0093     fi
0094 
0095     cd $startdir
0096     kstbinary=kst-build
0097     rm -rf $kstbinary
0098     mkdir $kstbinary
0099     cd $kstbinary
0100     git init --quiet
0101     git config user.name "travis"
0102     git config user.email travis@noreply.org
0103     git remote add origin git@github.com:Kst-plot/$kstbinary.git
0104     git fetch origin master --quiet
0105     checkExitCode
0106 fi
0107 cd $startdir
0108 
0109 
0110 # ---------------------------------------------------------
0111 #
0112 # get sha1 when git is used
0113 #
0114 sha1=`git rev-parse master`
0115 exitcode=$?
0116 
0117 if [ $exitcode -eq 0 ]; then
0118     rev="-Dkst_revision=$sha1"
0119 fi
0120 
0121 
0122 
0123 # ---------------------------------------------------------
0124 #
0125 # make build directory
0126 #
0127 cd ..
0128 if [ "$2" = "x64" ]; then
0129     build=_b_x64
0130 else
0131     build=_b_x86
0132 fi
0133 if [ -d "$build" ]; then
0134     echo Removing old build directory $build
0135     rm -rf $build
0136 fi
0137 mkdir $build
0138 builddir=$PWD/$build
0139 cd $builddir
0140 
0141 
0142 
0143 # ---------------------------------------------------------
0144 #
0145 # get actual cmake
0146 #
0147 cmakever=cmake-3.4.1-Linux-x86_64
0148 
0149 if [ "$iam" = "$travis" ]; then
0150     if [ ! -d $dep/$cmakever ]; then
0151           cmakebin=x
0152           if [ ! -d $dep/$cmakever ]; then
0153               wget --no-check-certificate http://www.cmake.org/files/v3.4/$cmakever.tar.gz
0154               checkExitCode
0155               cd $dep
0156               tar xf $builddir/$cmakever.tar.gz
0157               checkExitCode
0158               cd $builddir
0159           fi
0160     fi
0161     cmakebin=$dep/$cmakever/bin/cmake
0162 else
0163     cmakebin=cmake
0164 fi
0165 $cmakebin --version
0166 checkExitCode
0167 
0168 server=http://sourceforge.net/projects/kst/files/3rdparty
0169 
0170 #gccver=4.7.2
0171 if [ "$2" = "x64" ]; then
0172     win=win64
0173     mingw=x86_64-w64-mingw32
0174     branch=Kst-64bit-no-3rdparty-plugins-Qt5
0175     extlib=
0176     useext=
0177 else
0178     win=win32
0179     mingw=i686-w64-mingw32
0180     branch=Kst-32bit-3rdparty-plugins-Qt5
0181     exc=-dw2
0182     mingwdir=mingw32$exc
0183     extlib=kst-3rdparty-win32-gcc$exc-4.7.2
0184     extlib=kst-3rdparty-win32-gcc4.7
0185     useext=
0186     useext="-Dkst_3rdparty=1 -Dkst_3rdparty_dir=$dep/"$extlib
0187 fi
0188 
0189 if [ $downloadgcc ]; then
0190 
0191     gccver=4.7.2
0192     if [ "$2" = "x64" ]; then
0193         exc=-seh
0194         mingwdir=mingw64$exc
0195     else
0196         exc=-dw2
0197         mingwdir=mingw32$exc
0198     fi
0199 
0200     qtver=5.5.0
0201     qtver=Qt-$qtver-$win-g++-$mingw$exc-$gccver
0202     mingwver=$mingw-gcc$exc-$gccver
0203     
0204     # ---------------------------------------------------------
0205     #
0206     # download and install mingw
0207     #
0208 
0209     if [ ! -d $dep/$mingwdir ]; then
0210         mingwtar=$mingwver-Ubuntu64-12.04.tar
0211         wget $server/$mingwtar.xz
0212         checkExitCode
0213         xz -d $mingwtar.xz
0214         cd $dep
0215         tar xf $builddir/$mingwtar
0216         checkExitCode
0217         cd $builddir
0218     fi
0219     compiler=$dep/$mingwdir/bin/$mingw-gcc
0220     LTS=12.04
0221 else
0222     qtver=5.5.1
0223     qtver=Qt-$qtver-$mingw
0224     compiler=$mingw
0225     LTS=14.04
0226 fi
0227 echo Checking mingw installation ...
0228 $compiler-gcc -dumpversion
0229 checkExitCode
0230 
0231 
0232 # ---------------------------------------------------------
0233 #
0234 # download and install Qt
0235 #
0236 if [ ! -d $dep/$qtver ]; then
0237     qttar=$qtver-Ubuntu64-$LTS$tarver.tar
0238     wget $server/$qttar.xz
0239     checkExitCode
0240     xz -d $qttar.xz
0241     cd $dep
0242     tar xf $builddir/$qttar
0243     checkExitCode
0244     echo -e "[Paths]\nPrefix = $dep/$qtver" > $dep/$qtver/bin/qt.conf
0245     cd $builddir
0246 fi
0247 export PATH=$dep/$qtver/bin:$PATH
0248 echo Checking Qt installation ...
0249 which qmake
0250 checkExitCode
0251 
0252 
0253 
0254 # ---------------------------------------------------------
0255 #
0256 # download 3rdparty
0257 #
0258 if [ ! -d $dep/$extlib ]; then
0259     wget $server/$extlib.zip
0260     checkExitCode
0261     cd $dep
0262     unzip -q $builddir/$extlib.zip
0263     checkExitCode
0264     cd $builddir
0265     cp $dep/$extlib/include/matio_pubConf.h $dep/$extlib/include/matio_pubconf.h
0266 fi
0267 
0268 
0269 # ---------------------------------------------------------
0270 #
0271 # checkout translations
0272 #
0273 cd $startdir
0274 ./get-translations
0275 cd $builddir
0276 
0277 
0278 # ---------------------------------------------------------
0279 #
0280 # build Kst
0281 #
0282 qtopt="-Dkst_qt5=1"
0283 
0284 
0285 if [ $buildinstaller -eq 1 ]; then
0286     console=-Dkst_console=0
0287 else
0288     console=-Dkst_console=1
0289     noinstaller=-Dkst_noinstaller=1
0290 fi
0291 
0292 #$cmakebin ../kst \
0293 #    -Dkst_release=1  \
0294 #    -Dkst_version_string=$versionname \
0295 #    -Dkst_install_prefix=./$versionname \
0296 #    -Dkst_cross=$dep/$mingwdir/bin/$mingw \
0297 #    $rev $qtopt $useext $console $noinstaller $generator
0298 
0299 $cmakebin ../kst \
0300     -Dkst_release=1  \
0301     -Dkst_merge_files=1 \
0302     -Dkst_version_string=$versionname \
0303     -Dkst_install_prefix=./$versionname \
0304     -Dkst_cross=$compiler \
0305     $rev $qtopt $useext $console $noinstaller $generator
0306     
0307 checkExitCode
0308 
0309 
0310 $buildcmd_parallel
0311 checkExitCode
0312 
0313 
0314 # ---------------------------------------------------------
0315 #
0316 # deploy
0317 #
0318 $buildcmd package
0319 checkExitCode
0320 
0321 
0322 deploy() {
0323     if [ ! -e $1 ]; then
0324         exit 1
0325     fi
0326     cd $startdir/$kstbinary
0327     git checkout master
0328     git branch -D $2
0329     git checkout -b $2
0330     cp -f $builddir/$1 .
0331     checkExitCode
0332     git add $1
0333     checkExitCode
0334 
0335     git commit --quiet -m"Update $win binary to version $versionname"
0336     checkExitCode
0337 
0338     git push --quiet origin HEAD -f
0339     checkExitCode
0340 }
0341 
0342 
0343 if [ $deploybinary -eq 1 ]; then
0344     if [ $buildinstaller -eq 1 ]; then
0345         deploy $versionname-$win.exe Installer-$branch
0346     else
0347         deploy $versionname-$win.zip $branch
0348     fi
0349 fi
0350 
0351 
0352 cd $startdir
0353