# APPLE LOCAL new file # Copyright (C) 1997, 1999, 2000, 2003 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ${tool}-transform-file -- transform a source file name to an output file # name. # # The leading directory name of FILE is removed, the new SUFFIX # replaces the original dot-suffix (including the dot), and the result # is returned. # proc ${tool}-transform-file { file suffix } { if { $suffix == ".gch" } { return [file tail $file]$suffix } else { return [file rootname [file tail $file]]$suffix } } # Define gcc callbacks for dg.exp. # ${tool}-dg-test -- run the tool (compiler driver) for this test. # # PROG is the master (or only) source file # DO_WHAT is a keyword describing the action requested # EXTRA_TOOL_FLAGS are options to be added to the tool command line # The first optional arg is a multiple-source file keyword, one of # onestep -- process multiple sources to single file in one step # multi -- process multiple sources to multiple files in one step (TBD) # serial -- process multiple sources to multiple file serially (TBD) # Of course, the link step is always inherently "onestep". # Subsequent optional arguments are file/option-list pairs for # additional source files (slaves). # proc ${tool}-dg-test { prog do_what extra_tool_flags args } { global tool set sources [list $prog] set options [list] if { [llength $args] != 0 } { set multi_mode [lindex $args 0] if { [llength $args] < 2 } { perror "$multi_mode: slave-file/option pair list missing" } switch $multi_mode { onestep { # Ignore the per-file extra options. foreach pair [lrange $args 1 end] { lappend sources [lindex $pair 0] } } multi - serial { perror "$multi_mode: not implemented" } default { perror "$multi_mode: invalid multiple source file mode" } } } else { set multi_mode "" } # Set up the compiler flags, based on what we're going to do. switch $do_what { preprocess { set compile_type preprocess set suffix .i } compile { set compile_type assembly set suffix .s } assemble { set compile_type object set suffix .o } precompile { set compile_type precompiled_header set suffix .gch } link - run { } default { perror "$do_what: not a valid dg-do keyword" return "" } } switch $do_what { link { set compile_type "executable" set output_file ./[${tool}-transform-file $prog .exe] } run { set compile_type "executable" # FIXME: "./" is to cope with "." not being in $PATH. # Should this be handled elsewhere? # YES. set output_file ./[${tool}-transform-file $prog .exe] # Remove any previous copy of the output file, because # otherwise the framework can't tell if one gets produced. # to build a new one. remote_file build delete $output_file; } default { switch $multi_mode { onestep { set output_file [${tool}-transform-file $prog $suffix] lappend options -o $output_file } multi { # FIXME: Not yet. } serial { # FIXME: Not yet. } default { set output_file [${tool}-transform-file $prog $suffix] lappend options -o $output_file } } } } if { $extra_tool_flags != "" } { lappend options "additional_flags=$extra_tool_flags" } # APPLE LOCAL testsuite OS flush bug workaround lappend options "additional_flags=-fslow-exit" set comp_output [${tool}_target_compile \ $sources $output_file $compile_type $options] return [list $comp_output $output_file] } # search_for -- looks for a string match for PATTERN in FILE, returing # 1 if found, otherwise 0. # proc search_for { file pattern } { set fd [open $file r] while { [gets $fd cur_line]>=0 } { if [string match "*$pattern*" $cur_line] then { close $fd return 1 } } close $fd return 0 } # APPLE LOCAL new file