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/lodyc/incas/fplod/post_it_ws/ |
---|
58 | # with IDL 6.4 |
---|
59 | # |
---|
60 | # :: |
---|
61 | # |
---|
62 | # $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/lodyc/incas/fplod/post_it_ws/ -idl_dir /usr/local_linux/idl/idl_6.4/idl/ |
---|
63 | # |
---|
64 | # For POST_IT in working space /usr/lodyc/incas/fplod/post_it_ws/ |
---|
65 | # with IDL 7.0 |
---|
66 | # |
---|
67 | # :: |
---|
68 | # |
---|
69 | # $ ${SAXO_DIR}/SRC/Documentation/xmldoc/docompileall.sh -i /usr/lodyc/incas/fplod/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 | # |
---|
102 | system=$(uname) |
---|
103 | case "${system}" in |
---|
104 | AIX|IRIX64) |
---|
105 | echo " www : no specific posix checking" |
---|
106 | ;; |
---|
107 | *) |
---|
108 | set -o posix |
---|
109 | ;; |
---|
110 | esac |
---|
111 | command=$(basename ${0}) |
---|
112 | log_date=$(date -u +"%Y%m%dT%H%M%SZ") |
---|
113 | log=/tmp/$(basename ${command} .sh).log.${log_date} |
---|
114 | # |
---|
115 | usage=" Usage : ${command} -i indir -idl_dir idl_dir" |
---|
116 | # |
---|
117 | minargcount=4 #++ |
---|
118 | #echo " narg ${#}" |
---|
119 | if [ ${#} -lt ${minargcount} ] |
---|
120 | then |
---|
121 | echo "eee : not enought arguments (${#} vs ${minargcount})" |
---|
122 | echo "${usage}" |
---|
123 | exit 1 |
---|
124 | fi |
---|
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 |
---|
131 | indir=$(pwd) |
---|
132 | # |
---|
133 | # read parameters on command line |
---|
134 | while [ ! -z "${1}" ] |
---|
135 | do |
---|
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 |
---|
155 | done |
---|
156 | # |
---|
157 | set -u |
---|
158 | # |
---|
159 | # test in ${indir} exist |
---|
160 | if [ ! -d ${indir} ] |
---|
161 | then |
---|
162 | echo "eee : ${indir} not found" |
---|
163 | exit 1 |
---|
164 | fi |
---|
165 | # |
---|
166 | # ++ test si IDL (car GDL inutilisable) |
---|
167 | application=${idl_dir}/bin/idl |
---|
168 | # |
---|
169 | # start to write IDL commands file |
---|
170 | cat <<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) |
---|
175 | EOF |
---|
176 | # |
---|
177 | # if indir is equal to SAXO_DIR/SRC there is no need to add it in IDL path |
---|
178 | if [ "${indir}" != "${SAXO_DIR}/SRC/" ] |
---|
179 | then |
---|
180 | cat <<EOF >> /tmp/docompileall${$}.pro |
---|
181 | !path = expand_path('+' + '${indir}') + ':' + !path |
---|
182 | EOF |
---|
183 | fi |
---|
184 | # |
---|
185 | cat <<EOF >> /tmp/docompileall${$}.pro |
---|
186 | resolve_all, resolve_either='def_myuniquetmpdir', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
187 | resolve_all, resolve_either = 'find', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
188 | def_myuniquetmpdir |
---|
189 | oldcm = find('oldcm_empty') |
---|
190 | ;oldcm = find('oldcm_full') |
---|
191 | oldcm = oldcm[0] |
---|
192 | @cm_general |
---|
193 | file_copy, oldcm, myuniquetmpdir + 'oldcm_used.pro', /overwrite |
---|
194 | !path = myuniquetmpdir + ':' + !path |
---|
195 | IF !journal NE 0 THEN journal |
---|
196 | journal, myuniquetmpdir + 'cm_demomode_used.pro' |
---|
197 | journal |
---|
198 | path_cache, /rebuild |
---|
199 | ; |
---|
200 | resolve_all, resolve_either='keep_compatibility', skip_routines = ['xxx2ps','trends', 'label_gmt'] |
---|
201 | ; |
---|
202 | EOF |
---|
203 | # |
---|
204 | # find .pro files |
---|
205 | list_files=$(find ${indir} -name "*.pro" | grep -iv label_gmt | grep -iv report) |
---|
206 | # |
---|
207 | # check if at least one file found |
---|
208 | if [ "${list_files}" = "" ] |
---|
209 | then |
---|
210 | echo "eee : no . pro files found under ${indir}" |
---|
211 | exit 1 |
---|
212 | fi |
---|
213 | # |
---|
214 | # loop on each file in the list to select PRO and FUNCTION modules |
---|
215 | # ie exclude common files |
---|
216 | for i in ${list_files} |
---|
217 | do |
---|
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 |
---|
225 | done |
---|
226 | echo "exit" >> /tmp/docompileall${$}.pro |
---|
227 | # |
---|
228 | #more /tmp/docompileall${$}.pro |
---|
229 | export IDL_STARTUP=/tmp/docompileall${$}.pro |
---|
230 | ${application} &> /tmp/docompileallerr_${$} |
---|
231 | grep -i "error" /tmp/docompileallerr_${$} |
---|
232 | # grep -q "Compilation error(s)" /tmp/docompileallerr_${$} |
---|
233 | if [ ${?} -ne 0 ] |
---|
234 | then |
---|
235 | echo "all files are OK" |
---|
236 | # clean |
---|
237 | rm -f /tmp/docompileallerr_${$} /tmp/docompileall${$}.pro |
---|
238 | else |
---|
239 | grep "Compilation error(s)" /tmp/docompileallerr_${$} |
---|
240 | echo "eee : see /tmp/docompileallerr_${$}" |
---|
241 | more /tmp/docompileallerr_${$} |
---|
242 | exit 1 |
---|
243 | fi |
---|
244 | # end |
---|
245 | exit 0 |
---|