Commit | Line | Data |
---|---|---|
586027e6 AC |
1 | # This test code is part of GDB, the GNU debugger. |
2 | ||
8acc9f48 | 3 | # Copyright 1998-2013 Free Software Foundation, Inc. |
586027e6 AC |
4 | |
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
e22f8b7c | 7 | # the Free Software Foundation; either version 3 of the License, or |
586027e6 | 8 | # (at your option) any later version. |
e22f8b7c | 9 | # |
586027e6 AC |
10 | # This program is distributed in the hope that it will be useful, |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
e22f8b7c | 14 | # |
586027e6 | 15 | # You should have received a copy of the GNU General Public License |
e22f8b7c | 16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
9d273ca3 AG |
17 | |
18 | load_lib "libgloss.exp" | |
19 | ||
20 | # GCJ_UNDER_TEST is the compiler under test. | |
21 | ||
22 | global tmpdir | |
23 | ||
24 | if ![info exists tmpdir] { | |
25 | set tmpdir "/tmp" | |
26 | } | |
27 | ||
28 | set java_initialized 0 | |
29 | ||
30 | # | |
31 | # Build the status wrapper library as needed. | |
32 | # | |
33 | proc java_init { args } { | |
34 | global wrapper_file; | |
35 | global wrap_compile_flags; | |
36 | global java_initialized | |
37 | global GCJ_UNDER_TEST | |
38 | global TOOL_EXECUTABLE | |
39 | global env | |
40 | ||
41 | if { $java_initialized == 1 } { return; } | |
42 | ||
43 | if ![info exists GCJ_UNDER_TEST] { | |
44 | if [info exists TOOL_EXECUTABLE] { | |
45 | set GCJ_UNDER_TEST $TOOL_EXECUTABLE; | |
46 | } else { | |
d80a43f9 | 47 | if { [info exists env(GCJ)] && $env(GCJ) != "" } { |
9d273ca3 AG |
48 | set GCJ_UNDER_TEST $env(GCJ) |
49 | } else { | |
50 | global tool_root_dir | |
594e6d67 | 51 | global target_alias |
9d273ca3 AG |
52 | |
53 | if ![is_remote host] { | |
54 | set file [lookfor_file $tool_root_dir gcj]; | |
55 | if { $file == "" } { | |
56 | set file [lookfor_file $tool_root_dir gcc/gcj]; | |
57 | } | |
58 | if { $file != "" } { | |
59 | set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec"; | |
60 | } else { | |
61 | set CC [transform gcj]; | |
62 | } | |
63 | } else { | |
64 | set CC [transform gcj] | |
65 | } | |
66 | set GCJ_UNDER_TEST $CC | |
67 | } | |
68 | } | |
69 | } | |
70 | ||
71 | set wrapper_file ""; | |
72 | set wrap_compile_flags ""; | |
73 | if [target_info exists needs_status_wrapper] { | |
74 | set result [build_wrapper "testglue.o"]; | |
75 | if { $result != "" } { | |
76 | set wrapper_file [lindex $result 0]; | |
77 | set wrap_compile_flags [lindex $result 1]; | |
78 | } else { | |
79 | warning "Status wrapper failed to build." | |
80 | } | |
81 | } | |
82 | ||
83 | set java_initialized 1 | |
84 | } | |
85 | ||
86 | # | |
87 | # Run the test specified by srcfile and resultfile. compile_args and | |
88 | # exec_args are options telling this proc how to work. | |
89 | # | |
90 | proc compile_java_from_source { srcfile binfile compile_args } { | |
91 | global GCJ_UNDER_TEST | |
9d273ca3 AG |
92 | global java_initialized |
93 | ||
94 | if { $java_initialized != 1 } { java_init } | |
95 | ||
d47921b9 | 96 | set args [list "compiler=$GCJ_UNDER_TEST"] |
9d273ca3 AG |
97 | lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]" |
98 | if { $compile_args != "" } { | |
99 | lappend args "additional_flags=$compile_args" | |
100 | } | |
101 | ||
ec3c07fc NS |
102 | set result [target_compile $srcfile ${binfile} executable $args] |
103 | gdb_compile_test $srcfile $result | |
104 | return $result | |
9d273ca3 AG |
105 | } |
106 | ||
f1208f9e DE |
107 | # Auxiliary function to set the language to java. |
108 | # The result is 1 (true) for success, 0 (false) for failure. | |
109 | ||
110 | proc set_lang_java {} { | |
111 | if [gdb_test_no_output "set language java"] { | |
112 | return 0 | |
113 | } | |
114 | if [gdb_test "show language" ".* source language is \"java\"." \ | |
115 | "set language to \"java\""] { | |
116 | return 0 | |
117 | } | |
ae59b1da | 118 | return 1 |
f1208f9e DE |
119 | } |
120 | ||
9d273ca3 AG |
121 | # Local Variables: |
122 | # tcl-indent-level:4 | |
123 | # End: |