ada.exp revision 1.7
1# Copyright 2004-2017 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# Call target_compile with SOURCE DEST TYPE and OPTIONS as argument,
17# after having temporarily changed the current working directory to
18# BUILDDIR.
19
20proc target_compile_ada_from_dir {builddir source dest type options} {
21    set saved_cwd [pwd]
22    catch {
23        cd $builddir
24        return [target_compile $source $dest $type $options]
25    } result options
26    cd $saved_cwd
27    return -options $options $result
28}
29
30# Compile some Ada code.
31
32proc gdb_compile_ada {source dest type options} {
33
34    set srcdir [file dirname $source]
35    set gprdir [file dirname $srcdir]
36    set objdir [file dirname $dest]
37
38    # Although strictly not necessary, we force the recompilation
39    # of all units (additional_flags=-f).  This is what is done
40    # when using GCC to build programs in the other languages,
41    # and it avoids using a stray objfile file from a long-past
42    # run, for instance.
43    append options " ada"
44    append options " additional_flags=-f"
45    append options " additional_flags=-I$srcdir"
46
47    set result [target_compile_ada_from_dir \
48                    $objdir [file tail $source] $dest $type $options]
49
50    # The Ada build always produces some output, even when the build
51    # succeeds. Thus, we can not use the output the same way we do in
52    # gdb_compile to determine whether the build has succeeded or not.
53    # We therefore simply check whether the dest file has been created
54    # or not. Unless not present, the build has succeeded.
55    if [file exists $dest] { set result "" }
56    gdb_compile_test $source $result
57    return $result
58}
59
60# Like standard_testfile, but for Ada.  Historically the Ada tests
61# used a different naming convention from many of the other gdb tests,
62# and this difference was preserved during the conversion to
63# standard_testfile.  DIR defaults to the base name of the test case;
64# but can be overridden to find sources in a different subdirectory of
65# gdb.ada.
66
67proc standard_ada_testfile {base_file {dir ""}} {
68    global gdb_test_file_name srcdir subdir
69    global testdir testfile srcfile binfile
70
71    if {$dir == ""} {
72	set testdir $gdb_test_file_name
73    } else {
74	set testdir $dir
75    }
76
77    set testfile $base_file
78    set srcfile $srcdir/$subdir/$testdir/$testfile.adb
79    set binfile [standard_output_file $testfile]
80}
81