User Tools

Site Tools


openvsp_build_script

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
openvsp_build_script [2019/11/11 11:37]
cibin Add build-script for Ubuntu
openvsp_build_script [2020/06/03 14:42] (current)
cibin Add verbose statements for location of deb package and build system used
Line 6: Line 6:
  
 ''​bash openvsp-build.sh''​. ''​bash openvsp-build.sh''​.
- + 
 +For a fully automated build using default settings that generates a deb package, use: 
 + 
 + ''​yes | bash openvsp-build.sh''​ 
 <​file>​ <​file>​
 #!/bin/bash #!/bin/bash
Line 17: Line 21:
 set -e set -e
  
-Get variables+Define usage for using with --help or -h 
 +if [ $# -ne 0 ]; then 
 +  if [ $1 == "​-h"​ ] || [ $1 == "​--help"​ ]; then 
 +    echo "​Usage:​ bash openvsp-build.sh"​ 
 +  fi 
 +fi 
 + 
 +# Set some variables 
 +VSPRepo=https://​github.com/​OpenVSP/​OpenVSP.git ​
 OpenVSPdir=$(pwd)/​OpenVSP OpenVSPdir=$(pwd)/​OpenVSP
 NumOfThreads=$(nproc) NumOfThreads=$(nproc)
-echo "Do you want to create ​a:" + 
-echo "[1Zip folder or+# Get some variables 
-echo "[2Deb package+echo "Create ​Deb package?:" 
-read -p "​Choice [1/2] : " -n 1 pkgChoice+echo "[yDeb package (default)
 +echo "[nZip folder
 +read -p "​Choice [Y/n] : " -n 1 pkgChoice
 pkgChoice=${pkgChoice:​-1} pkgChoice=${pkgChoice:​-1}
 +case $pkgChoice in 
 +  y|Y)  # DEB
 +    pkgGen="​DEB"​
 +    ;;
 +  n|N)  # ZIP
 +    pkgGen="​ZIP"​
 +    ;;
 +  *)  # Default choice
 +    pkgGen="​DEB"​
 +    ;;
 +esac
 echo echo
  
Line 32: Line 57:
 sudo apt-get install python3-dev git git-gui cmake libxml2-dev \ sudo apt-get install python3-dev git git-gui cmake libxml2-dev \
   libfltk1.3-dev g++ libjpeg-dev libglm-dev libcminpack-dev \   libfltk1.3-dev g++ libjpeg-dev libglm-dev libcminpack-dev \
-  libglew-dev swig doxygen graphviz texlive-latex-base+  libglew-dev swig doxygen graphviz texlive-latex-base ​ninja-build
  
-# Create temporary directories ​for build+# Create temporary directories ​if not present
 echo echo
 echo "​Creating temporary directories ..." echo "​Creating temporary directories ..."
-mkdir -p OpenVSP +mkdir -p $OpenVSPdir 
-mkdir -p $OpenVSPdir/​build $OpenVSPdir/​buildlibs ​$OpenVSPdir/​repo +mkdir -p $OpenVSPdir/​build $OpenVSPdir/​buildlibs
-git clone --depth=1 https://​github.com/​OpenVSP/​OpenVSP.git $OpenVSPdir/​repo+
  
-# Build libraries+# Download source into temporary repo directory if absent 
 +echo 
 +echo "​Downloading OpenVSP source from GitHub ..." 
 +[ -d $OpenVSPdir/​repo ] || git clone --depth=1 $VSPRepo $OpenVSPdir/​repo 
 +cd $OpenVSPdir/​repo;​ git pull $VSPRepo 
 + 
 +# Build using Ninja since it's faster. 
 +# Fallback to Make if errors occur
 echo echo
 echo "​Building libraries ..." echo "​Building libraries ..."
-cd $OpenVSPdir/​buildlibs && ​+rm -rf $OpenVSP/​buildlibs/​* 
 +{ echo "Build using Ninja" &&​ 
 +  cd $OpenVSPdir/​buildlibs &&  
 +  cmake -G "​Ninja"​ \ 
 +  -DVSP_USE_SYSTEM_LIBXML2=true \ 
 +  -DVSP_USE_SYSTEM_FLTK=true \ 
 +  -DVSP_USE_SYSTEM_GLM=true \ 
 +  -DVSP_USE_SYSTEM_GLEW=true \ 
 +  -DVSP_USE_SYSTEM_CMINPACK=true \ 
 +  -DVSP_USE_SYSTEM_LIBIGES=false \ 
 +  -DVSP_USE_SYSTEM_EIGEN=false \ 
 +  -DVSP_USE_SYSTEM_CODEELI=false \ 
 +  -DVSP_USE_SYSTEM_CPPTEST=false \ 
 +  $OpenVSPdir/​repo/​Libraries -DCMAKE_BUILD_TYPE=Release &&​ 
 +  ninja 
 +} || {  
 +  echo "Build using Make" &&​ 
 +  ​cd $OpenVSPdir/​buildlibs && ​
   cmake \   cmake \
   -DVSP_USE_SYSTEM_LIBXML2=true \   -DVSP_USE_SYSTEM_LIBXML2=true \
Line 57: Line 105:
   $OpenVSPdir/​repo/​Libraries -DCMAKE_BUILD_TYPE=Release &&   $OpenVSPdir/​repo/​Libraries -DCMAKE_BUILD_TYPE=Release &&
   make -j $NumOfThreads   make -j $NumOfThreads
 +}
  
 # Build source # Build source
 echo echo
 echo "​Building source ..." echo "​Building source ..."
-case $pkgChoice in  +rm -rf $OpenVSPdir/​build/​* 
-  ​1)  # ZIP +# Build using Ninja since it's faster. 
-    cd $OpenVSPdir/​build &&​ +# Fallback to Make if errors occur 
-      cmake ../​repo/​src/​ \ +{ echo "Build using Ninja" && 
-      -DVSP_LIBRARY_PATH=$OpenVSPdir/​buildlibs \ +  ​cd $OpenVSPdir/​build &&​ 
-      -DCMAKE_BUILD_TYPE=Release &&​ +  cmake -G "​Ninja"​ ../​repo/​src/​ \ 
-      make -j $NumOfThreads package &&​ +  ​-DVSP_LIBRARY_PATH=$OpenVSPdir/​buildlibs \ 
-      cp *.zip $OpenVSPdir/​+  -DCMAKE_BUILD_TYPE=Release \ 
 +  -DVSP_CPACK_GEN=$pkgGen &&​ 
 +  ninja package &&​ 
 +  cp *.deb $OpenVSPdir/​ 
 +} || { 
 +  echo "Build using Make" &&​ 
 +  ​cd $OpenVSPdir/​build ​&& rm -f $OpenVSPdir/​build/​* ​&&​ 
 +  cmake ../​repo/​src/​ \ 
 +  -DVSP_LIBRARY_PATH=$OpenVSPdir/​buildlibs \ 
 +  -DCMAKE_BUILD_TYPE=Release ​
 +  -DVSP_CPACK_GEN=$pkgGen ​&&​ 
 +  make -j $NumOfThreads package &&​ 
 +  cp *.deb $OpenVSPdir/​ 
 +
 + 
 +echo 
 +echo "​Removing temporary directories ..." 
 +echo "​Remove temporary directories?:"​ 
 +echo "[y] Remove (default)"​ 
 +echo "[n] Do not remove"​ 
 +read -p "​Choice [Y/n] : " -n 1 rmChoice 
 +rmChoice=${rmChoice:​-1} 
 +case $rmChoice in 
 +  y|Y) # Remove all 
 +    rm -rf $OpenVSPdir/​build* $OpenVSPdir/​repo
     ;;     ;;
-  ​2 DEB +  ​n|N) # Do not remove
-    cd $OpenVSPdir/​build &&​ +
-      cmake ../​repo/​src/​ \ +
-      -DVSP_LIBRARY_PATH=$OpenVSPdir/​buildlibs \ +
-      -DCMAKE_BUILD_TYPE=Release \ +
-      -DVSP_CPACK_GEN=DEB &&​ +
-      make -j $NumOfThreads package &&​ +
-      cp *.deb $OpenVSPdir/​+
     ;;     ;;
-  *)  # Wrong choice +  *)  # Default ​choice 
-    ​echo "​ERROR:​ Wrong package choice"​ +    ​rm -rf $OpenVSPdir/​build* $OpenVSPdir/​repo
-    exit 1+
     ;;     ;;
 esac esac
- 
-# Remove unnecessary temporary directories 
-echo 
-echo "​Removing temporary directories ..." 
-rm -rf $OpenVSPdir/​build* $OpenVSPdir/​repo 
  
 echo  echo 
 echo "​OpenVSP build successfull!"​ echo "​OpenVSP build successfull!"​
 +echo "Deb package created in directory: $OpenVSPdir/"​
 </​file>​ </​file>​
openvsp_build_script.1573501078.txt.gz · Last modified: 2019/11/11 11:37 by cibin