Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Optimize: do not rebuild from scratch when something already exists
[simgrid.git] / buildtools / Cmake / cmake_simgrid.conf
index 5a4661f..da0d7e3 100644 (file)
@@ -5,4 +5,85 @@
 SIMGRID_SVN_ROOT=~/simgrid-svn
 
 # Root of build directories and so on
-SIMGRID_BASEDIR=~/simgrid
\ No newline at end of file
+SIMGRID_BASEDIR=~/simgrid
+
+
+
+############ Do not change anything below, unless your first name is Martin or Pierre ##############
+
+# get_version: define the version number of the svn into a version variable
+get_version() {
+  if [ x$version = x ] ; then
+    cd ${SIMGRID_SVN_ROOT}
+    svn up
+    version="simgrid-3.3.4-svn-r"`svnversion`
+    export version
+  fi
+}
+
+# wait_archive: wait until the archive gets defined into the right position
+wait_archive() {
+  while [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; do
+    echo ${SIMGRID_BASEDIR}/${version}.tar.gz not found. Wait five seconds.
+    sleep 5
+  done
+}
+
+# make_dist: rebuild an archive from the svn
+make_dist() {
+  get_version
+  if [ ! -e ${SIMGRID_BASEDIR}/${version}.tar.gz ] ; then
+    cd ${SIMGRID_BASEDIR}
+    echo "rebuild the missing files for compilation"
+    if [ ! -e configure ] ; then
+      ./bootstrap
+    fi
+    if [ ! -e Makefile ] ; then
+       # Disable compilation optim to make it built faster
+       ./configure --enable-maintainer-mode --disable-compile-optimizations
+    fi
+    echo "Make the archive"
+    make all dist
+
+    echo "Copy the archive in position"
+    mkdir -p ${SIMGRID_BASEDIR}
+    mv ${version}.tar.gz ${SIMGRID_BASEDIR}
+  else
+    echo "${SIMGRID_BASEDIR}/${version}.tar.gz already exists. Don't rebuild"
+  fi
+}
+
+# clean_node: remove everything about this node
+clean_node() {
+  OS=`uname`
+  node=`uname -n`
+  # OS specific working directory 
+  BUILDDIR=${SIMGRID_BASEDIR}/$OS/$node/$version
+  export BUILDDIR
+  
+  # Clean any leftover from previous install
+  if [ -e $BUILDDIR ] ; then
+    echo "remove old directory $BUILDDIR"
+    rm -rf $BUILDDIR
+  fi
+  mkdir -p $BUILDDIR
+}
+
+# open_archive: wait for archive to be built, cleanup previous
+open_archive() {
+  get_version
+  clean_node
+  wait_archive
+  cd $BUILDDIR/..
+  tar xfz ${SIMGRID_BASEDIR}/${version}.tar.gz
+}
+
+
+# build_from_autotools: build the archive using the autotools
+# expects: the archive opened in the right position
+build_from_autotools() {
+  open_archive
+  cd $BUILDDIR
+  ./configure $@
+  make
+}
\ No newline at end of file