]>
Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2004-2016 Free Software Foundation, Inc. |
d40d2c92 JB |
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 | |
e22f8b7c | 5 | # the Free Software Foundation; either version 3 of the License, or |
d40d2c92 | 6 | # (at your option) any later version. |
e22f8b7c | 7 | # |
d40d2c92 JB |
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. | |
e22f8b7c | 12 | # |
d40d2c92 | 13 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
d40d2c92 | 15 | |
ab8314b3 JB |
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 | ||
20 | proc 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 | ||
034cb681 JB |
30 | # Compile some Ada code. |
31 | ||
32 | proc gdb_compile_ada {source dest type options} { | |
33 | ||
464dd14d JB |
34 | set srcdir [file dirname $source] |
35 | set gprdir [file dirname $srcdir] | |
034cb681 JB |
36 | set objdir [file dirname $dest] |
37 | ||
ab8314b3 JB |
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. | |
034cb681 | 43 | append options " ada" |
ab8314b3 JB |
44 | append options " additional_flags=-f" |
45 | append options " additional_flags=-I$srcdir" | |
034cb681 | 46 | |
ab8314b3 JB |
47 | set result [target_compile_ada_from_dir \ |
48 | $objdir [file tail $source] $dest $type $options]] | |
034cb681 JB |
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. | |
ec3c07fc NS |
55 | if [file exists $dest] { set result "" } |
56 | gdb_compile_test $source $result | |
57 | return $result | |
034cb681 JB |
58 | } |
59 | ||
8223e12c TT |
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 | ||
67 | proc 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 | set testfile $testdir/$base_file | |
77 | set srcfile $srcdir/$subdir/$testfile.adb | |
78 | set binfile [standard_output_file $testfile] | |
79 | ||
80 | file mkdir [standard_output_file $testdir] | |
81 | } |