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

Last change on this file was 495, checked in by pinsard, 10 years ago

fix thanks to coding rules; typo; dupe empty lines; trailing blanks

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