/work/se_make.sh
Shell | 193 lines | 155 code | 10 blank | 28 comment | 25 complexity | 4a9698b06ec67b9391389b0b51b2afbf MD5 | raw file
1#!/usr/bin/env bash 2#-- 3#-- This file is part of SmartEiffel The GNU Eiffel Compiler Tools and Libraries. 4#-- See the Copyright notice at the end of this file. 5#-- 6# 7# Use this script to install a tool in SE_BIN. 8# 9# Usage: se make <tool> <options>... 10# 11 12CHECK_LEVEL=-require_check 13DIR=require 14DEBUG=false 15SEDB=false 16NOGC=false 17BDWGC=false 18OPTIONS='' 19TOOL=compile_to_c 20BUILD=true 21GDB=false 22VALGRIND=false 23CC= 24 25SE_BIN=$(grep ^bin: $HOME/.config/liberty-eiffel/liberty.se | cut -c6-) 26 27while [ $# -gt 0 ]; do 28 case x"$1" in 29 x-no_check|x--no_check|x/no_check) 30 CHECK_LEVEL=$1 31 DIR=no 32 ;; 33 x-require_check|x--require_check|x/require_check) 34 CHECK_LEVEL=$1 35 DIR=require 36 ;; 37 x-ensure_check|x--ensure_check|x/ensure_check) 38 CHECK_LEVEL=$1 39 DIR=ensure 40 ;; 41 x-invariant_check|x--invariant_check|x/invariant_check) 42 CHECK_LEVEL=$1 43 DIR=invariant 44 ;; 45 x-loop_check|x--loop_check|x/loop_check) 46 CHECK_LEVEL=$1 47 DIR=loop 48 ;; 49 x-all_check|x--all_check|x/all_check) 50 CHECK_LEVEL=$1 51 DIR=all 52 ;; 53 x-boost|x--boost|x/boost) 54 CHECK_LEVEL=$1 55 DIR=boost 56 ;; 57 x-debug|x--debug|x/debug) 58 DEBUG=true 59 OPTIONS="$OPTIONS $1" 60 ;; 61 x-sedb|x--sedb|x/sedb) 62 SEDB=true 63 OPTIONS="$OPTIONS $1" 64 ;; 65 x-no_gc|x--no_gc|x/no_gc) 66 NOGC=true 67 OPTIONS="$OPTIONS $1" 68 ;; 69 x-bdw_gc|x--bdw_gc|x/bdw_gc) 70 BDWGC=true 71 OPTIONS="$OPTIONS $1" 72 ;; 73 x-no_build|x--no_build|x/no_build) 74 BUILD=false 75 ;; 76 x-gdb|x--gdb|x/gdb) 77 GDB=true 78 ;; 79 x-valgrind|x--valgrind|x/valgrind) 80 VALGRIND=true 81 ;; 82 x-version|x--version|x/version|x-v|x--v|x/v) 83 $SE_BIN/compile_to_c $1 84 exit 0 85 ;; 86 x-c_mode) 87 OPTIONS="$OPTIONS -c_mode $2" 88 shift 89 ;; 90 x-cc) 91 OPTIONS="$OPTIONS -cc $2" 92 CC=$2 93 shift 94 ;; 95 x-*|x/*) 96 OPTIONS="$OPTIONS $1" 97 ;; 98 *) 99 TOOL=$1 100 ;; 101 esac 102 shift 103done 104 105outdir=$SE_BIN/.make/$TOOL/$DIR 106if $DEBUG; then 107 outdir=${outdir}.debug 108fi 109if $SEDB; then 110 outdir=${outdir}.sedb 111fi 112if $NOGC; then 113 outdir=${outdir}.no_gc 114fi 115if $BDWGC; then 116 outdir=${outdir}.bdw_gc 117fi 118if [[ -n "$CC" ]]; then 119 outdir=${outdir}.cc\=$CC 120fi 121 122if $GDB && $VALGRIND; then 123 echo "Cannot use gdb and valgrind at the same time!" >&2 124 exit 1 125fi 126 127test -d $outdir || mkdir -p $outdir 128cd $outdir 129 130if $BUILD; then 131 test -d old && rm -rf old 132 if [ -d new ]; then 133 mkdir old 134 ln new/$TOOL* old/ 135 else 136 mkdir new 137 fi 138 cd new 139 echo "Compiling $TOOL..." 140 if $GDB; then 141 gdb --args $SE_BIN/compile_to_c $OPTIONS -split by_type $CHECK_LEVEL $TOOL -o $TOOL.out || exit 1 142 if [ -e $TOOL.make ]; then 143 while read cmd; do 144 echo "$cmd" 145 eval "$cmd" || exit 1 146 done < $TOOL.make 147 fi 148 elif $VALGRIND; then 149 valgrind $SE_BIN/compile_to_c $OPTIONS -split by_type $CHECK_LEVEL $TOOL -o $TOOL.out || exit 1 150 if [ -e $TOOL.make ]; then 151 while read cmd; do 152 echo "$cmd" 153 eval "$cmd" || exit 1 154 done < $TOOL.make 155 fi 156 else 157 echo $SE_BIN/se compile $OPTIONS -split by_type $CHECK_LEVEL $TOOL -o $TOOL.out 158 $SE_BIN/se compile $OPTIONS -split by_type $CHECK_LEVEL $TOOL -o $TOOL.out || exit 1 159 fi 160else 161 test -d new || mkdir new 162 cd new 163fi 164 165if [ -e $TOOL.out ]; then 166 echo "Copying $TOOL..." 167 test -e $SE_BIN/$TOOL && /bin/mv $SE_BIN/$TOOL $SE_BIN/$TOOL.old 168 ln $TOOL.out $SE_BIN/$TOOL 169else 170 echo "**** $TOOL was not compiled. Keeping the older version." 2>&1 171 exit 1 172fi 173 174echo "Done." 175 176#-- 177#-- ------------------------------------------------------------------------------------------------------------------------------ 178#-- Copyright notice below. Please read. 179#-- 180#-- SmartEiffel is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, 181#-- as published by the Free Software Foundation; either version 2, or (at your option) any later version. 182#-- SmartEiffel is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty 183#-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have 184#-- received a copy of the GNU General Public License along with SmartEiffel; see the file COPYING. If not, write to the Free 185#-- Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 186#-- 187#-- Copyright(C) 1994-2002: INRIA - LORIA (INRIA Lorraine) - ESIAL U.H.P. - University of Nancy 1 - FRANCE 188#-- Copyright(C) 2003-2006: INRIA - LORIA (INRIA Lorraine) - I.U.T. Charlemagne - University of Nancy 2 - FRANCE 189#-- 190#-- Authors: Dominique COLNET, Philippe RIBET, Cyril ADRIAN, Vincent CROIZIER, Frederic MERIZEN 191#-- 192#-- http://SmartEiffel.loria.fr - SmartEiffel@loria.fr 193#-- ------------------------------------------------------------------------------------------------------------------------------