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] [--adc pragmas.adc] 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"
16
+ echo " --adc pragmas.adc Use the specified 'pragmas.adc' file during compilation"
12
17
}
13
18
19
+ # File extensions to expect for Specification files and Body files
20
+ spec_ext=" ${SPEC_EXT:- ads} "
21
+ body_ext=" ${BODY_EXT:- adb} "
22
+
14
23
# First check some environment prerequisites
15
24
echo >&2 " Checking environment..."
16
25
@@ -93,46 +102,82 @@ echo >&2 "...environment is OK."
93
102
94
103
# Command line processing....
95
104
96
- if [ " $1 " = ' --help ' ]; then
105
+ if [ " $# " -eq 0 ]; then
97
106
usage
98
107
exit
99
108
fi
100
109
101
- if [ " $# " -ne 1 ]; then
110
+ while [ -n " $1 " ] ; do
111
+ case " $1 " in
112
+ --apex)
113
+ spec_ext=" 1.ada"
114
+ body_ext=" 2.ada"
115
+ pragma_file=" $( dirname ${0} ) /rational-apex.adc"
116
+ ;;
117
+ --adc)
118
+ shift
119
+ if [ -r " ${1} " ] ; then
120
+ pragma_file=" ${1} "
121
+ else
122
+ usage >&2
123
+ echo >&2 " --adc option must specify a configuration pragma file"
124
+ exit 2
125
+ fi
126
+ ;;
127
+ --help)
128
+ usage
129
+ exit
130
+ ;;
131
+ * )
132
+ if [ -n " $project_dir " ]; then
133
+ usage >&2
134
+ echo >&2 " Only a single folder name may be specified"
135
+ exit 2
136
+ fi
137
+ project_dir=" $1 "
138
+ esac
139
+ shift
140
+ done
141
+
142
+ if [ -z " $project_dir " ]; then
102
143
usage >&2
103
- echo >&2 " Only a single folder name may be specified"
144
+ echo >&2 " A project folder name must be specified"
104
145
exit 2
105
146
fi
106
147
107
148
# Finally start work
108
149
109
- echo >&2 " Project to build: $1 "
110
- path=" $( cd " $( dirname " $1 " ) " ; pwd) /$( basename " $1 " ) "
150
+ echo >&2 " Project to build: ${project_dir} "
151
+ file_name=$( basename " ${project_dir} " )
152
+ path=" $( cd " $( dirname " ${project_dir} " ) " ; pwd) /${file_name} "
111
153
include_path=" "
112
- file_name=$( basename " $1 " )
113
154
114
155
for foldername in $( find ${path} -type d -name " *" | LC_ALL=posix sort ) ; do
115
- count=` ls -1 ${foldername} /* .ads 2> /dev/null | wc -l`
156
+ count=` ls -1 ${foldername} /* .${spec_ext} 2> /dev/null | wc -l`
116
157
if [ $count != 0 ]
117
158
then
118
159
include_path=" ${include_path} -I ${foldername} "
119
160
fi
120
161
done
121
162
122
- echo " $1 : Unsupported features\n" > " $file_name " .txt
163
+ echo " ${project_dir} : Unsupported features\n" > " $file_name " .txt
123
164
124
165
# Enumerate all the sub directories of ADA_INCLUDE_PATH
125
166
for include_folder in ` echo " $ADA_INCLUDE_PATH " | tr ' :' ' ' ` ; do
126
167
echo " Expanding $include_folder ..."
127
168
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`
169
+ count=` ls -1 ${foldername} /* .${spec_ext} 2> /dev/null | wc -l`
129
170
if [ $count != 0 ]
130
171
then
131
172
ADA_INCLUDE_PATH=" ${ADA_INCLUDE_PATH} :${foldername} "
132
173
fi
133
174
done
134
175
done
135
176
177
+ if [ -n " ${pragma_file} " ]; then
178
+ pragma_file_opt=" -gnatec=${pragma_file} "
179
+ fi
180
+
136
181
# Before attempting to start compiling, make a clear log of the environment
137
182
# we will be using:
138
183
echo >&2 " -------------------------------------------------------"
@@ -147,10 +192,10 @@ echo >&2 "-------------------------------------------------------"
147
192
# some other error that caused the compiler to exit with non-zero
148
193
# exit code
149
194
compile_error_occured=0
150
- for filename in $( find ${path} -name ' *.adb ' | LC_ALL=posix sort) ; do
195
+ for filename in $( find ${path} -name " *. ${body_ext} " | LC_ALL=posix sort) ; do
151
196
printf " Compiling %s..." " ${filename} " >&2
152
197
echo " ---------- COMPILING: $filename " >> " $file_name " .txt
153
- " ${GNAT2GOTO} " -gnatU ${include_path} " ${filename} " > " $file_name " .txt.compiling 2>&1
198
+ " ${GNAT2GOTO} " ${pragma_file_opt} -gnatU ${include_path} " ${filename} " > " $file_name " .txt.compiling 2>&1
154
199
result=$?
155
200
cat " $file_name " .txt.compiling >> " $file_name " .txt
156
201
@@ -176,11 +221,15 @@ for filename in $(find ${path} -name '*.adb' | LC_ALL=posix sort); do
176
221
fi
177
222
done
178
223
224
+ # Need to use ${spec_ext} and ${body_ext} inside some regex's here,
225
+ # so add any quoting necessary
226
+ quoted_spec_ext=$( printf " %s" " ${spec_ext} " | sed ' s/\./\\./g' )
227
+ quoted_body_ext=$( printf " %s" " ${body_ext} " | sed ' s/\./\\./g' )
179
228
# This redacting system is really pretty crude...
180
229
sed ' /^\[/ d' < " $file_name " .txt | \
181
230
sed ' s/"[^"][^"]*"/"REDACTED"/g' | \
182
- sed ' s/[^ ][^ ]*\.adb /REDACTED.adb/g ' | \
183
- sed ' s/[^ ][^ ]*\.ads /REDACTED.ads/g ' \
231
+ sed " s/[^ ][^ ]*\.${quoted_body_ext} /REDACTED.${body_ext} /g " | \
232
+ sed " s/[^ ][^ ]*\.${quoted_spec_ext} /REDACTED.${spec_ext} /g " \
184
233
> " $file_name " _redacted.txt
185
234
186
235
# Collate and summarise unsupported features
0 commit comments