From febf6115a0d7799b8d4b80e1bb5e89236182d7ca Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 10 May 2020 11:31:10 +0200 Subject: [PATCH] bench: use a Makefile This makes it much easier to toy with the benchs. * etc/bench.pl.in: Generate a Makefile instead of directly compiling the files. --- etc/bench.pl.in | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/etc/bench.pl.in b/etc/bench.pl.in index 053efd22..669e013c 100755 --- a/etc/bench.pl.in +++ b/etc/bench.pl.in @@ -825,9 +825,9 @@ Compile C<$base.y> to an executable. =cut -sub compile ($) +sub compile ($$) { - my ($base) = @_; + my ($makefile, $base) = @_; my $compiler = compiler ($base); my $my_bison = `sed -ne '/[/][/] %bison "\\(.*\\)"/{s//\\1/;p;q;}' $base.y`; @@ -838,14 +838,21 @@ sub compile ($) 'c' => 'c', ); my $ext = $ext{language ($base)}; - run ((length $my_bison ? $my_bison : $bison) . " $base.y -o $base.$ext"); if ($gbench) { - run "$compiler -c -o $base.o $cflags $base.$ext"; + print $makefile <Makefile"; while (my ($name, $directives) = each %bench) { generate_grammar ($grammar, $name, $directives); # Compile the executable. - compile ($name); + compile ($makefile, $name); + run "make $name"; $bench{$name} = "system ('./$name');"; chop($size{$name} = `wc -c <$name`); } @@ -932,6 +941,14 @@ sub bench_with_gbenchmark ($@) my $readme = new IO::File ">README.md"; print $readme <Makefile"; + print $makefile <