From 0039049fb1d76afef05d550823b27731ad7d7b3d Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Thu, 31 May 2018 08:13:02 -0400 Subject: [PATCH] Fix compile-time warnings on all perl code This patch does two things. First, it silences a number of compile-time warnings in the msvc tools files, mainly those due to the fact that in some cases we have more than one package per file. Second it supplies a dummy Perl library with just enough of the Windows API referred to in our code to let it run these checks cleanly, even on Unix machines where the code is never supposed to run. The dummy library should only be used for that purpose, as its README notes. --- src/tools/msvc/MSBuildProject.pm | 12 ++++++++++++ src/tools/msvc/Project.pm | 1 + src/tools/msvc/Solution.pm | 16 ++++++++++++++++ src/tools/msvc/VCBuildProject.pm | 6 ++++++ src/tools/msvc/VSObjectFactory.pm | 2 ++ src/tools/msvc/dummylib/README | 13 +++++++++++++ src/tools/msvc/dummylib/Win32.pm | 4 ++++ src/tools/msvc/dummylib/Win32/Registry.pm | 13 +++++++++++++ src/tools/msvc/dummylib/Win32API/File.pm | 14 ++++++++++++++ 9 files changed, 81 insertions(+) create mode 100644 src/tools/msvc/dummylib/README create mode 100644 src/tools/msvc/dummylib/Win32.pm create mode 100644 src/tools/msvc/dummylib/Win32/Registry.pm create mode 100644 src/tools/msvc/dummylib/Win32API/File.pm diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index 27397ba3fb..948c548aed 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -11,6 +11,8 @@ use strict; use warnings; use base qw(Project); +no warnings qw(redefine); ## no critic + sub _new { my $classname = shift; @@ -399,6 +401,8 @@ use strict; use warnings; use base qw(MSBuildProject); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -420,6 +424,8 @@ use strict; use warnings; use base qw(MSBuildProject); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -464,6 +470,8 @@ use strict; use warnings; use base qw(VC2012Project); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -487,6 +495,8 @@ use strict; use warnings; use base qw(VC2012Project); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -510,6 +520,8 @@ use strict; use warnings; use base qw(VC2012Project); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm index 261c913ea0..0d3554659b 100644 --- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -229,6 +229,7 @@ sub AddDir if ($filter eq "LIBOBJS") { + no warnings qw(once); if (grep(/$p/, @main::pgportfiles, @main::pgcommonfiles) == 1) { diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 8f0b355fc0..7cfd5e1016 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -10,6 +10,8 @@ use strict; use warnings; use VSObjectFactory; +no warnings qw(redefine); ## no critic + sub _new { my $classname = shift; @@ -768,6 +770,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -791,6 +795,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -815,6 +821,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -839,6 +847,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -863,6 +873,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -889,6 +901,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -915,6 +929,8 @@ use strict; use warnings; use base qw(Solution); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; diff --git a/src/tools/msvc/VCBuildProject.pm b/src/tools/msvc/VCBuildProject.pm index 03b890b9b7..09152b2bbc 100644 --- a/src/tools/msvc/VCBuildProject.pm +++ b/src/tools/msvc/VCBuildProject.pm @@ -11,6 +11,8 @@ use strict; use warnings; use base qw(Project); +no warnings qw(redefine); ## no critic + sub _new { my $classname = shift; @@ -268,6 +270,8 @@ use strict; use warnings; use base qw(VCBuildProject); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; @@ -289,6 +293,8 @@ use strict; use warnings; use base qw(VCBuildProject); +no warnings qw(redefine); ## no critic + sub new { my $classname = shift; diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm index eea59c5e4f..3745f8f8a1 100644 --- a/src/tools/msvc/VSObjectFactory.pm +++ b/src/tools/msvc/VSObjectFactory.pm @@ -20,6 +20,8 @@ our (@ISA, @EXPORT); @ISA = qw(Exporter); @EXPORT = qw(CreateSolution CreateProject DetermineVisualStudioVersion); +no warnings qw(redefine); ## no critic + sub CreateSolution { my $visualStudioVersion = shift; diff --git a/src/tools/msvc/dummylib/README b/src/tools/msvc/dummylib/README new file mode 100644 index 0000000000..7b63d0ed43 --- /dev/null +++ b/src/tools/msvc/dummylib/README @@ -0,0 +1,13 @@ + +src/tools/msvc/dummylib + +This directory contains just enough of a dummy library to allow checking of +the programs in src/tools/msvc and src/tools/win32tzlist.pl with +perl -cw, even on machines that lack the Win32 perl infrastructure. + +invoke via: + +PERL5LIB=src/tools/msvc/dummylib perl -cw $file + +This is the only use that should be made of this directory. Attempting actually +running of any programs using this library will result in a lot of grief. diff --git a/src/tools/msvc/dummylib/Win32.pm b/src/tools/msvc/dummylib/Win32.pm new file mode 100644 index 0000000000..079e276f24 --- /dev/null +++ b/src/tools/msvc/dummylib/Win32.pm @@ -0,0 +1,4 @@ +package Win32; +use strict; +use warnings; +1; diff --git a/src/tools/msvc/dummylib/Win32/Registry.pm b/src/tools/msvc/dummylib/Win32/Registry.pm new file mode 100644 index 0000000000..12fe0446ff --- /dev/null +++ b/src/tools/msvc/dummylib/Win32/Registry.pm @@ -0,0 +1,13 @@ +package Win32::Registry; + +use strict; +use warnings; + +use vars qw($HKEY_LOCAL_MACHINE); + +use Exporter (); +our (@EXPORT,@ISA); +@ISA = qw(Exporter); +@EXPORT = qw($HKEY_LOCAL_MACHINE); + +1; diff --git a/src/tools/msvc/dummylib/Win32API/File.pm b/src/tools/msvc/dummylib/Win32API/File.pm new file mode 100644 index 0000000000..34d2bd81eb --- /dev/null +++ b/src/tools/msvc/dummylib/Win32API/File.pm @@ -0,0 +1,14 @@ +package Win32API::File; + +use strict; +use warnings; + +use constant { SEM_FAILCRITICALERRORS => 1, SEM_NOGPFAULTERRORBOX => 2 }; +sub SetErrormode {}; +use Exporter; +our(@ISA,@EXPORT_OK,%EXPORT_TAGS); +@ISA = qw(Exporter); +@EXPORT_OK = qw(SetErrorMode SEM_FAILCRITICALERRORS SEM_NOGPFAULTERRORBOX); +%EXPORT_TAGS = (SEM_ => [qw(SEM_FAILCRITICALERRORS SEM_NOGPFAULTERRORBOX)]); + +1;