1 # Copyright (C) 1998, 1999 Red Hat, Inc.
3 load_lib "libgloss.exp"
5 # GCJ_UNDER_TEST is the compiler under test.
9 if ![info exists tmpdir] {
13 set java_initialized 0
16 # Build the status wrapper library as needed.
18 proc java_init { args } {
20 global wrap_compile_flags;
21 global java_initialized
23 global TOOL_EXECUTABLE
26 if { $java_initialized == 1 } { return; }
28 if ![info exists GCJ_UNDER_TEST] {
29 if [info exists TOOL_EXECUTABLE] {
30 set GCJ_UNDER_TEST $TOOL_EXECUTABLE;
32 if [info exists env(GCJ)] {
33 set GCJ_UNDER_TEST $env(GCJ)
37 if ![is_remote host] {
38 set file [lookfor_file $tool_root_dir gcj];
40 set file [lookfor_file $tool_root_dir gcc/gcj];
43 set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
45 set CC [transform gcj];
48 set CC [transform gcj]
50 set GCJ_UNDER_TEST $CC
56 set wrap_compile_flags "";
57 if [target_info exists needs_status_wrapper] {
58 set result [build_wrapper "testglue.o"];
59 if { $result != "" } {
60 set wrapper_file [lindex $result 0];
61 set wrap_compile_flags [lindex $result 1];
63 warning "Status wrapper failed to build."
67 set java_initialized 1
71 # Run the test specified by srcfile and resultfile. compile_args and
72 # exec_args are options telling this proc how to work.
74 proc compile_java_from_source { srcfile binfile compile_args } {
77 global java_initialized
79 if { $java_initialized != 1 } { java_init }
81 set errname [file rootname [file tail $srcfile]]
82 if {! [runtest_file_p $runtests $errname]} {
86 set args "compiler=$GCJ_UNDER_TEST"
87 lappend args "additional_flags=--main=[file rootname [file tail $srcfile]]"
88 if { $compile_args != "" } {
89 lappend args "additional_flags=$compile_args"
92 if { $compile_args != "" } {
93 set errname "$errname $compile_args"
96 set x [target_compile $srcfile ${binfile} ${binfile} $args]
98 verbose "target_compile failed: $x" 2
99 return "$errname compilation from source";