[412] | 1 | #! /bin/sh |
---|
| 2 | #+ |
---|
| 3 | # |
---|
| 4 | # NAME |
---|
| 5 | # ==== |
---|
| 6 | # |
---|
| 7 | # docompileall.sh - compile all IDL modules which define PRO or FUNCTION |
---|
| 8 | # |
---|
| 9 | # SYNOPSIS |
---|
| 10 | # ======== |
---|
| 11 | # |
---|
| 12 | # :: |
---|
| 13 | # |
---|
| 14 | # $ docompileall.sh -i indir |
---|
| 15 | # |
---|
| 16 | # DESCRIPTION |
---|
| 17 | # =========== |
---|
| 18 | # |
---|
| 19 | # ``docompileall.sh`` scans indir to find .pro files which define PRO or FUNCTION. |
---|
| 20 | # |
---|
| 21 | # -i directory input |
---|
| 22 | # |
---|
| 23 | # On each file found, idl is asked to ++ compile. |
---|
| 24 | # |
---|
| 25 | # By default, indir is the current directory. |
---|
| 26 | # |
---|
| 27 | # CAUTIONS |
---|
| 28 | # ======== |
---|
| 29 | # |
---|
| 30 | # SAXO_DIR must be set. The value should be the directory where |
---|
| 31 | # SAXO is available. |
---|
| 32 | # |
---|
| 33 | # for example, if you work at LOCEAN and work with default SAXO, |
---|
| 34 | # SAXO_DIR=/usr/home/smasson/SAXO_DIR/. |
---|
| 35 | # |
---|
| 36 | # For working in progress, you should checkout SAXO on a personnal |
---|
| 37 | # directory and set SAXO_DIR to the working space. |
---|
| 38 | # |
---|
| 39 | # example for me : SAXO_DIR=${HOME}/SAXO_DIR_ws/ |
---|
| 40 | |
---|
| 41 | # EXAMPLES |
---|
| 42 | # ======== |
---|
| 43 | # |
---|
| 44 | # For SAXO in working space ${HOME}/SAXO_DIR_ws/ : |
---|
| 45 | # |
---|
| 46 | # :: |
---|
| 47 | # |
---|
| 48 | # $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i ${HOME}/SAXO_DIR_ws/ |
---|
| 49 | # |
---|
| 50 | # For VARAMMA in working space /usr/home/fplod/incas/varamma/varamma_ws/ |
---|
| 51 | # |
---|
| 52 | # :: |
---|
| 53 | # |
---|
| 54 | # $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/home/fplod/incas/varamma/varamma_ws/ |
---|
| 55 | # |
---|
| 56 | # |
---|
| 57 | # For POST_IT in working space /usr/home/fplod/incas/post_it/post_it_ws/ |
---|
| 58 | # |
---|
| 59 | # :: |
---|
| 60 | # |
---|
| 61 | # $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/home/fplod/incas/post_it/post_it_ws/ |
---|
| 62 | # |
---|
| 63 | # TODO |
---|
| 64 | # ==== |
---|
| 65 | # |
---|
| 66 | # exclude .svn directory in find command |
---|
| 67 | # |
---|
| 68 | # better handling on DEMO mode (ie information cant check) |
---|
| 69 | # |
---|
| 70 | # EVOLUTIONS |
---|
| 71 | # ========== |
---|
| 72 | # |
---|
| 73 | # $Id$ |
---|
| 74 | # |
---|
| 75 | # - fplod 20091110T134500Z aedon.locean-ipsl.upmc.fr (Darwin) |
---|
| 76 | # |
---|
| 77 | # * creation from savesaxo.sh docompileall part |
---|
| 78 | # * make it work from anywhere |
---|
| 79 | # |
---|
| 80 | #- |
---|
| 81 | # |
---|
| 82 | system=$(uname) |
---|
| 83 | case "${system}" in |
---|
| 84 | AIX|IRIX64) |
---|
| 85 | echo " www : no specific posix checking" |
---|
| 86 | ;; |
---|
| 87 | *) |
---|
| 88 | set -o posix |
---|
| 89 | ;; |
---|
| 90 | esac |
---|
| 91 | command=$(basename ${0}) |
---|
| 92 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
| 93 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
| 94 | # |
---|
| 95 | usage=" Usage : ${command} -i indir" |
---|
| 96 | # |
---|
| 97 | minargcount=0 #++ |
---|
| 98 | #echo " narg ${#}" |
---|
| 99 | if [ ${#} -lt ${minargcount} ] |
---|
| 100 | then |
---|
| 101 | echo "eee : not enought arguments (${#} vs ${minargcount})" |
---|
| 102 | echo "${usage}" |
---|
| 103 | exit 1 |
---|
| 104 | fi |
---|
| 105 | # |
---|
| 106 | # default |
---|
| 107 | # default IDL command and directory |
---|
| 108 | idl_command=$(which idl) |
---|
| 109 | idl_dir=$(dirname ${idl_command}) |
---|
| 110 | # |
---|
| 111 | # default indir directory |
---|
| 112 | indir=$(pwd) |
---|
| 113 | # |
---|
| 114 | # read parameters on command line |
---|
| 115 | while [ ! -z "${1}" ] |
---|
| 116 | do |
---|
| 117 | case ${1} in |
---|
| 118 | -i) |
---|
| 119 | indir=${2} |
---|
| 120 | shift |
---|
| 121 | ;; |
---|
| 122 | -h) |
---|
| 123 | echo "${usage}" |
---|
| 124 | exit 0 |
---|
| 125 | ;; |
---|
| 126 | *) # other choice |
---|
| 127 | echo "${usage}" |
---|
| 128 | exit 1 |
---|
| 129 | ;; |
---|
| 130 | esac |
---|
| 131 | shift # next flag |
---|
| 132 | done |
---|
| 133 | # |
---|
| 134 | set -u |
---|
| 135 | # |
---|
| 136 | # test in ${indir} exist |
---|
| 137 | if [ ! -d ${indir} ] |
---|
| 138 | then |
---|
| 139 | echo "eee : ${indir} not found" |
---|
| 140 | exit 1 |
---|
| 141 | fi |
---|
| 142 | # |
---|
| 143 | cat <<EOF > /tmp/docompileall${$}.pro |
---|
| 144 | ; test DEMO mode |
---|
| 145 | demo_on=LMGR(/DEMO) |
---|
| 146 | IF demo_on EQ 1 THEN BEGIN |
---|
| 147 | exit |
---|
| 148 | ENDIF |
---|
| 149 | .reset_session |
---|
| 150 | ; |
---|
| 151 | !path = expand_path('+' + '${SAXO_DIR}/SRC/') + ':' + expand_path('+' + !dir) |
---|
| 152 | resolve_all, resolve_either='def_myuniquetmpdir', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
| 153 | resolve_all, resolve_either = 'find', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
| 154 | def_myuniquetmpdir |
---|
| 155 | oldcm = find('oldcm_empty') |
---|
| 156 | ;oldcm = find('oldcm_full') |
---|
| 157 | oldcm = oldcm[0] |
---|
| 158 | @cm_general |
---|
| 159 | file_copy, oldcm, myuniquetmpdir + 'oldcm_used.pro', /overwrite |
---|
| 160 | !path = myuniquetmpdir + ':' + !path |
---|
| 161 | IF !journal NE 0 THEN journal |
---|
| 162 | journal, myuniquetmpdir + 'cm_demomode_used.pro' |
---|
| 163 | journal |
---|
| 164 | path_cache, /rebuild |
---|
| 165 | ; |
---|
| 166 | resolve_all, resolve_either='keep_compatibility', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
| 167 | ; |
---|
| 168 | EOF |
---|
| 169 | # |
---|
| 170 | more /tmp/docompileall${$}.pro |
---|
| 171 | read a |
---|
| 172 | # find .pro files |
---|
| 173 | list_files=$(find ${indir} -name "*.pro" | grep -iv label_gmt | grep -iv report) |
---|
| 174 | # |
---|
| 175 | # check if at least one file found |
---|
| 176 | if [ "${list_files}" = "" ] |
---|
| 177 | then |
---|
| 178 | echo "eee : no . pro files found under ${indir}" |
---|
| 179 | exit 1 |
---|
| 180 | fi |
---|
| 181 | # |
---|
| 182 | # loop on each file in the list to select PRO and FUNCTION modules |
---|
| 183 | # ie exclude common files |
---|
| 184 | for i in ${list_files} |
---|
| 185 | do |
---|
| 186 | # does it contains pro or function ? |
---|
| 187 | egrep -iq '^ * *(pro|function)' ${i} |
---|
| 188 | if [ ${?} -eq 0 ] |
---|
| 189 | then |
---|
| 190 | echo "print, '$( basename ${i} .pro ) :'" >> /tmp/docompileall${$}.pro |
---|
| 191 | echo "resolve_all, resolve_either = '$( basename ${i} .pro )', skip_routines = ['xxx2ps','trends', 'label_gmt', 'report']" >> /tmp/docompileall${$}.pro |
---|
| 192 | fi |
---|
| 193 | done |
---|
| 194 | echo "exit" >> /tmp/docompileall${$}.pro |
---|
| 195 | # |
---|
| 196 | IDL_STARTUP=/tmp/docompileall${$}.pro |
---|
| 197 | ${idl_command} &> /tmp/docompileallerr_${$} |
---|
| 198 | grep -i "error" /tmp/docompileallerr_${$} |
---|
| 199 | # grep -q "Compilation error(s)" /tmp/docompileallerr_${$} |
---|
| 200 | if [ ${?} -ne 0 ] |
---|
| 201 | then |
---|
| 202 | echo "all files are OK" |
---|
| 203 | # clean |
---|
| 204 | rm -f /tmp/docompileallerr_${$} /tmp/docompileall${$}.pro |
---|
| 205 | else |
---|
| 206 | grep "Compilation error(s)" /tmp/docompileallerr_${$} |
---|
| 207 | echo "eee : see /tmp/docompileallerr_${$}" |
---|
| 208 | more /tmp/docompileallerr_${$} |
---|
| 209 | exit 1 |
---|
| 210 | fi |
---|
| 211 | |
---|
| 212 | # end |
---|
| 213 | exit 0 |
---|