3 #
Compile a single C
++ file and produce a .o file. OPTIONS is a list
4 # of options to pass to the compiler. Returns
0 on failure
, 1 on
6 proc gcj_cni_compile_cxx_to_o
{file
{options
{}}} {
9 set name [file rootname
[file tail $file
]]
12 # Find the generated header.
13 lappend options
"additional_flags=-I. -I.."
14 # Find libgcj headers.
15 lappend options
"additional_flags=-I$srcdir/.."
17 set x
[libjava_prune_warnings \
18 [target_compile $file $oname object $options
]]
20 verbose
"target_compile failed: $x" 2
21 fail
"[file tail $file] compilation"
25 pass
"[file tail $file] compilation"
29 # Build header files given
name of .java file.
Return 0 on failure.
30 proc gcj_cni_build_headers
{file
} {
32 set jvscan
[find_jvscan
]
34 set class_out
[string trim \
35 [libjava_prune_warnings \
36 [lindex
[local_exec
"$jvscan --encoding=UTF-8 $file --list-class" "" "" 300] 1]]]
37 if {[string match
"*parse error*" $class_out]} {
38 fail
"$file header generation"
42 foreach file
[split $class_out
] {
43 set x
[string trim
[libjava_prune_warnings \
44 [lindex
[local_exec
"$gcjh $file" "" "" 300] 1]]]
46 verbose
"local_exec failed: $x" 2
47 fail
"$file header generation"
52 pass
"$file header generation"
56 #
Do all the work
for a single CNI test.
Return 0 on failure.
57 proc gcj_cni_test_one
{file
} {
60 # The base
name. We use it
for several purposes.
61 set main
[file rootname
[file tail $file
]]
62 if {! [runtest_file_p $runtests $main
]} {
67 if {! [bytecompile_file $file
[pwd
]]} {
68 fail
"bytecompile $file"
69 # FIXME
- should use `untested
' on all remaining tests.
73 pass "bytecompile $file"
75 if {! [gcj_cni_build_headers $file]} {
80 set cfile [file join [file dirname $file] nat$main.cc]
81 if {! [gcj_cni_compile_cxx_to_o $cfile]} {
86 if {! [gcj_link $main $main [list $file nat$main.o]]} {
91 if {! [gcj_invoke $main [file rootname $file].out {}]} {
96 # When we succeed we remove all our clutter.
97 eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
103 proc gcj_cni_run {} {
105 global build_triplet host_triplet
107 # For now we only test CNI on native builds.
108 if {$build_triplet == $host_triplet} {
109 catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.java] } srcfiles
111 foreach x $srcfiles {
115 verbose "CNI tests not run in cross-compilation environment"