2008-05-14  Martin Sebor  <sebor@roguewave.com>

	STDCXX-682
	* bin/genxviews (XBUILDGEN): Defined variable to (the best guess
	of) pathname of the xbuildgen utility.
	(logdir): Added a variable and the -L command line option to set
	the directory containing build logs.
	(outdir): Set to /www/stdcxx.apache.org/builds, the "official"
	default location of the cross build result pages.
	(myurl): Avoided using shell variables in definition.
	Added argument validation and more (verbose) progress output.
	* bin/xbuildgen (logdir): Determined from log pathnames passed
	in on the command line and passed to xcomp.awk.
	(process_builds): Removed unused function.
	* bin/xcomp.awk (get_gzlogfname): Used logdir.


git-svn-id: https://svn.apache.org/repos/asf/stdcxx/trunk@656465 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bin/genxviews b/bin/genxviews
index c447077..22bee77 100755
--- a/bin/genxviews
+++ b/bin/genxviews
@@ -30,6 +30,16 @@
     fi
 fi
 
+readonly www_stdcxx_dir="/www/stdcxx.apache.org/builds"
+
+XBUILDGEN=`which xbuildgen 2>/dev/null`
+
+if [ "$XBUILDGEN" = "" ]; then
+    XBUILDGEN=`dirname $0`/xbuildgen
+fi
+
+# default directory where to look for build logs to process
+logdir=.
 
 # show the command line to invoke xbuildgen without actually
 # invoking the script
@@ -38,9 +48,8 @@
 # write verbose progress output to stdout?
 verbose=0
 
-
 # process command line options
-while getopts "dvD:o:V:" opt_name; do
+while getopts "dvD:L:o:V:" opt_name; do
     case $opt_name in
         # options with no arguments
 
@@ -54,10 +63,14 @@
 
         # options with arguments
 
-        D)  # output directory
+        D)  # argument names the directory where to create output files
             outdir=$OPTARG
             ;;
 
+        L)  # argument names the directory containing build logs
+            logdir=$OPTARG
+            ;;
+
         o)  # argument is the name of output file (stdout by default)
             outfile=$OPTARG
             ;;
@@ -72,30 +85,27 @@
 
 
 # set the Subversion and output directories based on version
-if [ "$version" == "" ]; then
+if [ "$version" = "" ]; then
 
     # Subversion (sub)directory under stdcxx/
     svndir="trunk"
 
     # set output directory unless already set on the command line
-    if [ "$outdir" = "" ]; then
-        outdir="$HOME/public_html/stdcxx/results/builds"
+    if [ "$outdir" = "" -a -w $www_stdcxx_dir ]; then
+        outdir="/www/stdcxx.apache.org/builds/$svndir"
     fi
 else
     # Subversion (sub)directory under stdcxx/
     svndir="branches/$version"
 
     # set output directory unless already set on the command line
-    if [ "$outdir" = "" ]; then
-        outdir="$HOME/public_html/stdcxx-$version/results/builds"
+    if [ "$outdir" = "" -a -w $www_stdcxx_dir ]; then
+        outdir="/www/stdcxx.apache.org/builds/$version"
     fi
 
     verarg="-V$version"
 fi
 
-# program to invoke to process detailed results
-CROSS=$HOME/stdcxx/bin/xbuildgen
-
 
 # extract the script's revision number
 myrev='$Revision$'
@@ -103,7 +113,7 @@
 myrev=${myrev%' $'}            # strip trailing text
 
 # form the URL to this version of the script in the repository
-myurl='$HeadURL: http://svn.apache.org/repos/asf/stdcxx/$svndir/bin/genxviews $'
+myurl='$HeadURL: http://svn.apache.org/repos/asf/stdcxx/trunk/bin/genxviews $'
 myurl=${myurl#'$HeadURL: '}   # strip leading text
 myurl=${myurl##*asf/}         # strip svn prefix
 myurl=${myurl%' $'}           # strip trailing text
@@ -116,9 +126,24 @@
 
 myurl="$myurl?view=markup&rev=$myrev"
 
+######################################################################
+# validate arguments
+
+if [ ! -x $XBUILDGEN ]; then
+    echo "$myname $error: cannot find xbuildgen" >&1
+    exit 2
+fi
+
+
+if [ ! -d "$logdir" -o ! -r "$logdir" ]; then
+    echo "$myname error: \"$logdir\" does not exist or isn't readable" >&2
+    exit 2
+fi
+
 
 if [ $verbose -ne 0 ]; then
     echo "$myname: using output directory: \"$outdir\""
+    echo "$myname: reading logs from: \"$logdir\""
 fi
 
 ######################################################################
@@ -144,10 +169,7 @@
 
 # start the clock measuring the amount of wall clock time to process
 # all logs and generate the page
-start_time=`LC_ALL=C date`
-
-
-cd $outdir/..
+readonly start_time=`LC_ALL=C date`
 
 
 readonly scripturl="<a href=\"$myurl\"><code>$myname</code></a>"
@@ -201,7 +223,8 @@
     xfile="$5"
 
     if [ $verbose -ne 0 ]; then
-        echo "$myname: processing logs for $osname-$arch-$compiler: $alllogs"
+        echo "$myname: processing logs for $compiler on $osname, $arch"
+        echo "$myname: searching for files matching \"$alllogs\""
     fi
 
     cat<<EOF | output
@@ -229,8 +252,8 @@
     for b in $btypes; do
         for s in $suffixes; do
 
-            log=`echo $alllogs | tr ' ' '\n' | grep "[-]$b$s-" \
-                               | sort | tail -n 1`
+            log=`  echo $logdir/$alllogs | tr ' ' '\n' \
+                 | grep "[-]$b$s-" | sort | tail -n 1`
 
             if [ "$log" != "" ]; then
                 buildlogs="$buildlogs $log"
@@ -250,13 +273,13 @@
         output "            <td><i>$xfile</i></td>"
     else
         if [ $verbose -ne 0 ]; then
-            echo "$myname: $CROSS $verarg -s -o$outdir/$xfile -T\"$title\" $buildlogs"
+            echo "$myname: $XBUILDGEN $verarg -s -o$outdir/$xfile -T\"$title\" $buildlogs"
         fi
 
         output "            <td><a href=\"$xfile\">$xfile</a></td>"
 
         if [ $dryrun -eq 0 ]; then
-            $CROSS $verarg -s -o$outdir/$xfile -T"$title" $buildlogs
+            $XBUILDGEN $verarg -s -o$outdir/$xfile -T"$title" $buildlogs
         fi
     fi
 
@@ -355,7 +378,7 @@
 # IRIX #################################################################
 process_results "IRIX 6.5" "MIPS" "SGI MIPSpro 7.41" \
                 "irix-6.5-mips-mipspro-7.41-*-*-log.gz.txt" \
-                irix-6.5-mips-mipspro-7.41.htm
+                irix-6.5-mips-mipspro-7.41.html
 
 # Red Hat Linux ########################################################
 # Red Hat Enterprise Linux 5.0
@@ -587,7 +610,7 @@
 readonly now=`date`
 processing_time=`$HOME/stdcxx/bin/duration "$start_time" "$now"`
 
-cat<<EOF
+cat<<EOF | output
     </table>
     <hr>
     <i>Generated in $processing_time.</i>
diff --git a/bin/xbuildgen b/bin/xbuildgen
index 65f42b4..374c7c1 100755
--- a/bin/xbuildgen
+++ b/bin/xbuildgen
@@ -878,13 +878,6 @@
 
 ######################################################################
 
-# the location of the logs
-if [ -z $version ]; then
-    logdir="http://people.apache.org/~sebor/stdcxx/results"
-else
-    logdir="http://people.apache.org/~sebor/stdcxx-$version/results"
-fi
-
 # the name of a temporary file containing the build timings
 timings_file=$TMPDIR/.stdcxx-timings.$$
 
@@ -905,6 +898,7 @@
 
 # space-separated list of names of text logs processed in loop below
 textlogs=""
+logdir=""
 
 for l in $gzlogs; do
     logcount=$((logcount + 1))
@@ -917,6 +911,12 @@
     # set temporary variables (valid only within the loop)
     txtlog=$TMPDIR/`basename $l .gz.txt`.txt.$$
 
+    if [ "$logdir" = "" ]; then
+        logdir=`dirname $l`
+    elif [ $logdir != `dirname $l` ]; then
+        echo "$myname: not implemented: logs in multiple directories" >&2
+    fi
+
     # append the name of the log to the list
     textlogs="$textlogs $txtlog"
 
@@ -936,74 +936,14 @@
 
 ######################################################################
 
-# process a list of builds, one build per row
-process_builds()
-{
-    component_type=$1   # example, locale, or test
-    component_list=$2   # list of component names
-
-    cat <<EOF | output
-    <h2>Results of ${component_type}s</h2>
-    <table>
-      <tr>
-        <th><a name="${component_type}s"></a>log</th>
-        $table_header
-      </tr>
-EOF
-
-    for l in $textlogs; do
-
-        fname=`basename $l .$$`
-        cat <<EOF | output
-      <tr>
-        <td class="name">
-            <a href="$logdir/$fname">$fname</a>
-        </td>
-EOF
-
-        for c in $component_list; do
-
-            line=`grep "^$c  *[^-]" $l`
-            if [ $? -eq 0 -a "$line" != "" ]; then
-                  echo $line \
-                | awk -f $xcomp component=$component_type         \
-                      name=$c verbose=$verbose expect="$expect"   \
-                | output
-            else
-                output "        <td class=\"missing\">N/A</td>"
-            fi
-        done
-
-        output "      </tr>"
-    done
-    output "    </table>"
-}
-
-
-if [ $components_in_rows -ne 0 ]; then
-
-    # check to see 
-    if [ -r $xfailfile ]; then
-        xfails=$xfailfile
-    else
-        xfails=""
-    fi
-
-    awk -f $xcomp bodyonly=1 $xfails $textlogs | output
+# check to see 
+if [ -r $xfailfile ]; then
+    xfails=$xfailfile
 else
-    if [ "$examples_list" != "" ]; then
-        process_builds "example" "$examples_list"
-    fi
-
-    if [ "$test_list" != "" ]; then
-        process_builds "test" "$test_list"
-    fi
-
-    if [ "$locale_list" != "" ]; then
-        process_builds "locale" "$locale_list"
-    fi
+    xfails=""
 fi
 
+awk -f $xcomp bodyonly=1 logdir=$logdir $xfails $textlogs | output
 
 ######################################################################
 # output the rest of the HTML file
diff --git a/bin/xcomp.awk b/bin/xcomp.awk
index 12e542a..9201c88 100755
--- a/bin/xcomp.awk
+++ b/bin/xcomp.awk
@@ -23,7 +23,7 @@
 ########################################################################
 #
 # SYNOPSIS
-#     myname [bodyonly=0|1] logs...
+#     myname [bodyonly=0|1 logdir=<logdir>] logs...
 #
 # VARIABLES:
 #   bodyonly     when non-zero, suppresses the <html> tags
@@ -1777,7 +1777,7 @@
     # replace the trailing .txt suffix with .gz.txt
     sub("\\.txt$", ".gz.txt", fref)
 
-    return "../" fref
+    return logdir "/" fref
 }