diff options
author | Petr Machata <pmachata@redhat.com> | 2012-10-06 21:47:47 +0200 |
---|---|---|
committer | Petr Machata <pmachata@redhat.com> | 2012-10-14 20:13:10 +0200 |
commit | 5aaf64ed7c4243f55944e2190a81123d568700e7 (patch) | |
tree | 95246039419a17af2467f84ab29a1175afc10c59 | |
parent | 0709b4cb982607477d8cc508c85a9104c5d0c194 (diff) | |
download | ltrace-5aaf64ed7c4243f55944e2190a81123d568700e7.tar.gz |
ltrace.exp: Extract logic for compiling object files into a separate proc
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | testsuite/lib/ltrace.exp | 47 |
2 files changed, 43 insertions, 9 deletions
@@ -1,3 +1,8 @@ +2012-10-06 Petr Machata <pmachata@redhat.com> + + * testsuite/lib/ltrace.exp (LtraceCompileObjects): New function. + (ltrace_compile_shlib): Extracted from here. + 2012-10-03 Petr Machata <pmachata@redhat.com> * configure.ac (--enable-valgrind): New option. diff --git a/testsuite/lib/ltrace.exp b/testsuite/lib/ltrace.exp index be635a5..3aeca69 100644 --- a/testsuite/lib/ltrace.exp +++ b/testsuite/lib/ltrace.exp @@ -172,15 +172,9 @@ proc ltrace_compile_shlib {sources dest options} { fail "Bad compiler!" } } - - set outdir [file dirname $dest] - set objects "" - foreach source $sources { - set sourcebase [file tail $source] - if {[ltrace_compile $source "${outdir}/${sourcebase}.o" object $obj_options] != ""} { - return -1 - } - lappend objects ${outdir}/${sourcebase}.o + + if {![LtraceCompileObjects $sources $obj_options objects]} { + return -1 } set link_options $options @@ -194,6 +188,41 @@ proc ltrace_compile_shlib {sources dest options} { } } +# LtraceCompileObjects -- +# +# Compile each source file into an object file. ltrace_compile +# is called to perform actual compilation. +# +# Arguments: +# sources List of source files. +# +# options Options for ltrace_compile. +# +# retName Variable where the resulting list of object names is +# to be placed. +# Results: +# Returns true or false depending on whether there were any +# errors. If it returns true, then variable referenced by +# retName contains list of object files, produced by compiling +# files in sources list. + +proc LtraceCompileObjects {sources options retName} { + upvar $retName ret + set ret {} + + foreach source $sources { + set sourcebase [file tail $source] + set dest $source.o + verbose "LtraceCompileObjects: $source -> $dest" + if {[ltrace_compile $source $dest object $options] != ""} { + return false + } + lappend ret $dest + } + + return true +} + # # ltrace_options OPTIONS_LIST # Pass ltrace commandline options. |