1 # Copyright (C) 2009 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
18 # This file contains the support procedures for testing the plugin mechanism.
24 # plugin-get-options -- process test directives
26 # SRC is the full pathname of the plugin source file.
28 proc plugin-get-options { src } {
29 # dg-options sets a variable called dg-extra-tool-flags.
30 set dg-extra-tool-flags ""
32 # dg-require-* sets dg-do-what.
33 upvar dg-do-what dg-do-what
35 set tmp [dg-get-options $src]
37 set cmd [lindex $op 0]
38 if { ![string compare "dg-options" $cmd] } {
39 set status [catch "$op" errmsg]
41 perror "src: $errmsg for \"$op\"\n"
42 unresolved "$src: $errmsg for \"$op\""
46 # Ignore unrecognized dg- commands, but warn about them.
47 warning "plugin.exp does not support $cmd"
51 # Return flags to use for compiling the plugin source file
52 return ${dg-extra-tool-flags}
56 # plugin-test-execute -- build the plugin first and then compile the
57 # test files with the plugin.
59 # PLUGIN_SRC is the full pathname of the plugin source file.
60 # PLUGIN_TESTS is a list of input test source files.
62 proc plugin-test-execute { plugin_src plugin_tests } {
69 set basename [file tail $plugin_src]
70 set base [file rootname $basename]
71 set plugin_lib $base.so
73 verbose "Test the plugin $basename" 1
75 # Build the plugin itself
76 set extra_flags [plugin-get-options $plugin_src]
78 # Note that the plugin test support currently only works when the GCC
79 # build tree is available. (We make sure that is the case in plugin.exp.)
80 # Once we have figured out how/where to package/install GCC header files
81 # for general plugin support, we should modify the following include paths
83 set gcc_srcdir "$srcdir/../.."
84 set gcc_objdir "$objdir/../../.."
85 set includes "-I. -I${srcdir} -I${gcc_srcdir}/gcc -I${gcc_objdir}/gcc \
86 -I${gcc_srcdir}/include -I${gcc_srcdir}/libcpp/include \
89 set optstr "$includes $extra_flags -DIN_GCC -fPIC -shared"
91 # Temporarily switch to the environment for the host compiler.
92 restore_ld_library_path_env_vars
93 set status [remote_exec build "$HOSTCC $HOSTCFLAGS $plugin_src $optstr -o $plugin_lib"]
94 set status [lindex $status 0]
95 set_ld_library_path_env_vars
97 if { $status != 0 } then {
98 unresolved "$basename compilation, $optstr"
102 # Compile the input source files with the plugin
104 set plugin_enabling_flags "-fplugin=./$plugin_lib"
105 dg-runtest $plugin_tests $plugin_enabling_flags $default_flags
108 remote_file build delete $plugin_lib