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