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.. -I$srcdir/$subdir -fdollars-in-identifiers"
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
} {
35 # Currently we only build a header file
for the main class from the
36 # .java file
, and
then others
on an ad hoc basis.
38 set main
[file rootname
[file tail $file
]]
40 # ...
for instance
, an obvious hack.
41 if {$main
== "shortfield"} {
42 lappend list shortfieldbase
46 set cmd
"$gcjh -cni -force -classpath .:$libgcj_jar $file"
48 set x
[string trim
[libjava_prune_warnings \
49 [lindex
[local_exec $cmd
"" "" 300] 1]]]
51 verbose
"local_exec failed: $x" 2
52 fail
"$main header generation"
57 pass
"$main header generation"
61 #
Do all the work
for a single CNI test.
Return 0 on failure.
62 proc gcj_cni_test_one
{file
} {
65 # The base
name. We use it
for several purposes.
66 set main
[file rootname
[file tail $file
]]
67 if {! [runtest_file_p $runtests $main
]} {
72 #
if {! [bytecompile_file $file
[pwd
]]} {
73 # fail
"bytecompile $file"
74 # # FIXME
- should use `untested
' on all remaining tests.
78 # pass "bytecompile $file"
80 # if {! [gcj_cni_build_headers $file]} {
85 set cfile [file join [file dirname $file] nat$main.cc]
86 if {! [gcj_cni_compile_cxx_to_o $cfile]} {
91 if {! [gcj_link $main $main [list $file nat$main.o]]} {
96 if {! [gcj_invoke $main [file rootname $file].out {}]} {
101 # When we succeed we remove all our clutter.
102 eval gcj_cleanup [glob -nocomplain -- ${main}.*] [list $main nat$main.o]
108 proc gcj_cni_run {} {
110 global build_triplet host_triplet
112 # For now we only test CNI on native builds.
113 if {$build_triplet == $host_triplet} {
114 catch { lsort [glob -nocomplain ${srcdir}/${subdir}/*.jar] } srcfiles
116 foreach x $srcfiles {
120 verbose "CNI tests not run in cross-compilation environment"