Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / testsuite / lib / ada.exp
1 # Copyright 2004-2015 Free Software Foundation, Inc.
2 #
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 # Compile some Ada code.
17
18 proc gdb_compile_ada {source dest type options} {
19
20     set srcdir [file dirname $source]
21     set gprdir [file dirname $srcdir]
22     set objdir [file dirname $dest]
23
24     append options " ada"
25     append options " additional_flags=-P$gprdir/gnat_ada"
26     append options " additional_flags=-XSRC=[file tail $srcdir]"
27     append options " additional_flags=-XOBJ=$objdir"
28
29     set result [target_compile [file tail $source] $dest $type $options]
30
31     # The Ada build always produces some output, even when the build
32     # succeeds. Thus, we can not use the output the same way we do in
33     # gdb_compile to determine whether the build has succeeded or not.
34     # We therefore simply check whether the dest file has been created
35     # or not. Unless not present, the build has succeeded.
36     if [file exists $dest] { set result "" }
37     gdb_compile_test $source $result
38     return $result
39 }
40
41 # Like standard_testfile, but for Ada.  Historically the Ada tests
42 # used a different naming convention from many of the other gdb tests,
43 # and this difference was preserved during the conversion to
44 # standard_testfile.  DIR defaults to the base name of the test case;
45 # but can be overridden to find sources in a different subdirectory of
46 # gdb.ada.
47
48 proc standard_ada_testfile {base_file {dir ""}} {
49     global gdb_test_file_name srcdir subdir
50     global testdir testfile srcfile binfile
51
52     if {$dir == ""} {
53         set testdir $gdb_test_file_name
54     } else {
55         set testdir $dir
56     }
57     set testfile $testdir/$base_file
58     set srcfile $srcdir/$subdir/$testfile.adb
59     set binfile [standard_output_file $testfile]
60
61     file mkdir [standard_output_file $testdir]
62 }