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)
38 if ![is_remote host] {
39 set file [lookfor_file $tool_root_dir gcj];
41 set file [lookfor_file $tool_root_dir gcc/gcj];
44 set CC "$file -B[file dirname $file]/ --specs=$tool_root_dir/$target_alias/libjava/libgcj-test.spec";
46 set CC [transform gcj];
49 set CC [transform gcj]
51 set GCJ_UNDER_TEST $CC
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];
64 warning "Status wrapper failed to build."
68 set java_initialized 1
72 # Run the test specified by srcfile and resultfile. compile_args and
73 # exec_args are options telling this proc how to work.
75 proc compile_java_from_source { srcfile binfile compile_args } {
78 global java_initialized
80 if { $java_initialized != 1 } { java_init }
82 set errname [file rootname [file tail $srcfile]]
83 if {! [runtest_file_p $runtests $errname]} {
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"
93 if { $compile_args != "" } {
94 set errname "$errname $compile_args"
97 set x [target_compile $srcfile ${binfile} ${binfile} $args]
99 verbose "target_compile failed: $x" 2
100 return "$errname compilation from source";