From 49d0e291d83f66d7e1ed393e03eb1b50a2abc560 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Sun, 11 Sep 2011 10:01:38 -0400 Subject: add templates for use with hg-tools/create.py --- scripts/templates/template-cpp.cpp | 29 +++++++++++++++++++++++++++++ scripts/templates/template-h.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 scripts/templates/template-cpp.cpp create mode 100644 scripts/templates/template-h.h (limited to 'scripts') diff --git a/scripts/templates/template-cpp.cpp b/scripts/templates/template-cpp.cpp new file mode 100644 index 0000000000..7a8797698a --- /dev/null +++ b/scripts/templates/template-cpp.cpp @@ -0,0 +1,29 @@ +/** +* @file #filename#.cpp +* @brief Implementation of #filename# +* @author #getpass.getuser()#@lindenlab.com +* +* $LicenseInfo:firstyear=#datetime.datetime.now().year#&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) #datetime.datetime.now().year#, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + + +#'%c'%35#include "#filename#.h" diff --git a/scripts/templates/template-h.h b/scripts/templates/template-h.h new file mode 100644 index 0000000000..de40a8e071 --- /dev/null +++ b/scripts/templates/template-h.h @@ -0,0 +1,31 @@ +/** +* @file #filename#.h +* @brief Header file for #filename# +* @author #getpass.getuser()#@lindenlab.com +* +* $LicenseInfo:firstyear=#datetime.datetime.now().year#&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) #datetime.datetime.now().year#, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ +#'%c'%35#ifndef LL_#filename.upper().replace('-','_')#_H +#'%c'%35#define LL_#filename.upper().replace('-','_')#_H + + +#'%c'%35#endif LL_#filename.upper().replace('-','_')#_H -- cgit v1.2.3 From 9df77524fce4dd0df7f63e2909e0b5f6170d24db Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 12 Sep 2011 07:21:22 -0400 Subject: only include the h file when it is being created, and make the #endif in the h file safer for picky compilers --- scripts/templates/template-cpp.cpp | 3 ++- scripts/templates/template-h.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/templates/template-cpp.cpp b/scripts/templates/template-cpp.cpp index 7a8797698a..35d8441c87 100644 --- a/scripts/templates/template-cpp.cpp +++ b/scripts/templates/template-cpp.cpp @@ -26,4 +26,5 @@ */ -#'%c'%35#include "#filename#.h" +#'' if ( skip_h ) else '%cinclude "%s.h"' % (35,filename)# + diff --git a/scripts/templates/template-h.h b/scripts/templates/template-h.h index de40a8e071..ce7b4ddc87 100644 --- a/scripts/templates/template-h.h +++ b/scripts/templates/template-h.h @@ -28,4 +28,4 @@ #'%c'%35#define LL_#filename.upper().replace('-','_')#_H -#'%c'%35#endif LL_#filename.upper().replace('-','_')#_H +#'%c'%35#endif // LL_#filename.upper().replace('-','_')#_H -- cgit v1.2.3 From 3958c5fe71595cf925c6de0e3d2283a98d125a43 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Mon, 12 Sep 2011 12:10:46 -0400 Subject: make script executable --- scripts/gpu_table_tester | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/gpu_table_tester (limited to 'scripts') diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester old mode 100644 new mode 100755 -- cgit v1.2.3 From 5b42f6f25b9b8fa4bc3ccfe37069a447f89c6327 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 13 Sep 2011 10:00:03 -0400 Subject: modify gpu_table_tester to lowercase things the way that the real gpu table parser does --- scripts/gpu_table_tester | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester index 52b1c8f31d..2ad7ffc01e 100755 --- a/scripts/gpu_table_tester +++ b/scripts/gpu_table_tester @@ -62,14 +62,14 @@ die "Must specify a --gpu-table value" open(GPUS, "<$GpuTable") || die "Failed to open gpu table '$GpuTable':\n\t$!\n"; -# Parse the GPU table into these table, indexed by the name +# Parse the GPU table into these tables, indexed by the name my %NameLine; # name -> line number on which a given name was found (catches duplicate names) my %RecognizerLine; # name -> line number on which a given name was found (catches duplicate names) my %Name; # recognizer -> name my %Recognizer; # name -> recognizer my %Class; # recognizer -> class my %Supported; # recognizer -> supported -my @InOrder; # records the order of the recognizers +my @InOrder; # lowercased recognizers in file order - these are the ones really used to match $Name{'UNRECOGNIZED'} = 'UNRECOGNIZED'; $NameLine{'UNRECOGNIZED'} = '(hard-coded)'; # use this for error messages in table parsing @@ -126,7 +126,8 @@ while () if ($errsOnLine == $ErrorsSeen) # no errors found on this line { - push @InOrder,$regex; + $lcregex = $regex; # the real gpu table parser lowercases each recognizer + push @InOrder,$lcregex; $NameLine{$name} = $INPUT_LINE_NUMBER; $RecognizerLine{$regex} = $INPUT_LINE_NUMBER; $Name{$regex} = $name; @@ -142,10 +143,13 @@ print STDERR "\n" if $ErrorsSeen; exit $ErrorsSeen if $TableOnly; + my %RecognizedBy; -while (<>) +while (<>) # Loop over input lines { chomp; + my $lowerInput = $_; + lc lowerInput; # the real gpu table parser lowercases the input string my $recognizer; $RecognizedBy{$_} = 'UNRECOGNIZED'; foreach $recognizer ( @InOrder ) # note early exit if recognized -- cgit v1.2.3 From 0665d3f2e65b75db55134b5ad3fc1c8182b05f9e Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 13 Sep 2011 10:51:31 -0400 Subject: lowercase gpu string and recognizers in gpu_table_tester to match the behavior of the real code --- scripts/gpu_table_tester | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester index 2ad7ffc01e..4edf649994 100755 --- a/scripts/gpu_table_tester +++ b/scripts/gpu_table_tester @@ -126,8 +126,7 @@ while () if ($errsOnLine == $ErrorsSeen) # no errors found on this line { - $lcregex = $regex; # the real gpu table parser lowercases each recognizer - push @InOrder,$lcregex; + push @InOrder,$regex; $NameLine{$name} = $INPUT_LINE_NUMBER; $RecognizerLine{$regex} = $INPUT_LINE_NUMBER; $Name{$regex} = $name; @@ -148,13 +147,13 @@ my %RecognizedBy; while (<>) # Loop over input lines { chomp; - my $lowerInput = $_; - lc lowerInput; # the real gpu table parser lowercases the input string + my $lcInput = lc $_; # the real gpu table parser lowercases the input string my $recognizer; $RecognizedBy{$_} = 'UNRECOGNIZED'; foreach $recognizer ( @InOrder ) # note early exit if recognized { - if ( m/$recognizer/ ) + my $lcRecognizer = lc $recognizer; # the real gpu table parser lowercases the recognizer + if ( $lcInput =~ m/$lcRecognizer/ ) { $RecognizedBy{$_} = $recognizer; last; # exit recognizer loop -- cgit v1.2.3 From 466b9d7aebff91472ba156b1b9709a42d04e41aa Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Fri, 23 Sep 2011 10:18:01 -0400 Subject: add --diff option to display change report, other minor improvements --- scripts/gpu_table_tester | 131 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 106 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester index 4edf649994..e1e840e2d4 100755 --- a/scripts/gpu_table_tester +++ b/scripts/gpu_table_tester @@ -26,25 +26,35 @@ use Getopt::Long; ( $MyName = $0 ) =~ s|.*/||; my $mini_HELP = " - $MyName --gpu-table - [ --unrecognized-only ] - [ --table-only ] - [ ...] + $MyName {--gpu-table|-g} {--table-only|-t} - Checks for duplicates and invalid lines in the gpu_table.txt file. + Checks for duplicates and invalid lines in the gpu_table.txt file. - Unless the '--table-only' option is specified, it also tests the recognition of - values in the gpu-strings-files (or standard input if no files are given). + $MyName {--gpu-table|-g} [ ... ] + [{--unmatched|-u}] - If the --unrecognized-only option is specified, then no output is produced for - values that are matched, otherwise a line is output for each input line that - describes the results of attempting to match the value on that line. + Tests the recognition of values in the gpu-strings-files (or + standard input if no files are given). The results of attempting to match + each input line are displayed in report form, showing: + - NO MATCH, unsupported, or supported + - the class of the GPU + - the label for the recognizer line from the gpu_table that it matched + + If the --unmatched option is specified, then no output is produced for + values that are matched. + + $MyName {--gpu-table|-g} {--diff|-d} [ ...] + + With the --diff option, the report compares the current results to , + which should be the output from a previous run without --diff. The report shows each + input value with the old result and the new result if it is different. "; -&GetOptions("help" => \$Help, - "gpu-table=s" => \$GpuTable, - "unrecognized-only" => \$UnrecognizedOnly, - "table-only" => \$TableOnly +&GetOptions("help" => \$Help + ,"unmatched" => \$UnMatchedOnlly + ,"table-only" => \$TableOnly + ,"gpu-table=s" => \$GpuTable + ,"diff=s" => \$Diff ) || die "$mini_HELP"; @@ -55,6 +65,7 @@ if ($Help) } $ErrorsSeen = 0; +$NoMatch = 'NO MATCH'; # constant die "Must specify a --gpu-table value" unless $GpuTable; @@ -71,10 +82,10 @@ my %Class; # recognizer -> class my %Supported; # recognizer -> supported my @InOrder; # lowercased recognizers in file order - these are the ones really used to match -$Name{'UNRECOGNIZED'} = 'UNRECOGNIZED'; -$NameLine{'UNRECOGNIZED'} = '(hard-coded)'; # use this for error messages in table parsing -$Class{'UNRECOGNIZED'} = ''; -$Supported{'UNRECOGNIZED'} = ''; +$Name{$NoMatch} = $NoMatch; +$NameLine{$NoMatch} = '(hard-coded)'; # use this for error messages in table parsing +$Class{$NoMatch} = ''; +$Supported{$NoMatch} = ''; while () { @@ -143,13 +154,14 @@ print STDERR "\n" if $ErrorsSeen; exit $ErrorsSeen if $TableOnly; +# Loop over input lines, find the results for each my %RecognizedBy; -while (<>) # Loop over input lines +while (<>) { chomp; my $lcInput = lc $_; # the real gpu table parser lowercases the input string my $recognizer; - $RecognizedBy{$_} = 'UNRECOGNIZED'; + $RecognizedBy{$_} = $NoMatch; foreach $recognizer ( @InOrder ) # note early exit if recognized { my $lcRecognizer = lc $recognizer; # the real gpu table parser lowercases the recognizer @@ -161,8 +173,6 @@ while (<>) # Loop over input lines } } -## Print results. -## For each input, show supported or unsupported, the class, and the recognizer name format STDOUT_TOP = GPU String Supported? Class Recognizer ------------------------------------------------------------------------------------------------------ ----------- ----- ------------------------------------ @@ -172,10 +182,81 @@ format STDOUT = $_, $Supported{$RecognizedBy{$_}},$Class{$RecognizedBy{$_}},$Name{$RecognizedBy{$_}} . -foreach ( sort keys %RecognizedBy ) +my $ReportLineTemplate = "A102xxxA12xxxAA*"; # MUST match the format STDOUT above + +format DIFF_TOP = + ------ OLD ------ ------ NEW ------ +GPU String Supported? Class Supported? Class +------------------------------------------------------------------------------------------------------ ----------- ----- ----------- ----- +. + +my ( $oldSupported, $oldClass, $newSupported, $newClass ); + +format DIFF = +@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<... @<<<<<<<<<< @> @<<<<<<<<<< @> +$_, $oldSupported, $oldClass, $newSupported, $newClass +. + +if ( ! $Diff ) { - write if ! $UnrecognizedOnly || $Name{$RecognizedBy{$_}} eq 'UNRECOGNIZED'; - $-++; # suppresses pagination + ## Print results. + ## For each input, show supported or unsupported, the class, and the recognizer name + + foreach ( sort keys %RecognizedBy ) + { + write if ! $UnMatchedOnly || $Name{$RecognizedBy{$_}} eq $NoMatch; + $-++; # suppresses pagination + } +} +else +{ + open OLD, "<$Diff" + || die "Failed to open --diff file '$Diff'\n\t$!\n"; + my $discard = 2; + while ( ) + { + if ( $discard > 0 ) + { + my ( $gpu, $supported, $class ) = unpack $ReportLineTemplate; + $gpu =~ s/\s*$//; + ( $OldSupported{$gpu} = $supported ) =~ s/\s*$//; + ( $OldClass{$gpu} = $class ) =~ s/\s*$//; + } + else + { + $discard--; + } + } + close OLD; + + $FORMAT_TOP_NAME = DIFF_TOP; + $FORMAT_NAME = DIFF; + foreach ( sort keys %RecognizedBy ) + { + $newSupported = $Supported{$RecognizedBy{$_}} || $NoMatch; + $newClass = $Class{$RecognizedBy{$_}}; + + if ( ! defined $OldSupported{$_} ) + { + $oldSupported = 'NEW'; + $oldClass = '-'; + } + else + { + $oldSupported = $OldSupported{$_} || $NoMatch; + $oldClass = $OldClass{$_}; + + if ( ( $oldSupported eq $newSupported ) + && ( $oldClass eq $newClass ) + ) + { + $newSupported = ''; + $newClass = ''; + } + } + write; + $-++; # suppresses pagination + } } exit $ErrorsSeen; -- cgit v1.2.3 From 066d63022bbd073dd990ede491f111370fcaa879 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Thu, 6 Oct 2011 16:30:32 -0400 Subject: fix typo in flag for -u option --- scripts/gpu_table_tester | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/gpu_table_tester b/scripts/gpu_table_tester index e1e840e2d4..9bc958636d 100755 --- a/scripts/gpu_table_tester +++ b/scripts/gpu_table_tester @@ -51,7 +51,7 @@ my $mini_HELP = " "; &GetOptions("help" => \$Help - ,"unmatched" => \$UnMatchedOnlly + ,"unmatched" => \$UnMatchedOnly ,"table-only" => \$TableOnly ,"gpu-table=s" => \$GpuTable ,"diff=s" => \$Diff -- cgit v1.2.3