Skip to content

Commit 151968f

Browse files
Add partial support for Rational APEX file naming conventions to list_unsupported.sh
These changes make the script work OK with .1.ada and .2.ada file naming but at the moment gnat2goto still expects to import from .ads files. We need to switch gnat2goto mode somehow when --apex is specified to this script.
1 parent 9f260a1 commit 151968f

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

experiments/list_unsupported.sh

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
# Usage info
44
usage()
55
{
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
810
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"
1216
}
1317

18+
# File extensions to expect for Specification files and Body files
19+
spec_ext="${SPEC_EXT:-ads}"
20+
body_ext="${BODY_EXT:-adb}"
21+
1422
# First check some environment prerequisites
1523
echo >&2 "Checking environment..."
1624

@@ -93,39 +101,60 @@ echo >&2 "...environment is OK."
93101

94102
# Command line processing....
95103

96-
if [ "$1" = '--help' ]; then
104+
if [ "$#" -eq 0 ]; then
97105
usage
98106
exit
99107
fi
100108

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
102131
usage >&2
103-
echo >&2 "Only a single folder name may be specified"
132+
echo >&2 "A project folder name must be specified"
104133
exit 2
105134
fi
106135

107136
# Finally start work
108137

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}"
111141
include_path=""
112-
file_name=$(basename "$1")
113142

114143
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`
116145
if [ $count != 0 ]
117146
then
118147
include_path="${include_path} -I ${foldername}"
119148
fi
120149
done
121150

122-
echo "$1: Unsupported features\n" > "$file_name".txt
151+
echo "${project_dir}: Unsupported features\n" > "$file_name".txt
123152

124153
# Enumerate all the sub directories of ADA_INCLUDE_PATH
125154
for include_folder in `echo "$ADA_INCLUDE_PATH" | tr ':' ' '` ; do
126155
echo "Expanding $include_folder..."
127156
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`
129158
if [ $count != 0 ]
130159
then
131160
ADA_INCLUDE_PATH="${ADA_INCLUDE_PATH}:${foldername}"
@@ -147,7 +176,7 @@ echo >&2 "-------------------------------------------------------"
147176
# some other error that caused the compiler to exit with non-zero
148177
# exit code
149178
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
151180
printf "Compiling %s..." "${filename}" >&2
152181
echo "---------- COMPILING: $filename" >>"$file_name".txt
153182
"${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
176205
fi
177206
done
178207

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')
179212
# This redacting system is really pretty crude...
180213
sed '/^\[/ d' < "$file_name".txt | \
181214
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" \
184217
> "$file_name"_redacted.txt
185218

186219
# Collate and summarise unsupported features

0 commit comments

Comments
 (0)