hello,

I was trying to debug the t/src tests, and realized that doing by hand
what Parrot::Test::c_output_(is|like) does is not really easy.

I wanted to compile the source code embedded in t/src/sprintf.t (the
third test, in my case) to see exactly where and how it was failing, and
possibly have a chance to debug it.

so, I ended up looking in lib/Parrot/Test.pm and writing a simple
script which mimics what that module does (just a wrapper that calls
gcc with all the settings from Parrot::Config).

I've called it pcc, and it should reside in the root parrot directory.
the source is merely 17 lines long, so I attach it at the end of this
mail.

now, I'm able to pull out the source code from t/src/sprintf.t, save
it, let's say, in many_printfs.c and then do:

$ ./pcc many_printfs.c
$ ./many_printfs

hope this helps :-)

$ cat pcc

#!/usr/bin/perl -w

use lib 'lib';
use Parrot::Config;

my $libparrot = $PConfig{blib_lib_libparrot_a};
$libparrot =~ s/\$\(A\)/$PConfig{a}/;

my $source_f = $ARGV[0] || die "no source specified\n";
(my $obj_f = $source_f) =~ s/\.c/$PConfig{o}/ie;
(my $exe_f = $source_f) =~ s/\.c/$PConfig{exe}/ie;
my $cmd = "$PConfig{cc} $PConfig{ccflags} $PConfig{cc_debug} ".
          " -I./include -c $PConfig{cc_o_out}$obj_f $source_f";
system("$cmd") && die "compile failed with exit code ".($?>>8)."\n";
$cmd = "$PConfig{link} $PConfig{linkflags} $PConfig{ld_debug} $obj_f ".
       "$PConfig{ld_out}$exe_f $libparrot $PConfig{libs}";
system("$cmd") && die "link failed with exit code ".($?>>8)."\n";
__END__


cheers,
Aldo

__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;

Reply via email to