3
3
# Usage info
4
4
usage ()
5
5
{
6
- echo " Usage:\n\nlist_unsupported.sh path_to_ada_source_folder\n"
7
- echo " Run GNAT2Goto on an Ada repository.\n"
6
+ echo " Usage:list_unsupported.sh [--help] [--apex] path_to_ada_source_folder"
7
+ echo
8
+ echo " Run GNAT2Goto on an Ada repository."
9
+ echo
8
10
echo " The output is an ordered list of currently unsupported features"
9
- echo " with the number of times they occur in the input repository.\n"
10
- echo " The script builds a parsing program using collect_unsupported.cpp and expects"
11
- echo " this file to be in the same folder.\n"
11
+ echo " with the number of times they occur in the input repository."
12
+ echo
13
+ echo " Options:"
14
+ echo " --help Display this usage information"
15
+ echo " --apex Use Rational APEX style naming convention .1.ada and .2.ada"
12
16
}
13
17
18
+ # File extensions to expect for Specification files and Body files
19
+ spec_ext=" ${SPEC_EXT:- ads} "
20
+ body_ext=" ${BODY_EXT:- adb} "
21
+
14
22
# First check some environment prerequisites
15
23
echo >&2 " Checking environment..."
16
24
@@ -93,39 +101,60 @@ echo >&2 "...environment is OK."
93
101
94
102
# Command line processing....
95
103
96
- if [ " $1 " = ' --help ' ]; then
104
+ if [ " $# " -eq 0 ]; then
97
105
usage
98
106
exit
99
107
fi
100
108
101
- if [ " $# " -ne 1 ]; then
109
+ while [ -n " $1 " ] ; do
110
+ case " $1 " in
111
+ --apex)
112
+ spec_ext=" 1.ada"
113
+ body_ext=" 2.ada"
114
+ ;;
115
+ --help)
116
+ usage
117
+ exit
118
+ ;;
119
+ * )
120
+ if [ -n " $project_dir " ]; then
121
+ usage >&2
122
+ echo >&2 " Only a single folder name may be specified"
123
+ exit 2
124
+ fi
125
+ project_dir=" $1 "
126
+ esac
127
+ shift
128
+ done
129
+
130
+ if [ -z " $project_dir " ]; then
102
131
usage >&2
103
- echo >&2 " Only a single folder name may be specified"
132
+ echo >&2 " A project folder name must be specified"
104
133
exit 2
105
134
fi
106
135
107
136
# Finally start work
108
137
109
- echo >&2 " Project to build: $1 "
110
- path=" $( cd " $( dirname " $1 " ) " ; pwd) /$( basename " $1 " ) "
138
+ echo >&2 " Project to build: ${project_dir} "
139
+ file_name=$( basename " ${project_dir} " )
140
+ path=" $( cd " $( dirname " ${project_dir} " ) " ; pwd) /${file_name} "
111
141
include_path=" "
112
- file_name=$( basename " $1 " )
113
142
114
143
for foldername in $( find ${path} -type d -name " *" | LC_ALL=posix sort ) ; do
115
- count=` ls -1 ${foldername} /* .ads 2> /dev/null | wc -l`
144
+ count=` ls -1 ${foldername} /* .${spec_ext} 2> /dev/null | wc -l`
116
145
if [ $count != 0 ]
117
146
then
118
147
include_path=" ${include_path} -I ${foldername} "
119
148
fi
120
149
done
121
150
122
- echo " $1 : Unsupported features\n" > " $file_name " .txt
151
+ echo " ${project_dir} : Unsupported features\n" > " $file_name " .txt
123
152
124
153
# Enumerate all the sub directories of ADA_INCLUDE_PATH
125
154
for include_folder in ` echo " $ADA_INCLUDE_PATH " | tr ' :' ' ' ` ; do
126
155
echo " Expanding $include_folder ..."
127
156
for foldername in $( find ${include_folder} -type d -name " *" | LC_ALL=posix sort) ; do
128
- count=` ls -1 ${foldername} /* .ads 2> /dev/null | wc -l`
157
+ count=` ls -1 ${foldername} /* .${spec_ext} 2> /dev/null | wc -l`
129
158
if [ $count != 0 ]
130
159
then
131
160
ADA_INCLUDE_PATH=" ${ADA_INCLUDE_PATH} :${foldername} "
@@ -147,7 +176,7 @@ echo >&2 "-------------------------------------------------------"
147
176
# some other error that caused the compiler to exit with non-zero
148
177
# exit code
149
178
compile_error_occured=0
150
- for filename in $( find ${path} -name ' *.adb ' | LC_ALL=posix sort) ; do
179
+ for filename in $( find ${path} -name " *. ${body_ext} " | LC_ALL=posix sort) ; do
151
180
printf " Compiling %s..." " ${filename} " >&2
152
181
echo " ---------- COMPILING: $filename " >> " $file_name " .txt
153
182
" ${GNAT2GOTO} " -gnatU ${include_path} " ${filename} " > " $file_name " .txt.compiling 2>&1
@@ -176,11 +205,15 @@ for filename in $(find ${path} -name '*.adb' | LC_ALL=posix sort); do
176
205
fi
177
206
done
178
207
208
+ # Need to use ${spec_ext} and ${body_ext} inside some regex's here,
209
+ # so add any quoting necessary
210
+ quoted_spec_ext=$( printf " %s" " ${spec_ext} " | sed ' s/\./\\./g' )
211
+ quoted_body_ext=$( printf " %s" " ${body_ext} " | sed ' s/\./\\./g' )
179
212
# This redacting system is really pretty crude...
180
213
sed ' /^\[/ d' < " $file_name " .txt | \
181
214
sed ' s/"[^"][^"]*"/"REDACTED"/g' | \
182
- sed ' s/[^ ][^ ]*\.adb /REDACTED.adb/g ' | \
183
- sed ' s/[^ ][^ ]*\.ads /REDACTED.ads/g ' \
215
+ sed " s/[^ ][^ ]*\.${quoted_body_ext} /REDACTED.${body_ext} /g " | \
216
+ sed " s/[^ ][^ ]*\.${quoted_spec_ext} /REDACTED.${spec_ext} /g " \
184
217
> " $file_name " _redacted.txt
185
218
186
219
# Collate and summarise unsupported features
0 commit comments