source: trunk/SRC/Documentation/xmldoc/docompileall.sh @ 415

Last change on this file since 415 was 415, checked in by pinsard, 15 years ago

documentations tools improvements

  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
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 -idl_dir idl_dir
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/SRC/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/
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/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/
55#
56#
57# For POST_IT in working space /usr/home/fplod/incas/post_it/post_it_ws/
58# with IDL 6.4
59#
60# ::
61#
62# $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/home/fplod/incas/post_it/post_it_ws/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/
63#
64# For POST_IT in working space /usr/home/fplod/incas/post_it/post_it_ws/
65# with IDL 7.0
66#
67# ::
68#
69# $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/home/fplod/incas/post_it/post_it_ws/ -idl_dir /usr/local_linux/idl/idl70/
70#
71# TODO
72# ====
73#
74# exclude .svn directory in find command
75#
76# better handling on DEMO mode (ie information cant check)
77#       
78# be less sensible to multiple / and trailing / in indir and SAXO_DIR when
79# compare
80#
81# add a parameter excludedir to exclude unwanted files like ./tools/ in POST_IT.#
82# EVOLUTIONS
83# ==========
84#
85# $Id$
86#
87# - fplod 20091116T142010Z aedon.locean-ipsl.upmc.fr (Darwin)
88#   
89#   * remove dup if only SAXO
90#
91# - fplod 20091113T151637Z aedon.locean-ipsl.upmc.fr (Darwin)
92#
93#   * idl_dir in parameter
94#
95# - fplod 20091110T134500Z aedon.locean-ipsl.upmc.fr (Darwin)
96#
97#   * creation from savesaxo.sh docompileall part
98#   * make it work from anywhere
99#
100#-
101#
102system=$(uname)
103case "${system}" in
104 AIX|IRIX64)
105 echo " www : no specific posix checking"
106 ;;
107 *)
108 set -o posix
109 ;;
110esac
111command=$(basename ${0})
112log_date=$(date -u +"%Y%m%dT%H%M%SZ")
113log=/tmp/$(basename ${command} .sh).log.${log_date}
114#
115usage=" Usage : ${command} -i indir -idl_dir idl_dir"
116#
117minargcount=4 #++
118#echo " narg ${#}"
119if [ ${#} -lt ${minargcount} ]
120then
121 echo "eee : not enought arguments (${#} vs ${minargcount})"
122 echo "${usage}"
123 exit 1
124fi
125#
126# default
127# default IDL command and directory
128#idl_dir=/usr/local_linux/idl/idl64/ # overriding idl_dir for test ++
129#
130# default indir directory
131indir=$(pwd)
132#
133# read parameters on command line
134while [ ! -z "${1}" ]
135do
136 case ${1} in
137 -i)
138 indir=${2}
139 shift
140 ;;
141 -idl_dir)
142 idl_dir=${2}
143 shift
144 ;;
145 -h)
146 echo "${usage}"
147 exit 0
148 ;;
149 *) # other choice
150 echo "${usage}"
151 exit 1
152 ;;
153 esac
154 shift # next flag
155done
156#
157set -u
158#
159# test in ${indir} exist
160if [ ! -d ${indir} ]
161then
162 echo "eee : ${indir} not found"
163 exit 1
164fi
165#
166# ++ test si IDL (car GDL inutilisable)
167application=${idl_dir}/bin/idl
168#
169# start to write IDL commands file
170cat <<EOF > /tmp/docompileall${$}.pro
171.reset_session
172;
173; Add SAXO sources to IDL path
174!path = expand_path('+' + '${SAXO_DIR}/SRC/') + ':' + expand_path('+' + !dir)
175EOF
176#
177# if indir is equal to SAXO_DIR/SRC there is no need to add it in IDL path
178if [ "${indir}" != "${SAXO_DIR}/SRC/" ]
179then
180 cat <<EOF >> /tmp/docompileall${$}.pro
181!path = expand_path('+' + '${indir}') + ':' + !path
182EOF
183fi
184#
185cat <<EOF >> /tmp/docompileall${$}.pro
186resolve_all, resolve_either='def_myuniquetmpdir', skip_routines = ['xxx2ps','trends', 'label_gmt']
187resolve_all, resolve_either = 'find', skip_routines = ['xxx2ps','trends', 'label_gmt']
188def_myuniquetmpdir
189oldcm = find('oldcm_empty')
190;oldcm = find('oldcm_full')
191oldcm = oldcm[0]
192@cm_general
193file_copy, oldcm, myuniquetmpdir + 'oldcm_used.pro', /overwrite
194!path = myuniquetmpdir + ':' + !path
195IF !journal NE 0 THEN journal
196journal, myuniquetmpdir + 'cm_demomode_used.pro'
197journal
198path_cache, /rebuild
199;
200resolve_all, resolve_either='keep_compatibility', skip_routines = ['xxx2ps','trends', 'label_gmt']
201;
202EOF
203#
204# find .pro files
205list_files=$(find ${indir} -name "*.pro" | grep -iv label_gmt | grep -iv report)
206#
207# check if at least one file found
208if [ "${list_files}" = "" ]
209then
210 echo "eee : no . pro files found under ${indir}"
211 exit 1
212fi
213#
214# loop on each file in the list to select PRO and FUNCTION modules
215# ie exclude common files
216for i in ${list_files}
217do
218 # does it contains pro or function ?
219 egrep -iq '^ * *(pro|function)' ${i}
220 if [ ${?} -eq 0 ]
221 then
222  echo "print, '$( basename ${i} .pro ) :'" >> /tmp/docompileall${$}.pro
223  echo "resolve_all, resolve_either = '$( basename ${i} .pro )', skip_routines = ['xxx2ps','trends', 'label_gmt', 'report']" >> /tmp/docompileall${$}.pro
224 fi
225done
226echo "exit" >> /tmp/docompileall${$}.pro
227#
228#more /tmp/docompileall${$}.pro
229export IDL_STARTUP=/tmp/docompileall${$}.pro
230${application} &> /tmp/docompileallerr_${$}
231grep -i "error" /tmp/docompileallerr_${$}
232# grep -q "Compilation error(s)" /tmp/docompileallerr_${$}
233if [ ${?} -ne 0 ]
234then
235 echo "all files are OK"
236 # clean
237 rm -f /tmp/docompileallerr_${$} /tmp/docompileall${$}.pro
238else
239 grep "Compilation error(s)" /tmp/docompileallerr_${$}
240 echo "eee : see /tmp/docompileallerr_${$}"
241 more /tmp/docompileallerr_${$}
242 exit 1
243fi
244
245# end
246exit 0
Note: See TracBrowser for help on using the repository browser.