5c1432fcd375195b2c144eabf916d6d2ebace076
[deliverable/binutils-gdb.git] / gdb / testsuite / lib / java.exp
1 # Copyright (C) 1998, 1999 Red Hat, Inc.
2
3 load_lib "libgloss.exp"
4
5 # GCJ_UNDER_TEST is the compiler under test.
6
7 global tmpdir
8
9 if ![info exists tmpdir] {
10 set tmpdir "/tmp"
11 }
12
13 set java_initialized 0
14
15 #
16 # Build the status wrapper library as needed.
17 #
18 proc java_init { args } {
19 global wrapper_file;
20 global wrap_compile_flags;
21 global java_initialized
22 global GCJ_UNDER_TEST
23 global TOOL_EXECUTABLE
24 global env
25
26 if { $java_initialized == 1 } { return; }
27
28 if ![info exists GCJ_UNDER_TEST] {
29 if [info exists TOOL_EXECUTABLE] {
30 set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
31 } else {
32 if [info exists env(GCJ)] {
33 set GCJ_UNDER_TEST $env(GCJ)
34 } else {
35 global tool_root_dir
36 global target_alias
37
38 if ![is_remote host] {
39 set file [lookfor_file $tool_root_dir gcj];
40 if { $file == "" } {
41 set file [lookfor_file $tool_root_dir gcc/gcj];
42 }
43 if { $file != "" } {
44 set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
45 } else {
46 set CC [transform gcj];
47 }
48 } else {
49 set CC [transform gcj]
50 }
51 set GCJ_UNDER_TEST $CC
52 }
53 }
54 }
55
56 set wrapper_file "";
57 set wrap_compile_flags "";
58 if [target_info exists needs_status_wrapper] {
59 set result [build_wrapper "testglue.o"];
60 if { $result != "" } {
61 set wrapper_file [lindex $result 0];
62 set wrap_compile_flags [lindex $result 1];
63 } else {
64 warning "Status wrapper failed to build."
65 }
66 }
67
68 set java_initialized 1
69 }
70
71 #
72 # Run the test specified by srcfile and resultfile. compile_args and
73 # exec_args are options telling this proc how to work.
74 #
75 proc compile_java_from_source { srcfile binfile compile_args } {
76 global GCJ_UNDER_TEST
77 global runtests
78 global java_initialized
79
80 if { $java_initialized != 1 } { java_init }
81
82 set errname [file rootname [file tail $srcfile]]
83 if {! [runtest_file_p $runtests $errname]} {
84 return
85 }
86
87 set args "compiler=$GCJ_UNDER_TEST"
88 lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
89 if { $compile_args != "" } {
90 lappend args "additional_flags=$compile_args"
91 }
92
93 if { $compile_args != "" } {
94 set errname "$errname $compile_args"
95 }
96
97 set x [target_compile $srcfile ${binfile} ${binfile} $args]
98 if { $x != "" } {
99 verbose "target_compile failed: $x" 2
100 return "$errname compilation from source";
101 }
102 }
103
104 # Local Variables:
105 # tcl-indent-level:4
106 # End:
This page took 0.031207 seconds and 4 git commands to generate.