Skip to content

Commit ff9b6b3

Browse files
Merge pull request #255 from chrisr-diffblue/list_unsupported_user_help
List unsupported user help
2 parents 86b985b + bd9ca77 commit ff9b6b3

File tree

2 files changed

+105
-33
lines changed

2 files changed

+105
-33
lines changed

.travis.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ script:
8787
#run the tests
8888
- (cd testsuite/gnat2goto; ./testsuite.py --timeout 60 --diffs --enable-color -j 2 )
8989
- gnat2goto/install/bin/unit_tests
90-
- (gnat --version; cd ${TRAVIS_BUILD_DIR}/experiments; ./CI-list_unsupported.sh )
90+
- |
91+
#run CI-list_unsupported, making sure g++-7 is first on the PATH
92+
( set -euo pipefail
93+
gnat --version
94+
cd ${TRAVIS_BUILD_DIR}/experiments
95+
export PATH=${TRAVIS_BUILD_DIR}/bin:${PATH}
96+
./CI-list_unsupported.sh
97+
)
9198
9299
before_cache:
93100
- ccache -s

experiments/list_unsupported.sh

Lines changed: 97 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,125 @@
11
#!/bin/sh
2-
if ! command -v gnat2goto > /dev/null; then
3-
echo >&2 "gnat2goto not on PATH!"
4-
exit 1
5-
fi
6-
7-
if [ "$#" -ne 1 ]; then
8-
echo >&2 "Provide folder name to start"
9-
exit 2
10-
fi
112

12-
if [ "$1" = '--help' ]; then
3+
# Usage info
4+
usage()
5+
{
6+
echo "Usage:\n\nlist_unsupported.sh path_to_ada_source_folder\n"
137
echo "Run GNAT2Goto on an Ada repository.\n"
148
echo "The output is an ordered list of currently unsupported features"
159
echo "with the number of times they occur in the input repository.\n"
1610
echo "The script builds a parsing program using collect_unsupported.cpp and expects"
1711
echo "this file to be in the same folder.\n"
18-
echo "Usage:\n\nlist_unsupported.sh path_to_ada_source_folder"
19-
exit 3
20-
fi
21-
22-
echo >&2 "Project to build: $1"
23-
path="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
24-
include_path=""
25-
DIR=`dirname "$0"`
26-
file_name=$(basename "$1")
12+
}
2713

28-
for foldername in $(find ${path} -type d -name "*" | LC_ALL=posix sort ); do
29-
count=`ls -1 ${foldername}/*.ads 2>/dev/null | wc -l`
30-
if [ $count != 0 ]
31-
then
32-
include_path="${include_path} -I ${foldername}"
33-
fi
34-
done
14+
# First check some environment prerequisites
15+
echo >&2 "Checking environment..."
3516

36-
echo "$1: Unsupported features\n" > "$file_name".txt
17+
# gnat2goto on the path?
18+
if ! command -v gnat2goto > /dev/null; then
19+
echo >&2 "gnat2goto not on PATH!"
20+
gnat2goto_bin=$(cd "$(dirname ${0})/../gnat2goto/install/bin" 2>/dev/null && pwd)
21+
echo >&2 "Suggested adding gnat2goto to your PATH with the following command:"
22+
echo >&2 " export PATH=\"${gnat2goto_bin}:\${PATH}\""
23+
exit 1
24+
fi
3725

26+
# gnat on the path?
3827
if ! command -v gnat > /dev/null; then
3928
echo >&2 "Gnat not on PATH!"
29+
# Take a wild guess at where gnat might be installed...
30+
gnat_location="/opt/gnat/bin"
31+
if [ -x "${gnat_location}/gnat" ] ; then
32+
# Check if that's gnat 2016...
33+
if gnat --version | grep -q 'GNAT GPL 2016' ; then
34+
echo >&2 "Suggested adding gnat to your PATH with the following command:"
35+
echo >&2 " export PATH=\"${gnat_location}:\${PATH}\""
36+
fi
37+
fi
4038
exit 4
4139
fi
4240

41+
# Right version of gnat?
42+
if ! (gnat --version | grep -q 'GNAT GPL 2016') ; then
43+
echo >&2 "The wrong version of gnat is on the PATH. gnat2goto requires GNAT GPL 2016."
44+
exit 5
45+
fi
46+
47+
# Sane ADA_INCLUDE_PATH and GPR_PROJECT_PATH?
4348
GNAT2GOTO=`command -v gnat2goto`
4449
ADA_HOME=`command -v gnat`
45-
ADA_HOME="$(dirname "$ADA_HOME")/.."
50+
ADA_HOME=$(cd "$(dirname ${ADA_HOME})/.." 2>/dev/null && pwd)
4651
PLATFORM=`${ADA_HOME}/bin/gcc -dumpmachine`
4752
DEF_ADA_INCLUDE_PATH="${ADA_HOME}/lib/gcc/${PLATFORM}"
4853
ADA_GCC_VERSION=`${ADA_HOME}/bin/gcc -dumpversion`
4954
DEF_ADA_INCLUDE_PATH="${DEF_ADA_INCLUDE_PATH}/${ADA_GCC_VERSION}/rts-native/adainclude:${ADA_HOME}/include"
5055
export ADA_INCLUDE_PATH="${ADA_INCLUDE_PATH:-$DEF_ADA_INCLUDE_PATH}"
5156

52-
export GPR_PROJECT_PATH="${GPR_PROJECT_PATH:-/opt/gnat/lib/gnat}"
53-
if [ ! -d "$GPR_PROJECT_PATH" ]; then
54-
echo >&2 "GPR project path does not exists!"
57+
if [ -n "$GPR_PROJECT_PATH" -a ! -d "$GPR_PROJECT_PATH" ]; then
58+
echo >&2 "GPR project path environment variable has been set to:"
59+
echo >&2 " \"${GPR_PROJECT_PATH}\""
60+
echo >&2 "but that path is not a directory."
61+
echo >&2 "Please set the environment variable GPR_PROJECT_PATH to the"
62+
echo >&2 "location of the gnat libraries"
5563
exit 6
64+
else
65+
# GPR_PROJECT_PATH not previously specified, use a default
66+
export GPR_PROJECT_PATH="${ADA_HOME}/lib/gnat"
67+
if [ ! -d "$GPR_PROJECT_PATH" ]; then
68+
echo >&2 "Could not find gnat library directory at ${GPR_PROJECT_PATH}"
69+
echo >&2 "Please set the environment variable GPR_PROJECT_PATH to the"
70+
echo >&2 "location of the gnat libraries"
71+
exit 9
72+
fi
73+
fi
74+
75+
# Can we build the support tool?
76+
# Problem: GNAT 2016 helpfully installs a g++ binary alongside gnat... except
77+
# it's way out of date so invoking g++ via PATH looking will pickup that gnat g++
78+
# compiler, rather than the default system compiler... Instead we need to
79+
# temporarily drop the GNAT tools off the path while we build the tool.
80+
saved_path="$PATH"
81+
export PATH=$(echo ${PATH} | tr ':' '\n' | grep -v "${ADA_HOME}" | paste -s -d : - )
82+
experiment_dir=`dirname "$0"`
83+
gplusplus=`command -v g++`
84+
if ! ${gplusplus} --std=c++14 "${experiment_dir}/collect_unsupported.cpp" -o CollectUnsupported ; then
85+
echo >&2 "Failed to compile support tool 'CollectUnsupported' using ${gplusplus}"
86+
echo >&2 "You need a version of g++ on the PATH that supports C++14"
87+
exit 8
5688
fi
89+
export PATH="${saved_path}"
90+
91+
echo >&2 "...environment is OK."
92+
93+
94+
# Command line processing....
95+
96+
if [ "$1" = '--help' ]; then
97+
usage
98+
exit
99+
fi
100+
101+
if [ "$#" -ne 1 ]; then
102+
usage >&2
103+
echo >&2 "Only a single folder name may be specified"
104+
exit 2
105+
fi
106+
107+
# Finally start work
108+
109+
echo >&2 "Project to build: $1"
110+
path="$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
111+
include_path=""
112+
file_name=$(basename "$1")
113+
114+
for foldername in $(find ${path} -type d -name "*" | LC_ALL=posix sort ); do
115+
count=`ls -1 ${foldername}/*.ads 2>/dev/null | wc -l`
116+
if [ $count != 0 ]
117+
then
118+
include_path="${include_path} -I ${foldername}"
119+
fi
120+
done
121+
122+
echo "$1: Unsupported features\n" > "$file_name".txt
57123

58124
# Enumerate all the sub directories of ADA_INCLUDE_PATH
59125
for include_folder in `echo "$ADA_INCLUDE_PATH" | tr ':' ' '` ; do
@@ -118,7 +184,6 @@ sed '/^\[/ d' < "$file_name".txt | \
118184
> "$file_name"_redacted.txt
119185

120186
# Collate and summarise unsupported features
121-
g++ --std=c++14 "$DIR"/collect_unsupported.cpp -o CollectUnsupported
122187
LC_ALL=posix ./CollectUnsupported "$file_name".txt
123188

124189
# Collate and summarize compile errors from builds that did not generate

0 commit comments

Comments
 (0)