#!/usr/bin/perl -w sub print_html_header { my $title = $_[0]; return <<"END_HEADER"; CGAL Benchmark - $title END_HEADER } sub check_unique_filenames { my $cmdline ='find . -name "*.bff" -type f'; open FILES, "$cmdline|"; my %filenames = (); while() { chomp; my $filename = $_; if( $_ =~ /\/([^\/]+)$/ ) { $filename = $1; } if( defined $filenames{$1} ) { printf STDERR "! Warning: duplicate filename \"$1\"\n"; } $filenames{$1} = 1; } close FILES; } %targz = (); sub parse_description { my $description=$_[0]; print "\tparsing description $description\n"; my $outdir = ""; my $basename = ""; if($description =~ /^[^\/]+\/[^\/]+\/[^\/]+\/([^\/]+\/)([^\/]+)$/ ) { $outdir = $1; $basename = $2; } else { printf STDERR "! Error: badly placed description filename $description\n"; return; } printf OUT "

$outdir$basename

\n"; open DESC, $description; my $in_paragraph = 0; my $first_paragraph = 1; while( ) { # check for empty lines and produce

tags if( $_ =~ /^\s*$/ ) { if( $in_paragraph && !$first_paragraph ) { printf OUT "

\n\n"; } $in_paragraph = 0; } else { if( ! $in_paragraph ) { printf OUT "

"; } $first_paragraph = 0; $in_paragraph = 1; if( $_ =~ /\\instance(\[\w+\])?\{([^}]+)\}/ ) { my $pre=$`; my $post=$'; #my $modifier=$1; my $location=$2; my $filenames=""; my $pattern="-name \"*.bff\""; if( $location =~ /\/([^\/]*\*[^\/]*)$/ ) { $pattern = " -maxdepth 1 -name \"$1\""; $location = $`; } my $cmdline ="find $location $pattern -type f"; open FILENAMES, "$cmdline|"; while( ) { chomp; $filenames .= $_." "; } close FILENAMES; my $id = $targz{$basename}++; my $freshname = "${basename}_${id}.tar.gz"; $cmdline = "tar czf $html/data/$freshname $filenames"; system "$cmdline"; printf OUT "$pre$freshname$post"; } else { printf OUT; } } } close DESC; } &check_unique_filenames; $html='Benchmark_instances/out_html'; system "rm -rf $html"; system "mkdir -p $html/data"; opendir PKG, "."; open OUT, ">$html/index.html"; printf OUT &print_html_header( "CGAL Benchmarks - Overview" ); printf OUT "

CGAL Benchmarks - Overview

\n\n"; while( $pkg=readdir PKG ) { if( -d $pkg && $pkg ne '.' && $pkg ne '..' && $pkg ne '.svn') { print "searching in package: $pkg\n"; opendir INNERPKG, "$pkg/benchmark/"; while( $innerpkg=readdir INNERPKG ) { if( -d $innerpkg && $innerpkg ne '.' && $innerpkg ne '..' && $innerpkg ne '.svn') { #print "$innerpkg"; if( -d "$pkg/benchmark/$innerpkg/description" ) { #print " contains benchmark\n"; open FILES, "find $pkg/benchmark/$innerpkg/description -type f -name \"*.desc\"|"; while() { chomp; &parse_description( $_ ); } close FILES; } } } } } printf OUT <<"END_FOOTER"; END_FOOTER close OUT; closedir PKG; print "\n";