OSDN Git Service

Copyright updates for 2007.
[pf3gnuchains/pf3gnuchains3x.git] / gdb / testsuite / lib / java.exp
1 # This test code is part of GDB, the GNU debugger.
2
3 # Copyright 1998, 1999, 2000, 2003, 2004, 2006, 2007
4 # Free Software Foundation, Inc.
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
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
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.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
19
20 load_lib "libgloss.exp"
21
22 # GCJ_UNDER_TEST is the compiler under test.
23
24 global tmpdir
25
26 if ![info exists tmpdir] {
27     set tmpdir "/tmp"
28 }
29
30 set java_initialized 0
31
32 #
33 # Build the status wrapper library as needed.
34 #
35 proc java_init { args } {
36     global wrapper_file;
37     global wrap_compile_flags;
38     global java_initialized
39     global GCJ_UNDER_TEST
40     global TOOL_EXECUTABLE
41     global env
42
43     if { $java_initialized == 1 } { return; }
44
45     if ![info exists GCJ_UNDER_TEST] {
46         if [info exists TOOL_EXECUTABLE] {
47             set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
48         } else {
49             if [info exists env(GCJ)] {
50                 set GCJ_UNDER_TEST $env(GCJ)
51             } else {
52                 global tool_root_dir
53                 global target_alias
54                 
55                 if ![is_remote host] {
56                     set file [lookfor_file $tool_root_dir gcj];
57                     if { $file == "" } {
58                         set file [lookfor_file $tool_root_dir gcc/gcj];
59                     }
60                     if { $file != "" } {
61                         set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
62                     } else {
63                         set CC [transform gcj];
64                     }
65                 } else {
66                     set CC [transform gcj]
67                 }
68                 set GCJ_UNDER_TEST $CC
69             }
70         }
71     }
72
73     set wrapper_file "";
74     set wrap_compile_flags "";
75     if [target_info exists needs_status_wrapper] {
76         set result [build_wrapper "testglue.o"];
77         if { $result != "" } {
78             set wrapper_file [lindex $result 0];
79             set wrap_compile_flags [lindex $result 1];
80         } else {
81             warning "Status wrapper failed to build."
82         }
83     }
84
85     set java_initialized 1
86 }
87
88 #
89 # Run the test specified by srcfile and resultfile. compile_args and
90 # exec_args are options telling this proc how to work.
91 #
92 proc compile_java_from_source { srcfile binfile compile_args } {
93     global GCJ_UNDER_TEST
94     global runtests
95     global java_initialized
96
97     if { $java_initialized != 1 } { java_init }
98
99     set errname [file rootname [file tail $srcfile]]
100     if {! [runtest_file_p $runtests $errname]} {
101         return
102     }
103
104     set args "compiler=$GCJ_UNDER_TEST"
105     lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
106     if { $compile_args != "" } {
107         lappend args "additional_flags=$compile_args"
108     }
109
110     if { $compile_args != "" } {
111         set errname "$errname $compile_args"
112     }
113
114     set x [target_compile $srcfile ${binfile} executable $args]
115     if { $x != "" } {
116         verbose "target_compile failed: $x" 2
117         return "$errname compilation from source";
118     }
119 }
120
121 # Local Variables:
122 # tcl-indent-level:4
123 # End: