diff options
Diffstat (limited to 'src/tools')
-rwxr-xr-x | src/tools/check_bison_recursion.pl | 82 | ||||
-rwxr-xr-x | src/tools/check_keywords.pl | 301 | ||||
-rwxr-xr-x | src/tools/copyright.pl | 56 | ||||
-rw-r--r-- | src/tools/msvc/Install.pm | 270 | ||||
-rw-r--r-- | src/tools/msvc/MSBuildProject.pm | 51 | ||||
-rw-r--r-- | src/tools/msvc/Mkvcbuild.pm | 321 | ||||
-rw-r--r-- | src/tools/msvc/Project.pm | 92 | ||||
-rw-r--r-- | src/tools/msvc/Solution.pm | 246 | ||||
-rw-r--r-- | src/tools/msvc/VCBuildProject.pm | 68 | ||||
-rw-r--r-- | src/tools/msvc/VSObjectFactory.pm | 18 | ||||
-rw-r--r-- | src/tools/msvc/build.pl | 9 | ||||
-rw-r--r-- | src/tools/msvc/builddoc.pl | 57 | ||||
-rw-r--r-- | src/tools/msvc/config_default.pl | 38 | ||||
-rw-r--r-- | src/tools/msvc/gendef.pl | 19 | ||||
-rw-r--r-- | src/tools/msvc/mkvcbuild.pl | 9 | ||||
-rw-r--r-- | src/tools/msvc/pgbison.pl | 8 | ||||
-rw-r--r-- | src/tools/msvc/pgflex.pl | 18 | ||||
-rw-r--r-- | src/tools/msvc/vcregress.pl | 126 | ||||
-rwxr-xr-x | src/tools/version_stamp.pl | 118 | ||||
-rwxr-xr-x | src/tools/win32tzlist.pl | 113 |
20 files changed, 1113 insertions, 907 deletions
diff --git a/src/tools/check_bison_recursion.pl b/src/tools/check_bison_recursion.pl index f350b26992e..142a7839bd0 100755 --- a/src/tools/check_bison_recursion.pl +++ b/src/tools/check_bison_recursion.pl @@ -32,43 +32,59 @@ my $cur_nonterminal; # We parse the input and emit warnings on the fly. my $in_grammar = 0; -while (<>) { - my $rule_number; - my $rhs; +while (<>) +{ + my $rule_number; + my $rhs; - # We only care about the "Grammar" part of the input. - if (m/^Grammar$/) { - $in_grammar = 1; - } elsif (m/^Terminal/) { - $in_grammar = 0; - } elsif ($in_grammar) { - if (m/^\s*(\d+)\s+(\S+):\s+(.*)$/) { - # first rule for nonterminal - $rule_number = $1; - $cur_nonterminal = $2; - $rhs = $3; - } elsif (m/^\s*(\d+)\s+\|\s+(.*)$/) { - # additional rule for nonterminal - $rule_number = $1; - $rhs = $2; + # We only care about the "Grammar" part of the input. + if (m/^Grammar$/) + { + $in_grammar = 1; } - } + elsif (m/^Terminal/) + { + $in_grammar = 0; + } + elsif ($in_grammar) + { + if (m/^\s*(\d+)\s+(\S+):\s+(.*)$/) + { + + # first rule for nonterminal + $rule_number = $1; + $cur_nonterminal = $2; + $rhs = $3; + } + elsif (m/^\s*(\d+)\s+\|\s+(.*)$/) + { + + # additional rule for nonterminal + $rule_number = $1; + $rhs = $2; + } + } + + # Process rule if we found one + if (defined $rule_number) + { + + # deconstruct the RHS + $rhs =~ s|^/\* empty \*/$||; + my @rhs = split '\s', $rhs; + print "Rule $rule_number: $cur_nonterminal := @rhs\n" if $debug; - # Process rule if we found one - if (defined $rule_number) { - # deconstruct the RHS - $rhs =~ s|^/\* empty \*/$||; - my @rhs = split '\s', $rhs; - print "Rule $rule_number: $cur_nonterminal := @rhs\n" if $debug; - # We complain if the nonterminal appears as the last RHS element - # but not elsewhere, since "expr := expr + expr" is reasonable - my $lastrhs = pop @rhs; - if (defined $lastrhs && - $cur_nonterminal eq $lastrhs && - !grep { $cur_nonterminal eq $_ } @rhs) { - print "Right recursion in rule $rule_number: $cur_nonterminal := $rhs\n"; + # We complain if the nonterminal appears as the last RHS element + # but not elsewhere, since "expr := expr + expr" is reasonable + my $lastrhs = pop @rhs; + if ( defined $lastrhs + && $cur_nonterminal eq $lastrhs + && !grep { $cur_nonterminal eq $_ } @rhs) + { + print +"Right recursion in rule $rule_number: $cur_nonterminal := $rhs\n"; + } } - } } exit 0; diff --git a/src/tools/check_keywords.pl b/src/tools/check_keywords.pl index 33816c51332..77fbd9a44e0 100755 --- a/src/tools/check_keywords.pl +++ b/src/tools/check_keywords.pl @@ -10,26 +10,30 @@ use strict; my $errors = 0; my $path; -sub error(@) { - print STDERR @_; - $errors = 1; +sub error(@) +{ + print STDERR @_; + $errors = 1; } -if (@ARGV) { +if (@ARGV) +{ $path = $ARGV[0]; shift @ARGV; -} else { +} +else +{ $path = "."; } -$, = ' '; # set output field separator -$\ = "\n"; # set output record separator +$, = ' '; # set output field separator +$\ = "\n"; # set output record separator my %keyword_categories; -$keyword_categories{'unreserved_keyword'} = 'UNRESERVED_KEYWORD'; -$keyword_categories{'col_name_keyword'} = 'COL_NAME_KEYWORD'; +$keyword_categories{'unreserved_keyword'} = 'UNRESERVED_KEYWORD'; +$keyword_categories{'col_name_keyword'} = 'COL_NAME_KEYWORD'; $keyword_categories{'type_func_name_keyword'} = 'TYPE_FUNC_NAME_KEYWORD'; -$keyword_categories{'reserved_keyword'} = 'RESERVED_KEYWORD'; +$keyword_categories{'reserved_keyword'} = 'RESERVED_KEYWORD'; my $gram_filename = "$path/src/backend/parser/gram.y"; open(GRAM, $gram_filename) || die("Could not open : $gram_filename"); @@ -39,80 +43,101 @@ my $comment; my @arr; my %keywords; -line: while (<GRAM>) { - chomp; # strip record separator - - $S = $_; - # Make sure any braces are split - $s = '{', $S =~ s/$s/ { /g; - $s = '}', $S =~ s/$s/ } /g; - # Any comments are split - $s = '[/][*]', $S =~ s#$s# /* #g; - $s = '[*][/]', $S =~ s#$s# */ #g; - - if (!($kcat)) { - # Is this the beginning of a keyword list? - foreach $k (keys %keyword_categories) { - if ($S =~ m/^($k):/) { - $kcat = $k; - next line; - } - } - next line; - } +line: while (<GRAM>) +{ + chomp; # strip record separator - # Now split the line into individual fields - $n = (@arr = split(' ', $S)); + $S = $_; - # Ok, we're in a keyword list. Go through each field in turn - for (my $fieldIndexer = 0; $fieldIndexer < $n; $fieldIndexer++) { - if ($arr[$fieldIndexer] eq '*/' && $comment) { - $comment = 0; - next; - } - elsif ($comment) { - next; - } - elsif ($arr[$fieldIndexer] eq '/*') { - # start of a multiline comment - $comment = 1; - next; - } - elsif ($arr[$fieldIndexer] eq '//') { - next line; - } + # Make sure any braces are split + $s = '{', $S =~ s/$s/ { /g; + $s = '}', $S =~ s/$s/ } /g; - if ($arr[$fieldIndexer] eq ';') { - # end of keyword list - $kcat = ''; - next; - } + # Any comments are split + $s = '[/][*]', $S =~ s#$s# /* #g; + $s = '[*][/]', $S =~ s#$s# */ #g; - if ($arr[$fieldIndexer] eq '|') { - next; + if (!($kcat)) + { + + # Is this the beginning of a keyword list? + foreach $k (keys %keyword_categories) + { + if ($S =~ m/^($k):/) + { + $kcat = $k; + next line; + } + } + next line; } - # Put this keyword into the right list - push @{$keywords{$kcat}}, $arr[$fieldIndexer]; - } + # Now split the line into individual fields + $n = (@arr = split(' ', $S)); + + # Ok, we're in a keyword list. Go through each field in turn + for (my $fieldIndexer = 0; $fieldIndexer < $n; $fieldIndexer++) + { + if ($arr[$fieldIndexer] eq '*/' && $comment) + { + $comment = 0; + next; + } + elsif ($comment) + { + next; + } + elsif ($arr[$fieldIndexer] eq '/*') + { + + # start of a multiline comment + $comment = 1; + next; + } + elsif ($arr[$fieldIndexer] eq '//') + { + next line; + } + + if ($arr[$fieldIndexer] eq ';') + { + + # end of keyword list + $kcat = ''; + next; + } + + if ($arr[$fieldIndexer] eq '|') + { + next; + } + + # Put this keyword into the right list + push @{ $keywords{$kcat} }, $arr[$fieldIndexer]; + } } close GRAM; # Check that all keywords are in alphabetical order my ($prevkword, $kword, $bare_kword); -foreach $kcat (keys %keyword_categories) { - $prevkword = ''; - - foreach $kword (@{$keywords{$kcat}}) { - # Some keyword have a _P suffix. Remove it for the comparison. - $bare_kword = $kword; - $bare_kword =~ s/_P$//; - if ($bare_kword le $prevkword) { - error "'$bare_kword' after '$prevkword' in $kcat list is misplaced"; - $errors = 1; +foreach $kcat (keys %keyword_categories) +{ + $prevkword = ''; + + foreach $kword (@{ $keywords{$kcat} }) + { + + # Some keyword have a _P suffix. Remove it for the comparison. + $bare_kword = $kword; + $bare_kword =~ s/_P$//; + if ($bare_kword le $prevkword) + { + error + "'$bare_kword' after '$prevkword' in $kcat list is misplaced"; + $errors = 1; + } + $prevkword = $bare_kword; } - $prevkword = $bare_kword; - } } # Transform the keyword lists into hashes. @@ -120,13 +145,14 @@ foreach $kcat (keys %keyword_categories) { # UNRESERVED_KEYWORD. Each inner hash is a keyed by keyword id, e.g. ABORT_P # with a dummy value. my %kwhashes; -while ( my ($kcat, $kcat_id) = each(%keyword_categories) ) { - @arr = @{$keywords{$kcat}}; +while (my ($kcat, $kcat_id) = each(%keyword_categories)) +{ + @arr = @{ $keywords{$kcat} }; - my $hash; - foreach my $item (@arr) { $hash->{$item} = 1 } + my $hash; + foreach my $item (@arr) { $hash->{$item} = 1 } - $kwhashes{$kcat_id} = $hash; + $kwhashes{$kcat_id} = $hash; } # Now read in kwlist.h @@ -137,63 +163,82 @@ open(KWLIST, $kwlist_filename) || die("Could not open : $kwlist_filename"); my $prevkwstring = ''; my $bare_kwname; my %kwhash; -kwlist_line: while (<KWLIST>) { - my($line) = $_; - - if ($line =~ /^PG_KEYWORD\(\"(.*)\", (.*), (.*)\)/) - { - my($kwstring) = $1; - my($kwname) = $2; - my($kwcat_id) = $3; - - # Check that the list is in alphabetical order - if ($kwstring le $prevkwstring) { - error "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced"; - } - $prevkwstring = $kwstring; - - # Check that the keyword string is valid: all lower-case ASCII chars - if ($kwstring !~ /^[a-z_]*$/) { - error "'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars"; - } - - # Check that the keyword name is valid: all upper-case ASCII chars - if ($kwname !~ /^[A-Z_]*$/) { - error "'$kwname' is not a valid keyword name, must be all upper-case ASCII chars"; +kwlist_line: while (<KWLIST>) +{ + my ($line) = $_; + + if ($line =~ /^PG_KEYWORD\(\"(.*)\", (.*), (.*)\)/) + { + my ($kwstring) = $1; + my ($kwname) = $2; + my ($kwcat_id) = $3; + + # Check that the list is in alphabetical order + if ($kwstring le $prevkwstring) + { + error + "'$kwstring' after '$prevkwstring' in kwlist.h is misplaced"; + } + $prevkwstring = $kwstring; + + # Check that the keyword string is valid: all lower-case ASCII chars + if ($kwstring !~ /^[a-z_]*$/) + { + error +"'$kwstring' is not a valid keyword string, must be all lower-case ASCII chars"; + } + + # Check that the keyword name is valid: all upper-case ASCII chars + if ($kwname !~ /^[A-Z_]*$/) + { + error +"'$kwname' is not a valid keyword name, must be all upper-case ASCII chars"; + } + + # Check that the keyword string matches keyword name + $bare_kwname = $kwname; + $bare_kwname =~ s/_P$//; + if ($bare_kwname ne uc($kwstring)) + { + error +"keyword name '$kwname' doesn't match keyword string '$kwstring'"; + } + + # Check that the keyword is present in the grammar + %kwhash = %{ $kwhashes{$kwcat_id} }; + + if (!(%kwhash)) + { + + #error "Unknown kwcat_id: $kwcat_id"; + } + else + { + if (!($kwhash{$kwname})) + { + error "'$kwname' not present in $kwcat_id section of gram.y"; + } + else + { + + # Remove it from the hash, so that we can complain at the end + # if there's keywords left that were not found in kwlist.h + delete $kwhashes{$kwcat_id}->{$kwname}; + } + } } - - # Check that the keyword string matches keyword name - $bare_kwname = $kwname; - $bare_kwname =~ s/_P$//; - if ($bare_kwname ne uc($kwstring)) { - error "keyword name '$kwname' doesn't match keyword string '$kwstring'"; - } - - # Check that the keyword is present in the grammar - %kwhash = %{$kwhashes{$kwcat_id}}; - - if (!(%kwhash)) { - #error "Unknown kwcat_id: $kwcat_id"; - } else { - if (!($kwhash{$kwname})) { - error "'$kwname' not present in $kwcat_id section of gram.y"; - } else { - # Remove it from the hash, so that we can complain at the end - # if there's keywords left that were not found in kwlist.h - delete $kwhashes{$kwcat_id}->{$kwname}; - } - } - } } close KWLIST; # Check that we've paired up all keywords from gram.y with lines in kwlist.h -while ( my ($kwcat, $kwcat_id) = each(%keyword_categories) ) { - %kwhash = %{$kwhashes{$kwcat_id}}; +while (my ($kwcat, $kwcat_id) = each(%keyword_categories)) +{ + %kwhash = %{ $kwhashes{$kwcat_id} }; - for my $kw ( keys %kwhash ) { - error "'$kw' found in gram.y $kwcat category, but not in kwlist.h" - } + for my $kw (keys %kwhash) + { + error "'$kw' found in gram.y $kwcat category, but not in kwlist.h"; + } } exit $errors; diff --git a/src/tools/copyright.pl b/src/tools/copyright.pl index d78a8d8ce88..e91672ec55f 100755 --- a/src/tools/copyright.pl +++ b/src/tools/copyright.pl @@ -14,42 +14,50 @@ use File::Find; use Tie::File; my $pgdg = 'PostgreSQL Global Development Group'; -my $cc = 'Copyright \(c\) '; +my $cc = 'Copyright \(c\) '; + # year-1900 is what localtime(time) puts in element 5 -my $year = 1900 + ${[localtime(time)]}[5]; +my $year = 1900 + ${ [ localtime(time) ] }[5]; print "Using current year: $year\n"; -find({wanted => \&wanted, no_chdir => 1}, '.'); +find({ wanted => \&wanted, no_chdir => 1 }, '.'); + +sub wanted +{ + + # prevent corruption of git indexes by ignoring any .git/ + if ($_ eq '.git') + { + $File::Find::prune = 1; + return; + } -sub wanted { - # prevent corruption of git indexes by ignoring any .git/ - if ($_ eq '.git') - { - $File::Find::prune = 1; - return; - } + return if !-f $File::Find::name || -l $File::Find::name; - return if ! -f $File::Find::name || -l $File::Find::name; - # skip file names with binary extensions - # How are these updated? bjm 2012-01-02 - return if ($_ =~ m/\.(ico|bin)$); + # skip file names with binary extensions + # How are these updated? bjm 2012-01-02 + return + if ( + $_ =~ m/\.(ico|bin)$); my @lines; tie @lines, "Tie::File", $File::Find::name; foreach my $line (@lines) { # We only care about lines with a copyright notice. - next unless $line =~ m/$cc.*$pgdg/; - # We stop when we've done one substitution. This is both for - # efficiency and, at least in the case of this program, for - # correctness. - last if $line =~ m/$cc.*$year.*$pgdg/; - last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/; - last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/; - } - untie @lines; + next unless $line =~ m/$cc . *$pgdg /; + + # We stop when we've done one substitution. This is both for + # efficiency and, at least in the case of this program, for + # correctness. + last if $line =~ m/$cc.*$year.*$pgdg/; + last if $line =~ s/($cc\d{4})(, $pgdg)/$1-$year$2/; + last if $line =~ s/($cc\d{4})-\d{4}(, $pgdg)/$1-$year$2/; + } + untie @lines; } -print "Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n"; +print +"Manually update doc/src/sgml/legal.sgml and src/interfaces/libpq/libpq.rc.in too\n"; diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm index 058fab3e5ab..3923532a143 100644 --- a/src/tools/msvc/Install.pm +++ b/src/tools/msvc/Install.pm @@ -13,13 +13,13 @@ use File::Copy; use File::Find (); use Exporter; -our (@ISA,@EXPORT_OK); -@ISA = qw(Exporter); +our (@ISA, @EXPORT_OK); +@ISA = qw(Exporter); @EXPORT_OK = qw(Install); sub lcopy { - my $src = shift; + my $src = shift; my $target = shift; if (-f $target) @@ -27,7 +27,7 @@ sub lcopy unlink $target || confess "Could not delete $target\n"; } - copy($src,$target) + copy($src, $target) || confess "Could not copy $src to $target\n"; } @@ -41,7 +41,7 @@ sub Install require "config_default.pl"; require "config.pl" if (-f "config.pl"); - chdir("../../..") if (-f "../../../configure"); + chdir("../../..") if (-f "../../../configure"); chdir("../../../..") if (-f "../../../../configure"); my $conf = ""; if (-d "debug") @@ -56,83 +56,79 @@ sub Install my $majorver = DetermineMajorVersion(); print "Installing version $majorver for $conf in $target\n"; - EnsureDirectories($target, 'bin', 'lib', 'share','share/timezonesets','share/extension', - 'share/contrib','doc','doc/extension', 'doc/contrib','symbols', - 'share/tsearch_data'); + EnsureDirectories( + $target, 'bin', + 'lib', 'share', + 'share/timezonesets', 'share/extension', + 'share/contrib', 'doc', + 'doc/extension', 'doc/contrib', + 'symbols', 'share/tsearch_data'); CopySolutionOutput($conf, $target); lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); my $sample_files = []; File::Find::find( - { - wanted =>sub { + { wanted => sub { /^.*\.sample\z/s - &&push(@$sample_files, $File::Find::name); + && push(@$sample_files, $File::Find::name); } }, - "src" - ); + "src"); CopySetOfFiles('config files', $sample_files, $target . '/share/'); CopyFiles( - 'Import libraries', - $target .'/lib/', - "$conf\\", "postgres\\postgres.lib","libpq\\libpq.lib", "libecpg\\libecpg.lib", - "libpgport\\libpgport.lib" - ); + 'Import libraries', $target . '/lib/', + "$conf\\", "postgres\\postgres.lib", + "libpq\\libpq.lib", "libecpg\\libecpg.lib", + "libpgport\\libpgport.lib"); CopySetOfFiles( 'timezone names', [ glob('src\timezone\tznames\*.txt') ], - $target . '/share/timezonesets/' - ); + $target . '/share/timezonesets/'); CopyFiles( 'timezone sets', $target . '/share/timezonesets/', - 'src/timezone/tznames/', 'Default','Australia','India' - ); + 'src/timezone/tznames/', 'Default', 'Australia', 'India'); CopySetOfFiles( 'BKI files', [ glob("src\\backend\\catalog\\postgres.*") ], - $target .'/share/' - ); - CopySetOfFiles('SQL files', [ glob("src\\backend\\catalog\\*.sql") ],$target . '/share/'); + $target . '/share/'); + CopySetOfFiles( + 'SQL files', + [ glob("src\\backend\\catalog\\*.sql") ], + $target . '/share/'); CopyFiles( - 'Information schema data',$target . '/share/', - 'src/backend/catalog/', 'sql_features.txt' - ); + 'Information schema data', $target . '/share/', + 'src/backend/catalog/', 'sql_features.txt'); GenerateConversionScript($target); - GenerateTimezoneFiles($target,$conf); + GenerateTimezoneFiles($target, $conf); GenerateTsearchFiles($target); CopySetOfFiles( 'Stopword files', [ glob("src\\backend\\snowball\\stopwords\\*.stop") ], - $target . '/share/tsearch_data/' - ); + $target . '/share/tsearch_data/'); CopySetOfFiles( 'Dictionaries sample files', [ glob("src\\backend\\tsearch\\*_sample.*") ], - $target . '/share/tsearch_data/' - ); - CopyContribFiles($config,$target); + $target . '/share/tsearch_data/'); + CopyContribFiles($config, $target); CopyIncludeFiles($target); my $pl_extension_files = []; - my @pldirs = ('src/pl/plpgsql/src'); - push @pldirs,"src/pl/plperl" if $config->{perl}; - push @pldirs,"src/pl/plpython" if $config->{python}; - push @pldirs,"src/pl/tcl" if $config->{tcl}; + my @pldirs = ('src/pl/plpgsql/src'); + push @pldirs, "src/pl/plperl" if $config->{perl}; + push @pldirs, "src/pl/plpython" if $config->{python}; + push @pldirs, "src/pl/tcl" if $config->{tcl}; File::Find::find( - { - wanted =>sub { + { wanted => sub { /^(.*--.*\.sql|.*\.control)\z/s - &&push(@$pl_extension_files, - $File::Find::name); + && push(@$pl_extension_files, $File::Find::name); } }, - @pldirs - ); - CopySetOfFiles('PL Extension files', $pl_extension_files,$target . '/share/extension/'); + @pldirs); + CopySetOfFiles('PL Extension files', + $pl_extension_files, $target . '/share/extension/'); - GenerateNLSFiles($target,$config->{nls},$majorver) if ($config->{nls}); + GenerateNLSFiles($target, $config->{nls}, $majorver) if ($config->{nls}); print "Installation complete.\n"; } @@ -149,8 +145,8 @@ sub EnsureDirectories sub CopyFiles { - my $what = shift; - my $target = shift; + my $what = shift; + my $target = shift; my $basedir = shift; print "Copying $what"; @@ -166,14 +162,14 @@ sub CopyFiles sub CopySetOfFiles { - my $what = shift; - my $flist = shift; + my $what = shift; + my $flist = shift; my $target = shift; print "Copying $what" if $what; foreach (@$flist) { - next if /regress/; # Skip temporary install in regression subdir - next if /ecpg.test/; # Skip temporary install in regression subdir + next if /regress/; # Skip temporary install in regression subdir + next if /ecpg.test/; # Skip temporary install in regression subdir my $tgt = $target . basename($_); print "."; lcopy($_, $tgt) || croak "Could not copy $_: $!\n"; @@ -183,14 +179,17 @@ sub CopySetOfFiles sub CopySolutionOutput { - my $conf = shift; + my $conf = shift; my $target = shift; - my $rem = qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"}; + my $rem = + qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"}; my $sln = read_file("pgsql.sln") || croak "Could not open pgsql.sln\n"; my $vcproj = 'vcproj'; - if ($sln =~ /Microsoft Visual Studio Solution File, Format Version (\d+)\.\d+/ && $1 >= 11) + if ($sln =~ + /Microsoft Visual Studio Solution File, Format Version (\d+)\.\d+/ + && $1 >= 11) { $vcproj = 'vcxproj'; } @@ -204,7 +203,8 @@ sub CopySolutionOutput $sln =~ s/$rem//; - my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n"; + my $proj = read_file("$pf.$vcproj") + || croak "Could not open $pf.$vcproj\n"; if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"}) { if ($1 == 1) @@ -220,11 +220,11 @@ sub CopySolutionOutput else { - # Static lib, such as libpgport, only used internally during build, don't install +# Static lib, such as libpgport, only used internally during build, don't install next; } } - elsif ( $vcproj eq 'vcxproj' + elsif ($vcproj eq 'vcxproj' && $proj =~ qr{<ConfigurationType>(\w+)</ConfigurationType>}) { if ($1 eq 'Application') @@ -237,10 +237,10 @@ sub CopySolutionOutput $dir = "lib"; $ext = "dll"; } - else # 'StaticLibrary' + else # 'StaticLibrary' { - # Static lib, such as libpgport, only used internally during build, don't install +# Static lib, such as libpgport, only used internally during build, don't install next; } } @@ -248,9 +248,9 @@ sub CopySolutionOutput { croak "Could not parse $pf.$vcproj\n"; } - lcopy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext") + lcopy("$conf\\$pf\\$pf.$ext", "$target\\$dir\\$pf.$ext") || croak "Could not copy $pf.$ext\n"; - lcopy("$conf\\$pf\\$pf.pdb","$target\\symbols\\$pf.pdb") + lcopy("$conf\\$pf\\$pf.pdb", "$target\\symbols\\$pf.pdb") || croak "Could not copy $pf.pdb\n"; print "."; } @@ -260,7 +260,7 @@ sub CopySolutionOutput sub GenerateConversionScript { my $target = shift; - my $sql = ""; + my $sql = ""; my $F; print "Generating conversion proc script..."; @@ -268,14 +268,14 @@ sub GenerateConversionScript $mf =~ s{\\\s*[\r\n]+}{}mg; $mf =~ /^CONVERSIONS\s*=\s*(.*)$/m || die "Could not find CONVERSIONS line in conversions Makefile\n"; - my @pieces = split /\s+/,$1; + my @pieces = split /\s+/, $1; while ($#pieces > 0) { my $name = shift @pieces; - my $se = shift @pieces; - my $de = shift @pieces; + my $se = shift @pieces; + my $de = shift @pieces; my $func = shift @pieces; - my $obj = shift @pieces; + my $obj = shift @pieces; $sql .= "-- $se --> $de\n"; $sql .= "CREATE OR REPLACE FUNCTION $func (INTEGER, INTEGER, CSTRING, INTERNAL, INTEGER) RETURNS VOID AS '\$libdir/$obj', '$func' LANGUAGE C STRICT;\n"; @@ -283,10 +283,11 @@ sub GenerateConversionScript "COMMENT ON FUNCTION $func(INTEGER, INTEGER, CSTRING, INTERNAL, INTEGER) IS 'internal conversion function for $se to $de';\n"; $sql .= "DROP CONVERSION pg_catalog.$name;\n"; $sql .= - "CREATE DEFAULT CONVERSION pg_catalog.$name FOR '$se' TO '$de' FROM $func;\n"; - $sql .= "COMMENT ON CONVERSION pg_catalog.$name IS 'conversion for $se to $de';\n"; +"CREATE DEFAULT CONVERSION pg_catalog.$name FOR '$se' TO '$de' FROM $func;\n"; + $sql .= +"COMMENT ON CONVERSION pg_catalog.$name IS 'conversion for $se to $de';\n"; } - open($F,">$target/share/conversion_create.sql") + open($F, ">$target/share/conversion_create.sql") || die "Could not write to conversion_create.sql\n"; print $F $sql; close($F); @@ -296,12 +297,13 @@ sub GenerateConversionScript sub GenerateTimezoneFiles { my $target = shift; - my $conf = shift; - my $mf = read_file("src/timezone/Makefile"); + my $conf = shift; + my $mf = read_file("src/timezone/Makefile"); $mf =~ s{\\\s*[\r\n]+}{}mg; - $mf =~ /^TZDATA\s*:?=\s*(.*)$/m || die "Could not find TZDATA row in timezone makefile\n"; - my @tzfiles = split /\s+/,$1; - unshift @tzfiles,''; + $mf =~ /^TZDATA\s*:?=\s*(.*)$/m + || die "Could not find TZDATA row in timezone makefile\n"; + my @tzfiles = split /\s+/, $1; + unshift @tzfiles, ''; print "Generating timezone files..."; system("$conf\\zic\\zic -d \"$target/share/timezone\" " . join(" src/timezone/data/", @tzfiles)); @@ -315,21 +317,21 @@ sub GenerateTsearchFiles print "Generating tsearch script..."; my $F; my $tmpl = read_file('src/backend/snowball/snowball.sql.in'); - my $mf = read_file('src/backend/snowball/Makefile'); + my $mf = read_file('src/backend/snowball/Makefile'); $mf =~ s{\\\s*[\r\n]+}{}mg; $mf =~ /^LANGUAGES\s*=\s*(.*)$/m || die "Could not find LANGUAGES line in snowball Makefile\n"; - my @pieces = split /\s+/,$1; - open($F,">$target/share/snowball_create.sql") + my @pieces = split /\s+/, $1; + open($F, ">$target/share/snowball_create.sql") || die "Could not write snowball_create.sql"; print $F read_file('src/backend/snowball/snowball_func.sql.in'); while ($#pieces > 0) { - my $lang = shift @pieces || last; + my $lang = shift @pieces || last; my $asclang = shift @pieces || last; - my $txt = $tmpl; - my $stop = ''; + my $txt = $tmpl; + my $stop = ''; if (-s "src/backend/snowball/stopwords/$lang.stop") { @@ -361,9 +363,9 @@ sub CopyContribFiles { next if ($d =~ /^\./); next unless (-f "contrib/$d/Makefile"); - next if ($d eq "uuid-ossp"&& !defined($config->{uuid})); - next if ($d eq "sslinfo" && !defined($config->{openssl})); - next if ($d eq "xml2" && !defined($config->{xml})); + next if ($d eq "uuid-ossp" && !defined($config->{uuid})); + next if ($d eq "sslinfo" && !defined($config->{openssl})); + next if ($d eq "xml2" && !defined($config->{xml})); next if ($d eq "sepgsql"); my $mf = read_file("contrib/$d/Makefile"); @@ -373,32 +375,32 @@ sub CopyContribFiles my $moduledir = 'contrib'; my $flist = ''; - if ($mf =~ /^EXTENSION\s*=\s*(.*)$/m) {$flist .= $1} + if ($mf =~ /^EXTENSION\s*=\s*(.*)$/m) { $flist .= $1 } if ($flist ne '') { $moduledir = 'extension'; $flist = ParseAndCleanRule($flist, $mf); - foreach my $f (split /\s+/,$flist) + foreach my $f (split /\s+/, $flist) { lcopy( 'contrib/' . $d . '/' . $f . '.control', $target . '/share/extension/' . $f . '.control' - )|| croak("Could not copy file $f.control in contrib $d"); + ) || croak("Could not copy file $f.control in contrib $d"); print '.'; } } $flist = ''; - if ($mf =~ /^DATA_built\s*=\s*(.*)$/m) {$flist .= $1} - if ($mf =~ /^DATA\s*=\s*(.*)$/m) {$flist .= " $1"} - $flist =~ s/^\s*//; # Remove leading spaces if we had only DATA_built + if ($mf =~ /^DATA_built\s*=\s*(.*)$/m) { $flist .= $1 } + if ($mf =~ /^DATA\s*=\s*(.*)$/m) { $flist .= " $1" } + $flist =~ s/^\s*//; # Remove leading spaces if we had only DATA_built if ($flist ne '') { $flist = ParseAndCleanRule($flist, $mf); - foreach my $f (split /\s+/,$flist) + foreach my $f (split /\s+/, $flist) { lcopy('contrib/' . $d . '/' . $f, $target . '/share/' . $moduledir . '/' . basename($f)) @@ -408,12 +410,12 @@ sub CopyContribFiles } $flist = ''; - if ($mf =~ /^DATA_TSEARCH\s*=\s*(.*)$/m) {$flist .= $1} + if ($mf =~ /^DATA_TSEARCH\s*=\s*(.*)$/m) { $flist .= $1 } if ($flist ne '') { $flist = ParseAndCleanRule($flist, $mf); - foreach my $f (split /\s+/,$flist) + foreach my $f (split /\s+/, $flist) { lcopy('contrib/' . $d . '/' . $f, $target . '/share/tsearch_data/' . basename($f)) @@ -423,7 +425,7 @@ sub CopyContribFiles } $flist = ''; - if ($mf =~ /^DOCS\s*=\s*(.*)$/mg) {$flist .= $1} + if ($mf =~ /^DOCS\s*=\s*(.*)$/mg) { $flist .= $1 } if ($flist ne '') { $flist = ParseAndCleanRule($flist, $mf); @@ -432,7 +434,7 @@ sub CopyContribFiles $flist = "autoinc.example insert_username.example moddatetime.example refint.example timetravel.example" if ($d eq 'spi'); - foreach my $f (split /\s+/,$flist) + foreach my $f (split /\s+/, $flist) { lcopy('contrib/' . $d . '/' . $f, $target . '/doc/' . $moduledir . '/' . $f) @@ -448,20 +450,25 @@ sub CopyContribFiles sub ParseAndCleanRule { my $flist = shift; - my $mf = shift; + my $mf = shift; # Strip out $(addsuffix) rules if (index($flist, '$(addsuffix ') >= 0) { my $pcount = 0; my $i; - for ($i = index($flist, '$(addsuffix ') + 12; $i < length($flist); $i++) + for ( + $i = index($flist, '$(addsuffix ') + 12; + $i < length($flist); + $i++) { $pcount++ if (substr($flist, $i, 1) eq '('); $pcount-- if (substr($flist, $i, 1) eq ')'); - last if ($pcount < 0); + last if ($pcount < 0); } - $flist = substr($flist, 0, index($flist, '$(addsuffix ')) . substr($flist, $i+1); + $flist = + substr($flist, 0, index($flist, '$(addsuffix ')) + . substr($flist, $i + 1); } return $flist; } @@ -470,56 +477,52 @@ sub CopyIncludeFiles { my $target = shift; - EnsureDirectories($target, 'include', 'include/libpq','include/internal', - 'include/internal/libpq','include/server', 'include/server/parser'); + EnsureDirectories($target, 'include', 'include/libpq', 'include/internal', + 'include/internal/libpq', 'include/server', 'include/server/parser'); CopyFiles( 'Public headers', $target . '/include/', 'src/include/', 'postgres_ext.h', 'pg_config.h', 'pg_config_os.h', - 'pg_config_manual.h' - ); + 'pg_config_manual.h'); lcopy('src/include/libpq/libpq-fs.h', $target . '/include/libpq/') || croak 'Could not copy libpq-fs.h'; CopyFiles( 'Libpq headers', $target . '/include/', - 'src/interfaces/libpq/','libpq-fe.h', 'libpq-events.h' - ); + 'src/interfaces/libpq/', 'libpq-fe.h', 'libpq-events.h'); CopyFiles( 'Libpq internal headers', - $target .'/include/internal/', - 'src/interfaces/libpq/', 'libpq-int.h', 'pqexpbuffer.h' - ); + $target . '/include/internal/', + 'src/interfaces/libpq/', 'libpq-int.h', 'pqexpbuffer.h'); CopyFiles( 'Internal headers', $target . '/include/internal/', - 'src/include/', 'c.h', 'port.h', 'postgres_fe.h' - ); + 'src/include/', 'c.h', 'port.h', 'postgres_fe.h'); lcopy('src/include/libpq/pqcomm.h', $target . '/include/internal/libpq/') || croak 'Could not copy pqcomm.h'; CopyFiles( 'Server headers', $target . '/include/server/', - 'src/include/', 'pg_config.h', 'pg_config_os.h' - ); + 'src/include/', 'pg_config.h', 'pg_config_os.h'); CopyFiles( 'Grammar header', $target . '/include/server/parser/', - 'src/backend/parser/','gram.h' - ); - CopySetOfFiles('',[ glob("src\\include\\*.h") ],$target . '/include/server/'); + 'src/backend/parser/', 'gram.h'); + CopySetOfFiles( + '', + [ glob("src\\include\\*.h") ], + $target . '/include/server/'); my $D; opendir($D, 'src/include') || croak "Could not opendir on src/include!\n"; CopyFiles( 'PL/pgSQL header', $target . '/include/server/', - 'src/pl/plpgsql/src/', 'plpgsql.h' - ); + 'src/pl/plpgsql/src/', 'plpgsql.h'); # some xcopy progs don't like mixed slash style paths (my $ctarget = $target) =~ s!/!\\!g; @@ -533,47 +536,45 @@ sub CopyIncludeFiles EnsureDirectories("$target/include/server/$d"); system( qq{xcopy /s /i /q /r /y src\\include\\$d\\*.h "$ctarget\\include\\server\\$d\\"} - )&& croak("Failed to copy include directory $d\n"); + ) && croak("Failed to copy include directory $d\n"); } closedir($D); my $mf = read_file('src/interfaces/ecpg/include/Makefile'); $mf =~ s{\\s*[\r\n]+}{}mg; - $mf =~ /^ecpg_headers\s*=\s*(.*)$/m || croak "Could not find ecpg_headers line\n"; + $mf =~ /^ecpg_headers\s*=\s*(.*)$/m + || croak "Could not find ecpg_headers line\n"; CopyFiles( 'ECPG headers', $target . '/include/', 'src/interfaces/ecpg/include/', - 'ecpg_config.h', split /\s+/,$1 - ); - $mf =~ /^informix_headers\s*=\s*(.*)$/m || croak "Could not find informix_headers line\n"; + 'ecpg_config.h', split /\s+/, $1); + $mf =~ /^informix_headers\s*=\s*(.*)$/m + || croak "Could not find informix_headers line\n"; EnsureDirectories($target . '/include', 'informix', 'informix/esql'); CopyFiles( 'ECPG informix headers', - $target .'/include/informix/esql/', + $target . '/include/informix/esql/', 'src/interfaces/ecpg/include/', - split /\s+/,$1 - ); + split /\s+/, $1); } sub GenerateNLSFiles { - my $target = shift; - my $nlspath = shift; + my $target = shift; + my $nlspath = shift; my $majorver = shift; print "Installing NLS files..."; EnsureDirectories($target, "share/locale"); my @flist; File::Find::find( - { - wanted =>sub { + { wanted => sub { /^nls\.mk\z/s - &&!push(@flist, $File::Find::name); + && !push(@flist, $File::Find::name); } }, - "src" - ); + "src"); foreach (@flist) { my $prgm = DetermineCatalogName($_); @@ -590,7 +591,7 @@ sub GenerateNLSFiles "share/locale/$lang/LC_MESSAGES"); system( "\"$nlspath\\bin\\msgfmt\" -o \"$target\\share\\locale\\$lang\\LC_MESSAGES\\$prgm-$majorver.mo\" $_" - )&& croak("Could not run msgfmt on $dir\\$_"); + ) && croak("Could not run msgfmt on $dir\\$_"); print "."; } } @@ -599,7 +600,8 @@ sub GenerateNLSFiles sub DetermineMajorVersion { - my $f = read_file('src/include/pg_config.h') || croak 'Could not open pg_config.h'; + my $f = read_file('src/include/pg_config.h') + || croak 'Could not open pg_config.h'; $f =~ /^#define\s+PG_MAJORVERSION\s+"([^"]+)"/m || croak 'Could not determine major version'; return $1; diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index 4e6ea1f7409..ac99345fa6d 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -14,7 +14,7 @@ use base qw(Project); sub _new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{filenameExtension} = '.vcxproj'; @@ -40,8 +40,10 @@ EOF </PropertyGroup> <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> EOF - $self->WriteConfigurationPropertyGroup($f, 'Release',{wholeopt=>'false'}); - $self->WriteConfigurationPropertyGroup($f, 'Debug',{wholeopt=>'false'}); + $self->WriteConfigurationPropertyGroup($f, 'Release', + { wholeopt => 'false' }); + $self->WriteConfigurationPropertyGroup($f, 'Debug', + { wholeopt => 'false' }); print $f <<EOF; <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -61,15 +63,17 @@ EOF EOF $self->WriteItemDefinitionGroup( $f, 'Debug', - { - defs=>'_DEBUG;DEBUG=1;', - opt=>'Disabled', - strpool=>'false', - runtime=>'MultiThreadedDebugDLL' - } - ); - $self->WriteItemDefinitionGroup($f, 'Release', - {defs=>'', opt=>'Full', strpool=>'true', runtime=>'MultiThreadedDLL'}); + { defs => '_DEBUG;DEBUG=1;', + opt => 'Disabled', + strpool => 'false', + runtime => 'MultiThreadedDebugDLL' }); + $self->WriteItemDefinitionGroup( + $f, + 'Release', + { defs => '', + opt => 'Full', + strpool => 'true', + runtime => 'MultiThreadedDLL' }); } sub AddDefine @@ -83,7 +87,7 @@ sub WriteReferences { my ($self, $f) = @_; - my @references = @{$self->{references}}; + my @references = @{ $self->{references} }; if (scalar(@references)) { @@ -110,14 +114,14 @@ sub WriteFiles print $f <<EOF; <ItemGroup> EOF - my @grammarFiles = (); + my @grammarFiles = (); my @resourceFiles = (); my %uniquefiles; - foreach my $fileNameWithPath (sort keys %{$self->{files}}) + foreach my $fileNameWithPath (sort keys %{ $self->{files} }) { confess "Bad format filename '$fileNameWithPath'\n" unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); - my $dir = $1; + my $dir = $1; my $fileName = $2; if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/) { @@ -178,7 +182,7 @@ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; </CustomBuild> EOF } - else #if ($grammarFile =~ /\.l$/) + else #if ($grammarFile =~ /\.l$/) { print $f <<EOF; <CustomBuild Include="$grammarFile"> @@ -231,8 +235,8 @@ sub WriteConfigurationPropertyGroup my ($self, $f, $cfgname, $p) = @_; my $cfgtype = ($self->{type} eq "exe") - ?'Application' - :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); + ? 'Application' + : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary'); print $f <<EOF; <PropertyGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="Configuration"> @@ -269,11 +273,12 @@ sub WriteItemDefinitionGroup my ($self, $f, $cfgname, $p) = @_; my $cfgtype = ($self->{type} eq "exe") - ?'Application' - :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); + ? 'Application' + : ($self->{type} eq "dll" ? 'DynamicLibrary' : 'StaticLibrary'); my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';'); - my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; + my $targetmachine = + $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; my $includes = $self->{includes}; unless ($includes eq '' or $includes =~ /;$/) @@ -378,7 +383,7 @@ use base qw(MSBuildProject); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{vcver} = '10.00'; diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index 23023e54b7e..64e53cbf76f 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -19,7 +19,7 @@ use List::Util qw(first); use Exporter; our (@ISA, @EXPORT_OK); -@ISA = qw(Exporter); +@ISA = qw(Exporter); @EXPORT_OK = qw(Mkvcbuild); my $solution; @@ -27,26 +27,29 @@ my $libpgport; my $postgres; my $libpq; -my $contrib_defines = {'refint' => 'REFINT_VERBOSE'}; -my @contrib_uselibpq = ('dblink', 'oid2name', 'pgbench', 'pg_upgrade','vacuumlo'); -my @contrib_uselibpgport =( - 'oid2name', 'pgbench', 'pg_standby','pg_archivecleanup', - 'pg_test_fsync', 'pg_test_timing', 'pg_upgrade', 'vacuumlo' -); -my $contrib_extralibs = {'pgbench' => ['wsock32.lib']}; -my $contrib_extraincludes = {'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend']}; +my $contrib_defines = { 'refint' => 'REFINT_VERBOSE' }; +my @contrib_uselibpq = + ('dblink', 'oid2name', 'pgbench', 'pg_upgrade', 'vacuumlo'); +my @contrib_uselibpgport = ( + 'oid2name', 'pgbench', + 'pg_standby', 'pg_archivecleanup', + 'pg_test_fsync', 'pg_test_timing', + 'pg_upgrade', 'vacuumlo'); +my $contrib_extralibs = { 'pgbench' => ['wsock32.lib'] }; +my $contrib_extraincludes = + { 'tsearch2' => ['contrib/tsearch2'], 'dblink' => ['src/backend'] }; my $contrib_extrasource = { - 'cube' => ['cubescan.l','cubeparse.y'], - 'seg' => ['segscan.l','segparse.y'] -}; -my @contrib_excludes = ('pgcrypto','intagg','sepgsql'); + 'cube' => [ 'cubescan.l', 'cubeparse.y' ], + 'seg' => [ 'segscan.l', 'segparse.y' ] }; +my @contrib_excludes = ('pgcrypto', 'intagg', 'sepgsql'); sub mkvcbuild { our $config = shift; chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src'); - die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src'); + die 'Must run from root or msvc directory' + unless (-d 'src\tools\msvc' && -d 'src'); my $vsVersion = DetermineVisualStudioVersion(); @@ -60,24 +63,31 @@ sub mkvcbuild sprompt.c thread.c getopt.c getopt_long.c dirent.c rint.c win32env.c win32error.c win32setlocale.c); - $libpgport = $solution->AddProject('libpgport','lib','misc'); + $libpgport = $solution->AddProject('libpgport', 'lib', 'misc'); $libpgport->AddDefine('FRONTEND'); - $libpgport->AddFiles('src\port',@pgportfiles); + $libpgport->AddFiles('src\port', @pgportfiles); - $postgres = $solution->AddProject('postgres','exe','','src\backend'); + $postgres = $solution->AddProject('postgres', 'exe', '', 'src\backend'); $postgres->AddIncludeDir('src\backend'); $postgres->AddDir('src\backend\port\win32'); $postgres->AddFile('src\backend\utils\fmgrtab.c'); - $postgres->ReplaceFile('src\backend\port\dynloader.c','src\backend\port\dynloader\win32.c'); - $postgres->ReplaceFile('src\backend\port\pg_sema.c','src\backend\port\win32_sema.c'); - $postgres->ReplaceFile('src\backend\port\pg_shmem.c','src\backend\port\win32_shmem.c'); - $postgres->ReplaceFile('src\backend\port\pg_latch.c','src\backend\port\win32_latch.c'); - $postgres->AddFiles('src\port',@pgportfiles); + $postgres->ReplaceFile( + 'src\backend\port\dynloader.c', + 'src\backend\port\dynloader\win32.c'); + $postgres->ReplaceFile('src\backend\port\pg_sema.c', + 'src\backend\port\win32_sema.c'); + $postgres->ReplaceFile('src\backend\port\pg_shmem.c', + 'src\backend\port\win32_shmem.c'); + $postgres->ReplaceFile('src\backend\port\pg_latch.c', + 'src\backend\port\win32_latch.c'); + $postgres->AddFiles('src\port', @pgportfiles); $postgres->AddDir('src\timezone'); - $postgres->AddFiles('src\backend\parser','scan.l','gram.y'); - $postgres->AddFiles('src\backend\bootstrap','bootscanner.l','bootparse.y'); - $postgres->AddFiles('src\backend\utils\misc','guc-file.l'); - $postgres->AddFiles('src\backend\replication', 'repl_scanner.l', 'repl_gram.y'); + $postgres->AddFiles('src\backend\parser', 'scan.l', 'gram.y'); + $postgres->AddFiles('src\backend\bootstrap', 'bootscanner.l', + 'bootparse.y'); + $postgres->AddFiles('src\backend\utils\misc', 'guc-file.l'); + $postgres->AddFiles('src\backend\replication', 'repl_scanner.l', + 'repl_gram.y'); $postgres->AddDefine('BUILDING_DLL'); $postgres->AddLibrary('wsock32.lib'); $postgres->AddLibrary('ws2_32.lib'); @@ -85,34 +95,36 @@ sub mkvcbuild $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap}); $postgres->FullExportDLL('postgres.lib'); - my $snowball = $solution->AddProject('dict_snowball','dll','','src\backend\snowball'); + my $snowball = $solution->AddProject('dict_snowball', 'dll', '', + 'src\backend\snowball'); $snowball->RelocateFiles( 'src\backend\snowball\libstemmer', sub { return shift !~ /dict_snowball.c$/; - } - ); + }); $snowball->AddIncludeDir('src\include\snowball'); $snowball->AddReference($postgres); - my $plpgsql = $solution->AddProject('plpgsql','dll','PLs','src\pl\plpgsql\src'); + my $plpgsql = + $solution->AddProject('plpgsql', 'dll', 'PLs', 'src\pl\plpgsql\src'); $plpgsql->AddFiles('src\pl\plpgsql\src', 'gram.y'); $plpgsql->AddReference($postgres); if ($solution->{options}->{perl}) { my $plperlsrc = "src\\pl\\plperl\\"; - my $plperl = $solution->AddProject('plperl','dll','PLs','src\pl\plperl'); + my $plperl = + $solution->AddProject('plperl', 'dll', 'PLs', 'src\pl\plperl'); $plperl->AddIncludeDir($solution->{options}->{perl} . '/lib/CORE'); $plperl->AddDefine('PLPERL_HAVE_UID_GID'); foreach my $xs ('SPI.xs', 'Util.xs') { (my $xsc = $xs) =~ s/\.xs/.c/; - if (Solution::IsNewer("$plperlsrc$xsc","$plperlsrc$xs")) + if (Solution::IsNewer("$plperlsrc$xsc", "$plperlsrc$xs")) { my $xsubppdir = first { -e "$_\\ExtUtils\\xsubpp" } @INC; print "Building $plperlsrc$xsc...\n"; - system( $solution->{options}->{perl} + system( $solution->{options}->{perl} . '/bin/perl ' . "$xsubppdir/ExtUtils/xsubpp -typemap " . $solution->{options}->{perl} @@ -121,60 +133,58 @@ sub mkvcbuild . ">$plperlsrc$xsc"); if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc") { - unlink("$plperlsrc$xsc"); # if zero size + unlink("$plperlsrc$xsc"); # if zero size die "Failed to create $xsc.\n"; } } } - if ( - Solution::IsNewer('src\pl\plperl\perlchunks.h', + if (Solution::IsNewer( + 'src\pl\plperl\perlchunks.h', 'src\pl\plperl\plc_perlboot.pl') - ||Solution::IsNewer( - 'src\pl\plperl\perlchunks.h','src\pl\plperl\plc_trusted.pl' - ) - ) + || Solution::IsNewer( + 'src\pl\plperl\perlchunks.h', + 'src\pl\plperl\plc_trusted.pl')) { print 'Building src\pl\plperl\perlchunks.h ...' . "\n"; my $basedir = getcwd; chdir 'src\pl\plperl'; - system( $solution->{options}->{perl} + system( $solution->{options}->{perl} . '/bin/perl ' . 'text2macro.pl ' . '--strip="^(\#.*|\s*)$$" ' . 'plc_perlboot.pl plc_trusted.pl ' - . '>perlchunks.h'); + . '>perlchunks.h'); chdir $basedir; - if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h') + if ((!(-f 'src\pl\plperl\perlchunks.h')) + || -z 'src\pl\plperl\perlchunks.h') { - unlink('src\pl\plperl\perlchunks.h'); # if zero size + unlink('src\pl\plperl\perlchunks.h'); # if zero size die 'Failed to create perlchunks.h' . "\n"; } } - if ( - Solution::IsNewer( + if (Solution::IsNewer( 'src\pl\plperl\plperl_opmask.h', - 'src\pl\plperl\plperl_opmask.pl' - ) - ) + 'src\pl\plperl\plperl_opmask.pl')) { print 'Building src\pl\plperl\plperl_opmask.h ...' . "\n"; my $basedir = getcwd; chdir 'src\pl\plperl'; - system( $solution->{options}->{perl} + system( $solution->{options}->{perl} . '/bin/perl ' . 'plperl_opmask.pl ' - . 'plperl_opmask.h'); + . 'plperl_opmask.h'); chdir $basedir; if ((!(-f 'src\pl\plperl\plperl_opmask.h')) || -z 'src\pl\plperl\plperl_opmask.h') { - unlink('src\pl\plperl\plperl_opmask.h'); # if zero size + unlink('src\pl\plperl\plperl_opmask.h'); # if zero size die 'Failed to create plperl_opmask.h' . "\n"; } } $plperl->AddReference($postgres); my @perl_libs = - grep {/perl\d+.lib$/ }glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib'); + grep { /perl\d+.lib$/ } + glob($solution->{options}->{perl} . '\lib\CORE\perl*.lib'); if (@perl_libs == 1) { $plperl->AddLibrary($perl_libs[0]); @@ -206,8 +216,8 @@ sub mkvcbuild if (!(defined($pyprefix) && defined($pyver))); my $pymajorver = substr($pyver, 0, 1); - my $plpython = - $solution->AddProject('plpython' . $pymajorver, 'dll','PLs', 'src\pl\plpython'); + my $plpython = $solution->AddProject('plpython' . $pymajorver, + 'dll', 'PLs', 'src\pl\plpython'); $plpython->AddIncludeDir($pyprefix . '\include'); $plpython->AddLibrary($pyprefix . "\\Libs\\python$pyver.lib"); $plpython->AddReference($postgres); @@ -215,20 +225,24 @@ sub mkvcbuild if ($solution->{options}->{tcl}) { - my $pltcl = $solution->AddProject('pltcl','dll','PLs','src\pl\tcl'); + my $pltcl = + $solution->AddProject('pltcl', 'dll', 'PLs', 'src\pl\tcl'); $pltcl->AddIncludeDir($solution->{options}->{tcl} . '\include'); $pltcl->AddReference($postgres); if (-e $solution->{options}->{tcl} . '\lib\tcl85.lib') { - $pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl85.lib'); + $pltcl->AddLibrary( + $solution->{options}->{tcl} . '\lib\tcl85.lib'); } else { - $pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl84.lib'); + $pltcl->AddLibrary( + $solution->{options}->{tcl} . '\lib\tcl84.lib'); } } - $libpq = $solution->AddProject('libpq','dll','interfaces','src\interfaces\libpq'); + $libpq = $solution->AddProject('libpq', 'dll', 'interfaces', + 'src\interfaces\libpq'); $libpq->AddDefine('FRONTEND'); $libpq->AddDefine('UNSAFE_STAT_OK'); $libpq->AddIncludeDir('src\port'); @@ -237,50 +251,56 @@ sub mkvcbuild $libpq->AddLibrary('ws2_32.lib'); $libpq->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap}); $libpq->UseDef('src\interfaces\libpq\libpqdll.def'); - $libpq->ReplaceFile('src\interfaces\libpq\libpqrc.c','src\interfaces\libpq\libpq.rc'); + $libpq->ReplaceFile('src\interfaces\libpq\libpqrc.c', + 'src\interfaces\libpq\libpq.rc'); $libpq->AddReference($libpgport); - my $libpqwalreceiver = $solution->AddProject('libpqwalreceiver', 'dll', '', + my $libpqwalreceiver = + $solution->AddProject('libpqwalreceiver', 'dll', '', 'src\backend\replication\libpqwalreceiver'); $libpqwalreceiver->AddIncludeDir('src\interfaces\libpq'); - $libpqwalreceiver->AddReference($postgres,$libpq); + $libpqwalreceiver->AddReference($postgres, $libpq); - my $pgtypes = - $solution->AddProject('libpgtypes','dll','interfaces','src\interfaces\ecpg\pgtypeslib'); + my $pgtypes = $solution->AddProject( + 'libpgtypes', 'dll', + 'interfaces', 'src\interfaces\ecpg\pgtypeslib'); $pgtypes->AddDefine('FRONTEND'); $pgtypes->AddReference($libpgport); $pgtypes->UseDef('src\interfaces\ecpg\pgtypeslib\pgtypeslib.def'); $pgtypes->AddIncludeDir('src\interfaces\ecpg\include'); - my $libecpg = - $solution->AddProject('libecpg','dll','interfaces','src\interfaces\ecpg\ecpglib'); + my $libecpg = $solution->AddProject('libecpg', 'dll', 'interfaces', + 'src\interfaces\ecpg\ecpglib'); $libecpg->AddDefine('FRONTEND'); $libecpg->AddIncludeDir('src\interfaces\ecpg\include'); $libecpg->AddIncludeDir('src\interfaces\libpq'); $libecpg->AddIncludeDir('src\port'); $libecpg->UseDef('src\interfaces\ecpg\ecpglib\ecpglib.def'); $libecpg->AddLibrary('wsock32.lib'); - $libecpg->AddReference($libpq,$pgtypes,$libpgport); + $libecpg->AddReference($libpq, $pgtypes, $libpgport); - my $libecpgcompat =$solution->AddProject('libecpg_compat','dll','interfaces', - 'src\interfaces\ecpg\compatlib'); + my $libecpgcompat = $solution->AddProject( + 'libecpg_compat', 'dll', + 'interfaces', 'src\interfaces\ecpg\compatlib'); $libecpgcompat->AddIncludeDir('src\interfaces\ecpg\include'); $libecpgcompat->AddIncludeDir('src\interfaces\libpq'); $libecpgcompat->UseDef('src\interfaces\ecpg\compatlib\compatlib.def'); - $libecpgcompat->AddReference($pgtypes,$libecpg,$libpgport); + $libecpgcompat->AddReference($pgtypes, $libecpg, $libpgport); - my $ecpg = $solution->AddProject('ecpg','exe','interfaces','src\interfaces\ecpg\preproc'); + my $ecpg = $solution->AddProject('ecpg', 'exe', 'interfaces', + 'src\interfaces\ecpg\preproc'); $ecpg->AddIncludeDir('src\interfaces\ecpg\include'); $ecpg->AddIncludeDir('src\interfaces\libpq'); $ecpg->AddPrefixInclude('src\interfaces\ecpg\preproc'); - $ecpg->AddFiles('src\interfaces\ecpg\preproc','pgc.l','preproc.y'); + $ecpg->AddFiles('src\interfaces\ecpg\preproc', 'pgc.l', 'preproc.y'); $ecpg->AddDefine('MAJOR_VERSION=4'); $ecpg->AddDefine('MINOR_VERSION=2'); $ecpg->AddDefine('PATCHLEVEL=1'); $ecpg->AddDefine('ECPG_COMPILE'); $ecpg->AddReference($libpgport); - my $pgregress_ecpg = $solution->AddProject('pg_regress_ecpg','exe','misc'); + my $pgregress_ecpg = + $solution->AddProject('pg_regress_ecpg', 'exe', 'misc'); $pgregress_ecpg->AddFile('src\interfaces\ecpg\test\pg_regress_ecpg.c'); $pgregress_ecpg->AddFile('src\test\regress\pg_regress.c'); $pgregress_ecpg->AddIncludeDir('src\port'); @@ -289,7 +309,8 @@ sub mkvcbuild $pgregress_ecpg->AddDefine('FRONTEND'); $pgregress_ecpg->AddReference($libpgport); - my $isolation_tester = $solution->AddProject('isolationtester','exe','misc'); + my $isolation_tester = + $solution->AddProject('isolationtester', 'exe', 'misc'); $isolation_tester->AddFile('src\test\isolation\isolationtester.c'); $isolation_tester->AddFile('src\test\isolation\specparse.y'); $isolation_tester->AddFile('src\test\isolation\specscanner.l'); @@ -303,7 +324,8 @@ sub mkvcbuild $isolation_tester->AddLibrary('wsock32.lib'); $isolation_tester->AddReference($libpq, $libpgport); - my $pgregress_isolation = $solution->AddProject('pg_isolation_regress','exe','misc'); + my $pgregress_isolation = + $solution->AddProject('pg_isolation_regress', 'exe', 'misc'); $pgregress_isolation->AddFile('src\test\isolation\isolation_main.c'); $pgregress_isolation->AddFile('src\test\regress\pg_regress.c'); $pgregress_isolation->AddIncludeDir('src\port'); @@ -337,9 +359,10 @@ sub mkvcbuild my $pgreset = AddSimpleFrontend('pg_resetxlog'); - my $pgevent = $solution->AddProject('pgevent','dll','bin'); - $pgevent->AddFiles('src\bin\pgevent','pgevent.c','pgmsgevent.rc'); - $pgevent->AddResourceFile('src\bin\pgevent','Eventlog message formatter'); + my $pgevent = $solution->AddProject('pgevent', 'dll', 'bin'); + $pgevent->AddFiles('src\bin\pgevent', 'pgevent.c', 'pgmsgevent.rc'); + $pgevent->AddResourceFile('src\bin\pgevent', + 'Eventlog message formatter'); $pgevent->RemoveFile('src\bin\pgevent\win32ver.rc'); $pgevent->UseDef('src\bin\pgevent\pgevent.def'); $pgevent->DisableLinkerWarnings('4104'); @@ -363,9 +386,9 @@ sub mkvcbuild # pg_dump and pg_restore. # So remove their sources from the object, keeping the other setup that # AddSimpleFrontend() has done. - my @nodumpall = grep { m/src\\bin\\pg_dump\\.*\.c$/ } - keys %{$pgdumpall->{files}}; - delete @{$pgdumpall->{files}}{@nodumpall}; + my @nodumpall = grep { m/src\\bin\\pg_dump\\.*\.c$/ } + keys %{ $pgdumpall->{files} }; + delete @{ $pgdumpall->{files} }{@nodumpall}; $pgdumpall->{name} = 'pg_dumpall'; $pgdumpall->AddIncludeDir('src\backend'); $pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c'); @@ -381,8 +404,9 @@ sub mkvcbuild $pgrestore->AddFile('src\bin\pg_dump\keywords.c'); $pgrestore->AddFile('src\backend\parser\kwlookup.c'); - my $zic = $solution->AddProject('zic','exe','utils'); - $zic->AddFiles('src\timezone','zic.c','ialloc.c','scheck.c','localtime.c'); + my $zic = $solution->AddProject('zic', 'exe', 'utils'); + $zic->AddFiles('src\timezone', 'zic.c', 'ialloc.c', 'scheck.c', + 'localtime.c'); $zic->AddReference($libpgport); if ($solution->{options}->{xml}) @@ -390,22 +414,20 @@ sub mkvcbuild $contrib_extraincludes->{'pgxml'} = [ $solution->{options}->{xml} . '\include', $solution->{options}->{xslt} . '\include', - $solution->{options}->{iconv} . '\include' - ]; + $solution->{options}->{iconv} . '\include' ]; $contrib_extralibs->{'pgxml'} = [ $solution->{options}->{xml} . '\lib\libxml2.lib', - $solution->{options}->{xslt} . '\lib\libxslt.lib' - ]; + $solution->{options}->{xslt} . '\lib\libxslt.lib' ]; } else { - push @contrib_excludes,'xml2'; + push @contrib_excludes, 'xml2'; } if (!$solution->{options}->{openssl}) { - push @contrib_excludes,'sslinfo'; + push @contrib_excludes, 'sslinfo'; } if ($solution->{options}->{uuid}) @@ -417,33 +439,38 @@ sub mkvcbuild } else { - push @contrib_excludes,'uuid-ossp'; + push @contrib_excludes, 'uuid-ossp'; } # Pgcrypto makefile too complex to parse.... - my $pgcrypto = $solution->AddProject('pgcrypto','dll','crypto'); + my $pgcrypto = $solution->AddProject('pgcrypto', 'dll', 'crypto'); $pgcrypto->AddFiles( - 'contrib\pgcrypto','pgcrypto.c','px.c','px-hmac.c', - 'px-crypt.c','crypt-gensalt.c','crypt-blowfish.c','crypt-des.c', - 'crypt-md5.c','mbuf.c','pgp.c','pgp-armor.c', - 'pgp-cfb.c','pgp-compress.c','pgp-decrypt.c','pgp-encrypt.c', - 'pgp-info.c','pgp-mpi.c','pgp-pubdec.c','pgp-pubenc.c', - 'pgp-pubkey.c','pgp-s2k.c','pgp-pgsql.c' - ); + 'contrib\pgcrypto', 'pgcrypto.c', + 'px.c', 'px-hmac.c', + 'px-crypt.c', 'crypt-gensalt.c', + 'crypt-blowfish.c', 'crypt-des.c', + 'crypt-md5.c', 'mbuf.c', + 'pgp.c', 'pgp-armor.c', + 'pgp-cfb.c', 'pgp-compress.c', + 'pgp-decrypt.c', 'pgp-encrypt.c', + 'pgp-info.c', 'pgp-mpi.c', + 'pgp-pubdec.c', 'pgp-pubenc.c', + 'pgp-pubkey.c', 'pgp-s2k.c', + 'pgp-pgsql.c'); if ($solution->{options}->{openssl}) { - $pgcrypto->AddFiles('contrib\pgcrypto', 'openssl.c','pgp-mpi-openssl.c'); + $pgcrypto->AddFiles('contrib\pgcrypto', 'openssl.c', + 'pgp-mpi-openssl.c'); } else { $pgcrypto->AddFiles( - 'contrib\pgcrypto', 'md5.c', - 'sha1.c','sha2.c', - 'internal.c','internal-sha2.c', - 'blf.c','rijndael.c', - 'fortuna.c','random.c', - 'pgp-mpi-internal.c','imath.c' - ); + 'contrib\pgcrypto', 'md5.c', + 'sha1.c', 'sha2.c', + 'internal.c', 'internal-sha2.c', + 'blf.c', 'rijndael.c', + 'fortuna.c', 'random.c', + 'pgp-mpi-internal.c', 'imath.c'); } $pgcrypto->AddReference($postgres); $pgcrypto->AddLibrary('wsock32.lib'); @@ -456,35 +483,43 @@ sub mkvcbuild { next if ($d =~ /^\./); next unless (-f "contrib/$d/Makefile"); - next if (grep {/^$d$/} @contrib_excludes); + next if (grep { /^$d$/ } @contrib_excludes); AddContrib($d); } closedir($D); - $mf = Project::read_file('src\backend\utils\mb\conversion_procs\Makefile'); + $mf = + Project::read_file('src\backend\utils\mb\conversion_procs\Makefile'); $mf =~ s{\\s*[\r\n]+}{}mg; - $mf =~ m{SUBDIRS\s*=\s*(.*)$}m || die 'Could not match in conversion makefile' . "\n"; - foreach my $sub (split /\s+/,$1) + $mf =~ m{SUBDIRS\s*=\s*(.*)$}m + || die 'Could not match in conversion makefile' . "\n"; + foreach my $sub (split /\s+/, $1) { my $mf = Project::read_file( 'src\backend\utils\mb\conversion_procs\\' . $sub . '\Makefile'); my $p = $solution->AddProject($sub, 'dll', 'conversion procs'); - $p->AddFile('src\backend\utils\mb\conversion_procs\\' . $sub . '\\' . $sub . '.c'); + $p->AddFile('src\backend\utils\mb\conversion_procs\\' + . $sub . '\\' + . $sub + . '.c'); if ($mf =~ m{^SRCS\s*\+=\s*(.*)$}m) { - $p->AddFile('src\backend\utils\mb\conversion_procs\\' . $sub . '\\' . $1); + $p->AddFile( + 'src\backend\utils\mb\conversion_procs\\' . $sub . '\\' . $1); } $p->AddReference($postgres); } $mf = Project::read_file('src\bin\scripts\Makefile'); $mf =~ s{\\s*[\r\n]+}{}mg; - $mf =~ m{PROGRAMS\s*=\s*(.*)$}m || die 'Could not match in bin\scripts\Makefile' . "\n"; - foreach my $prg (split /\s+/,$1) + $mf =~ m{PROGRAMS\s*=\s*(.*)$}m + || die 'Could not match in bin\scripts\Makefile' . "\n"; + foreach my $prg (split /\s+/, $1) { - my $proj = $solution->AddProject($prg,'exe','bin'); - $mf =~ m{$prg\s*:\s*(.*)$}m || die 'Could not find script define for $prg' . "\n"; - my @files = split /\s+/,$1; + my $proj = $solution->AddProject($prg, 'exe', 'bin'); + $mf =~ m{$prg\s*:\s*(.*)$}m + || die 'Could not find script define for $prg' . "\n"; + my @files = split /\s+/, $1; foreach my $f (@files) { $f =~ s/\.o$/\.c/; @@ -501,7 +536,7 @@ sub mkvcbuild $proj->AddFile('src\bin\pg_dump\dumputils.c'); } elsif ($f =~ /print\.c$/) - { # Also catches mbprint.c + { # Also catches mbprint.c $proj->AddFile('src\bin\psql\\' . $f); } elsif ($f =~ /\.c$/) @@ -512,16 +547,16 @@ sub mkvcbuild $proj->AddIncludeDir('src\interfaces\libpq'); $proj->AddIncludeDir('src\bin\pg_dump'); $proj->AddIncludeDir('src\bin\psql'); - $proj->AddReference($libpq,$libpgport); - $proj->AddResourceFile('src\bin\scripts','PostgreSQL Utility'); + $proj->AddReference($libpq, $libpgport); + $proj->AddResourceFile('src\bin\scripts', 'PostgreSQL Utility'); } # Regression DLL and EXE - my $regress = $solution->AddProject('regress','dll','misc'); + my $regress = $solution->AddProject('regress', 'dll', 'misc'); $regress->AddFile('src\test\regress\regress.c'); $regress->AddReference($postgres); - my $pgregress = $solution->AddProject('pg_regress','exe','misc'); + my $pgregress = $solution->AddProject('pg_regress', 'exe', 'misc'); $pgregress->AddFile('src\test\regress\pg_regress.c'); $pgregress->AddFile('src\test\regress\pg_regress_main.c'); $pgregress->AddIncludeDir('src\port'); @@ -539,10 +574,10 @@ sub mkvcbuild # Add a simple frontend project (exe) sub AddSimpleFrontend { - my $n = shift; - my $uselibpq= shift; + my $n = shift; + my $uselibpq = shift; - my $p = $solution->AddProject($n,'exe','bin'); + my $p = $solution->AddProject($n, 'exe', 'bin'); $p->AddDir('src\bin\\' . $n); $p->AddReference($libpgport); if ($uselibpq) @@ -556,7 +591,7 @@ sub AddSimpleFrontend # Add a simple contrib project sub AddContrib { - my $n = shift; + my $n = shift; my $mf = Project::read_file('contrib\\' . $n . '\Makefile'); if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg) @@ -578,8 +613,8 @@ sub AddContrib { foreach my $d (split /\s+/, $1) { - my $mf2 = - Project::read_file('contrib\\' . $n . '\\' . $d . '\Makefile'); + my $mf2 = Project::read_file( + 'contrib\\' . $n . '\\' . $d . '\Makefile'); $mf2 =~ s{\\\s*[\r\n]+}{}mg; $mf2 =~ /^SUBOBJS\s*=\s*(.*)$/gm || croak @@ -609,7 +644,8 @@ sub AddContrib { my $proj = $solution->AddProject($1, 'exe', 'contrib'); $mf =~ s{\\\s*[\r\n]+}{}mg; - $mf =~ /^OBJS\s*=\s*(.*)$/gm || croak "Could not find objects in PROGRAM for $n\n"; + $mf =~ /^OBJS\s*=\s*(.*)$/gm + || croak "Could not find objects in PROGRAM for $n\n"; my $objs = $1; while ($objs =~ /\b([\w-]+\.o)\b/g) { @@ -630,7 +666,7 @@ sub AddContrib sub GenerateContribSqlFiles { - my $n = shift; + my $n = shift; my $mf = shift; if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg) { @@ -645,25 +681,26 @@ sub GenerateContribSqlFiles { $pcount++ if (substr($l, $i, 1) eq '('); $pcount-- if (substr($l, $i, 1) eq ')'); - last if ($pcount < 0); + last if ($pcount < 0); } - $l = substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i+1); + $l = + substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i + 1); } foreach my $d (split /\s+/, $l) { - my $in = "$d.in"; + my $in = "$d.in"; my $out = "$d"; if (Solution::IsNewer("contrib/$n/$out", "contrib/$n/$in")) { print "Building $out from $in (contrib/$n)...\n"; my $cont = Project::read_file("contrib/$n/$in"); - my $dn = $out; - $dn =~ s/\.sql$//; + my $dn = $out; + $dn =~ s/\.sql$//; $cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g; my $o; - open($o,">contrib/$n/$out") + open($o, ">contrib/$n/$out") || croak "Could not write to contrib/$n/$d"; print $o $cont; close($o); @@ -675,7 +712,7 @@ sub GenerateContribSqlFiles sub AdjustContribProj { my $proj = shift; - my $n = $proj->{name}; + my $n = $proj->{name}; if ($contrib_defines->{$n}) { @@ -684,32 +721,32 @@ sub AdjustContribProj $proj->AddDefine($d); } } - if (grep {/^$n$/} @contrib_uselibpq) + if (grep { /^$n$/ } @contrib_uselibpq) { $proj->AddIncludeDir('src\interfaces\libpq'); $proj->AddReference($libpq); } - if (grep {/^$n$/} @contrib_uselibpgport) + if (grep { /^$n$/ } @contrib_uselibpgport) { $proj->AddReference($libpgport); } if ($contrib_extralibs->{$n}) { - foreach my $l (@{$contrib_extralibs->{$n}}) + foreach my $l (@{ $contrib_extralibs->{$n} }) { $proj->AddLibrary($l); } } if ($contrib_extraincludes->{$n}) { - foreach my $i (@{$contrib_extraincludes->{$n}}) + foreach my $i (@{ $contrib_extraincludes->{$n} }) { $proj->AddIncludeDir($i); } } if ($contrib_extrasource->{$n}) { - $proj->AddFiles('contrib\\' . $n, @{$contrib_extrasource->{$n}}); + $proj->AddFiles('contrib\\' . $n, @{ $contrib_extrasource->{$n} }); } } diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm index 53cfdb17538..6f359bfdbcb 100644 --- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -16,8 +16,7 @@ sub _new my $good_types = { lib => 1, exe => 1, - dll => 1, - }; + dll => 1, }; confess("Bad project type: $type\n") unless exists $good_types->{$type}; my $self = { name => $name, @@ -33,8 +32,7 @@ sub _new solution => $solution, disablewarnings => '4018;4244;4273;4102;4090;4267', disablelinkerwarnings => '', - platform => $solution->{platform}, - }; + platform => $solution->{platform}, }; bless($self, $classname); return $self; @@ -50,11 +48,11 @@ sub AddFile sub AddFiles { my $self = shift; - my $dir = shift; + my $dir = shift; while (my $f = shift) { - $self->{files}->{$dir . "\\" . $f} = 1; + $self->{files}->{ $dir . "\\" . $f } = 1; } } @@ -63,7 +61,7 @@ sub ReplaceFile my ($self, $filename, $newname) = @_; my $re = "\\\\$filename\$"; - foreach my $file (keys %{$self->{files}}) + foreach my $file (keys %{ $self->{files} }) { # Match complete filename @@ -89,9 +87,9 @@ sub ReplaceFile sub RemoveFile { my ($self, $filename) = @_; - my $orig = scalar keys %{$self->{files}}; + my $orig = scalar keys %{ $self->{files} }; delete $self->{files}->{$filename}; - if ($orig > scalar keys %{$self->{files}}) + if ($orig > scalar keys %{ $self->{files} }) { return; } @@ -101,7 +99,7 @@ sub RemoveFile sub RelocateFiles { my ($self, $targetdir, $proc) = @_; - foreach my $f (keys %{$self->{files}}) + foreach my $f (keys %{ $self->{files} }) { my $r = &$proc($f); if ($r) @@ -118,8 +116,9 @@ sub AddReference while (my $ref = shift) { - push @{$self->{references}},$ref; - $self->AddLibrary("__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); + push @{ $self->{references} }, $ref; + $self->AddLibrary( + "__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); } } @@ -132,10 +131,10 @@ sub AddLibrary $lib = '"' . $lib . """; } - push @{$self->{libraries}}, $lib; + push @{ $self->{libraries} }, $lib; if ($dbgsuffix) { - push @{$self->{suffixlib}}, $lib; + push @{ $self->{suffixlib} }, $lib; } } @@ -170,8 +169,8 @@ sub FullExportDLL my ($self, $libname) = @_; $self->{builddef} = 1; - $self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; - $self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; + $self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; + $self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; } sub UseDef @@ -188,8 +187,8 @@ sub AddDir my $t = $/; undef $/; - open($MF,"$reldir\\Makefile") - || open($MF,"$reldir\\GNUMakefile") + open($MF, "$reldir\\Makefile") + || open($MF, "$reldir\\GNUMakefile") || croak "Could not open $reldir\\Makefile\n"; my $mf = <$MF>; close($MF); @@ -197,11 +196,11 @@ sub AddDir $mf =~ s{\\\s*[\r\n]+}{}mg; if ($mf =~ m{^(?:SUB)?DIRS[^=]*=\s*(.*)$}mg) { - foreach my $subdir (split /\s+/,$1) + foreach my $subdir (split /\s+/, $1) { next if $subdir eq "\$(top_builddir)/src/timezone" - ; #special case for non-standard include + ; #special case for non-standard include next if $reldir . "\\" . $subdir eq "src\\backend\\port\\darwin"; @@ -210,13 +209,13 @@ sub AddDir } while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m) { - my $s = $1; + my $s = $1; my $filter_re = qr{\$\(filter ([^,]+),\s+\$\(([^\)]+)\)\)}; while ($s =~ /$filter_re/) { # Process $(filter a b c, $(VAR)) expressions - my $list = $1; + my $list = $1; my $filter = $2; $list =~ s/\.o/\.c/g; my @pieces = split /\s+/, $list; @@ -239,12 +238,13 @@ sub AddDir } $s =~ s/$filter_re/$matches/; } - foreach my $f (split /\s+/,$s) + foreach my $f (split /\s+/, $s) { next if $f =~ /^\s*$/; next if $f eq "\\"; next if $f =~ /\/SUBSYS.o$/; - $f =~ s/,$//; # Remove trailing comma that can show up from filter stuff + $f =~ s/,$// + ; # Remove trailing comma that can show up from filter stuff next unless $f =~ /.*\.o$/; $f =~ s/\.o$/\.c/; if ($f =~ /^\$\(top_builddir\)\/(.*)/) @@ -264,14 +264,15 @@ sub AddDir # Match rules that pull in source files from different directories, eg # pgstrcasecmp.c rint.c snprintf.c: % : $(top_srcdir)/src/port/% - my $replace_re = qr{^([^:\n\$]+\.c)\s*:\s*(?:%\s*: )?\$(\([^\)]+\))\/(.*)\/[^\/]+$}m; + my $replace_re = + qr{^([^:\n\$]+\.c)\s*:\s*(?:%\s*: )?\$(\([^\)]+\))\/(.*)\/[^\/]+$}m; while ($mf =~ m{$replace_re}m) { - my $match = $1; - my $top = $2; + my $match = $1; + my $top = $2; my $target = $3; $target =~ s{/}{\\}g; - my @pieces = split /\s+/,$match; + my @pieces = split /\s+/, $match; foreach my $fn (@pieces) { if ($top eq "(top_srcdir)") @@ -296,7 +297,7 @@ sub AddDir my $desc = $1; my $ico; if ($mf =~ /^PGAPPICON\s*=\s*(.*)$/m) { $ico = $1; } - $self->AddResourceFile($reldir,$desc,$ico); + $self->AddResourceFile($reldir, $desc, $ico); } $/ = $t; } @@ -305,15 +306,18 @@ sub AddResourceFile { my ($self, $dir, $desc, $ico) = @_; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + localtime(time); my $d = ($year - 100) . "$yday"; - if (Solution::IsNewer("$dir\\win32ver.rc",'src\port\win32ver.rc')) + if (Solution::IsNewer("$dir\\win32ver.rc", 'src\port\win32ver.rc')) { print "Generating win32ver.rc for $dir\n"; - open(I,'src\port\win32ver.rc') || confess "Could not open win32ver.rc"; - open(O,">$dir\\win32ver.rc") || confess "Could not write win32ver.rc"; - my $icostr = $ico?"IDI_ICON ICON \"src/port/$ico.ico\"":""; + open(I, 'src\port\win32ver.rc') + || confess "Could not open win32ver.rc"; + open(O, ">$dir\\win32ver.rc") + || confess "Could not write win32ver.rc"; + my $icostr = $ico ? "IDI_ICON ICON \"src/port/$ico.ico\"" : ""; while (<I>) { s/FILEDESC/"$desc"/gm; @@ -335,7 +339,8 @@ sub DisableLinkerWarnings { my ($self, $warnings) = @_; - $self->{disablelinkerwarnings} .= ',' unless ($self->{disablelinkerwarnings} eq ''); + $self->{disablelinkerwarnings} .= ',' + unless ($self->{disablelinkerwarnings} eq ''); $self->{disablelinkerwarnings} .= $warnings; } @@ -343,20 +348,21 @@ sub Save { my ($self) = @_; - # If doing DLL and haven't specified a DEF file, do a full export of all symbols - # in the project. +# If doing DLL and haven't specified a DEF file, do a full export of all symbols +# in the project. if ($self->{type} eq "dll" && !$self->{def}) { $self->FullExportDLL($self->{name} . ".lib"); } - # Warning 4197 is about double exporting, disable this per - # http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99193 +# Warning 4197 is about double exporting, disable this per +# http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99193 $self->DisableLinkerWarnings('4197') if ($self->{platform} eq 'x64'); # Dump the project open(F, ">$self->{name}$self->{filenameExtension}") - || croak("Could not write to $self->{name}$self->{filenameExtension}\n"); + || croak( + "Could not write to $self->{name}$self->{filenameExtension}\n"); $self->WriteHeader(*F); $self->WriteFiles(*F); $self->Footer(*F); @@ -366,12 +372,12 @@ sub Save sub GetAdditionalLinkerDependencies { my ($self, $cfgname, $seperator) = @_; - my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd"; + my $libcfg = (uc $cfgname eq "RELEASE") ? "MD" : "MDd"; my $libs = ''; - foreach my $lib (@{$self->{libraries}}) + foreach my $lib (@{ $self->{libraries} }) { my $xlib = $lib; - foreach my $slib (@{$self->{suffixlib}}) + foreach my $slib (@{ $self->{suffixlib} }) { if ($slib eq $lib) { diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 0c50c057347..d6b79dcc29c 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -13,15 +13,14 @@ use VSObjectFactory; sub _new { my $classname = shift; - my $options = shift; - my $self = { + my $options = shift; + my $self = { projects => {}, options => $options, numver => '', strver => '', vcver => undef, - platform => undef, - }; + platform => undef, }; bless($self, $classname); # integer_datetimes is now the default @@ -37,22 +36,23 @@ sub _new } } $options->{blocksize} = 8 - unless $options->{blocksize}; # undef or 0 means default + unless $options->{blocksize}; # undef or 0 means default die "Bad blocksize $options->{blocksize}" - unless grep {$_ == $options->{blocksize}} (1,2,4,8,16,32); + unless grep { $_ == $options->{blocksize} } (1, 2, 4, 8, 16, 32); $options->{segsize} = 1 - unless $options->{segsize}; # undef or 0 means default - # only allow segsize 1 for now, as we can't do large files yet in windows + unless $options->{segsize}; # undef or 0 means default + # only allow segsize 1 for now, as we can't do large files yet in windows die "Bad segsize $options->{segsize}" unless $options->{segsize} == 1; $options->{wal_blocksize} = 8 - unless $options->{wal_blocksize}; # undef or 0 means default + unless $options->{wal_blocksize}; # undef or 0 means default die "Bad wal_blocksize $options->{wal_blocksize}" - unless grep {$_ == $options->{wal_blocksize}} (1,2,4,8,16,32,64); + unless grep { $_ == $options->{wal_blocksize} } + (1, 2, 4, 8, 16, 32, 64); $options->{wal_segsize} = 16 - unless $options->{wal_segsize}; # undef or 0 means default + unless $options->{wal_segsize}; # undef or 0 means default die "Bad wal_segsize $options->{wal_segsize}" - unless grep {$_ == $options->{wal_segsize}} (1,2,4,8,16,32,64); + unless grep { $_ == $options->{wal_segsize} } (1, 2, 4, 8, 16, 32, 64); $self->DeterminePlatform(); @@ -66,7 +66,7 @@ sub DeterminePlatform # Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has # 64-bit only parameters. $self->{platform} = 'Win32'; - open(P,"cl /? 2>NUL|") || die "cl command not found"; + open(P, "cl /? 2>NUL|") || die "cl command not found"; while (<P>) { if (/^\/favor:</) @@ -84,7 +84,7 @@ sub DeterminePlatform sub IsNewer { my ($newfile, $oldfile) = @_; - if ( $oldfile ne 'src\tools\msvc\config.pl' + if ( $oldfile ne 'src\tools\msvc\config.pl' && $oldfile ne 'src\tools\msvc\config_default.pl') { return 1 @@ -105,8 +105,8 @@ sub IsNewer sub copyFile { my ($src, $dest) = @_; - open(I,$src) || croak "Could not open $src"; - open(O,">$dest") || croak "Could not open $dest"; + open(I, $src) || croak "Could not open $src"; + open(O, ">$dest") || croak "Could not open $dest"; while (<I>) { print O; @@ -121,7 +121,8 @@ sub GenerateFiles my $bits = $self->{platform} eq 'Win32' ? 32 : 64; # Parse configure.in to get version numbers - open(C,"configure.in") || confess("Could not open configure.in for reading\n"); + open(C, "configure.in") + || confess("Could not open configure.in for reading\n"); while (<C>) { if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/) @@ -131,7 +132,7 @@ sub GenerateFiles { confess "Bad format of version: $self->{strver}\n"; } - $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3?$3:0); + $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3 ? $3 : 0); $self->{majorver} = sprintf("%d.%d", $1, $2); } } @@ -139,18 +140,22 @@ sub GenerateFiles confess "Unable to parse configure.in for all variables!" if ($self->{strver} eq '' || $self->{numver} eq ''); - if (IsNewer("src\\include\\pg_config_os.h","src\\include\\port\\win32.h")) + if (IsNewer( + "src\\include\\pg_config_os.h", "src\\include\\port\\win32.h")) { print "Copying pg_config_os.h...\n"; - copyFile("src\\include\\port\\win32.h","src\\include\\pg_config_os.h"); + copyFile("src\\include\\port\\win32.h", + "src\\include\\pg_config_os.h"); } - if (IsNewer("src\\include\\pg_config.h","src\\include\\pg_config.h.win32")) + if (IsNewer( + "src\\include\\pg_config.h", "src\\include\\pg_config.h.win32")) { print "Generating pg_config.h...\n"; - open(I,"src\\include\\pg_config.h.win32") + open(I, "src\\include\\pg_config.h.win32") || confess "Could not open pg_config.h.win32\n"; - open(O,">src\\include\\pg_config.h") || confess "Could not write to pg_config.h\n"; + open(O, ">src\\include\\pg_config.h") + || confess "Could not write to pg_config.h\n"; while (<I>) { s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}"}; @@ -159,22 +164,27 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY print O; } print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n"; - print O "#define LOCALEDIR \"/share/locale\"\n" if ($self->{options}->{nls}); + print O "#define LOCALEDIR \"/share/locale\"\n" + if ($self->{options}->{nls}); print O "/* defines added by config steps */\n"; print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n"; - print O "#define USE_ASSERT_CHECKING 1\n" if ($self->{options}->{asserts}); + print O "#define USE_ASSERT_CHECKING 1\n" + if ($self->{options}->{asserts}); print O "#define USE_INTEGER_DATETIMES 1\n" if ($self->{options}->{integer_datetimes}); - print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap}); - print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib}); - print O "#define USE_SSL 1\n" if ($self->{options}->{openssl}); + print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap}); + print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib}); + print O "#define USE_SSL 1\n" if ($self->{options}->{openssl}); print O "#define ENABLE_NLS 1\n" if ($self->{options}->{nls}); - print O "#define BLCKSZ ",1024 * $self->{options}->{blocksize},"\n"; + print O "#define BLCKSZ ", 1024 * $self->{options}->{blocksize}, "\n"; print O "#define RELSEG_SIZE ", - (1024 / $self->{options}->{blocksize}) *$self->{options}->{segsize} * 1024, "\n"; - print O "#define XLOG_BLCKSZ ",1024 * $self->{options}->{wal_blocksize},"\n"; - print O "#define XLOG_SEG_SIZE (",$self->{options}->{wal_segsize}, + (1024 / $self->{options}->{blocksize}) * + $self->{options}->{segsize} * + 1024, "\n"; + print O "#define XLOG_BLCKSZ ", + 1024 * $self->{options}->{wal_blocksize}, "\n"; + print O "#define XLOG_SEG_SIZE (", $self->{options}->{wal_segsize}, " * 1024 * 1024)\n"; if ($self->{options}->{float4byval}) @@ -225,40 +235,43 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY print O "#define DEF_PGPORT $port\n"; print O "#define DEF_PGPORT_STR \"$port\"\n"; } - print O "#define VAL_CONFIGURE \"" . $self->GetFakeConfigure() . "\"\n"; + print O "#define VAL_CONFIGURE \"" + . $self->GetFakeConfigure() . "\"\n"; print O "#endif /* IGNORE_CONFIGURED_SETTINGS */\n"; close(O); close(I); } - $self->GenerateDefFile("src\\interfaces\\libpq\\libpqdll.def", - "src\\interfaces\\libpq\\exports.txt","LIBPQ"); + $self->GenerateDefFile( + "src\\interfaces\\libpq\\libpqdll.def", + "src\\interfaces\\libpq\\exports.txt", + "LIBPQ"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\ecpglib\\ecpglib.def", "src\\interfaces\\ecpg\\ecpglib\\exports.txt", - "LIBECPG" - ); + "LIBECPG"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\compatlib\\compatlib.def", "src\\interfaces\\ecpg\\compatlib\\exports.txt", - "LIBECPG_COMPAT" - ); + "LIBECPG_COMPAT"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\pgtypeslib\\pgtypeslib.def", "src\\interfaces\\ecpg\\pgtypeslib\\exports.txt", - "LIBPGTYPES" - ); + "LIBPGTYPES"); - if (IsNewer('src\backend\utils\fmgrtab.c','src\include\catalog\pg_proc.h')) + if (IsNewer( + 'src\backend\utils\fmgrtab.c', 'src\include\catalog\pg_proc.h')) { print "Generating fmgrtab.c and fmgroids.h...\n"; chdir('src\backend\utils'); - system("perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h"); + system( +"perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h"); chdir('..\..\..'); - copyFile('src\backend\utils\fmgroids.h','src\include\utils\fmgroids.h'); + copyFile('src\backend\utils\fmgroids.h', + 'src\include\utils\fmgroids.h'); } - if (IsNewer('src\include\utils\probes.h','src\backend\utils\probes.d')) + if (IsNewer('src\include\utils\probes.h', 'src\backend\utils\probes.d')) { print "Generating probes.h...\n"; system( @@ -267,7 +280,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY } if ($self->{options}->{python} - && IsNewer('src\pl\plpython\spiexceptions.h','src\include\backend\errcodes.txt')) + && IsNewer( + 'src\pl\plpython\spiexceptions.h', + 'src\include\backend\errcodes.txt')) { print "Generating spiexceptions.h...\n"; system( @@ -275,16 +290,21 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if (IsNewer('src\include\utils\errcodes.h','src\backend\utils\errcodes.txt')) + if (IsNewer( + 'src\include\utils\errcodes.h', + 'src\backend\utils\errcodes.txt')) { print "Generating errcodes.h...\n"; system( 'perl src\backend\utils\generate-errcodes.pl src\backend\utils\errcodes.txt > src\backend\utils\errcodes.h' ); - copyFile('src\backend\utils\errcodes.h','src\include\utils\errcodes.h'); + copyFile('src\backend\utils\errcodes.h', + 'src\include\utils\errcodes.h'); } - if (IsNewer('src\pl\plpgsql\src\plerrcodes.h','src\backend\utils\errcodes.txt')) + if (IsNewer( + 'src\pl\plpgsql\src\plerrcodes.h', + 'src\backend\utils\errcodes.txt')) { print "Generating plerrcodes.h...\n"; system( @@ -292,12 +312,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if ( - IsNewer( + if (IsNewer( 'src\backend\utils\sort\qsort_tuple.c', - 'src\backend\utils\sort\gen_qsort_tuple.pl' - ) - ) + 'src\backend\utils\sort\gen_qsort_tuple.pl')) { print "Generating qsort_tuple.c...\n"; system( @@ -305,14 +322,18 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if (IsNewer('src\interfaces\libpq\libpq.rc','src\interfaces\libpq\libpq.rc.in')) + if (IsNewer( + 'src\interfaces\libpq\libpq.rc', + 'src\interfaces\libpq\libpq.rc.in')) { print "Generating libpq.rc...\n"; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + localtime(time); my $d = ($year - 100) . "$yday"; - open(I,'<', 'src\interfaces\libpq\libpq.rc.in') + open(I, '<', 'src\interfaces\libpq\libpq.rc.in') || confess "Could not open libpq.rc.in"; - open(O,'>', 'src\interfaces\libpq\libpq.rc') || confess "Could not open libpq.rc"; + open(O, '>', 'src\interfaces\libpq\libpq.rc') + || confess "Could not open libpq.rc"; while (<I>) { s/(VERSION.*),0/$1,$d/; @@ -322,7 +343,7 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY close(O); } - if (IsNewer('src\bin\psql\sql_help.h','src\bin\psql\create_help.pl')) + if (IsNewer('src\bin\psql\sql_help.h', 'src\bin\psql\create_help.pl')) { print "Generating sql_help.h...\n"; chdir('src\bin\psql'); @@ -330,7 +351,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY chdir('..\..\..'); } - if (IsNewer('src\interfaces\ecpg\preproc\preproc.y','src\backend\parser\gram.y')) + if (IsNewer( + 'src\interfaces\ecpg\preproc\preproc.y', + 'src\backend\parser\gram.y')) { print "Generating preproc.y...\n"; chdir('src\interfaces\ecpg\preproc'); @@ -338,15 +361,12 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY chdir('..\..\..\..'); } - if ( - IsNewer( + if (IsNewer( 'src\interfaces\ecpg\include\ecpg_config.h', - 'src\interfaces\ecpg\include\ecpg_config.h.in' - ) - ) + 'src\interfaces\ecpg\include\ecpg_config.h.in')) { print "Generating ecpg_config.h...\n"; - open(O,'>','src\interfaces\ecpg\include\ecpg_config.h') + open(O, '>', 'src\interfaces\ecpg\include\ecpg_config.h') || confess "Could not open ecpg_config.h"; print O <<EOF; #if (_MSC_VER > 1200) @@ -362,9 +382,9 @@ EOF unless (-f "src\\port\\pg_config_paths.h") { print "Generating pg_config_paths.h...\n"; - open(O,'>', 'src\port\pg_config_paths.h') + open(O, '>', 'src\port\pg_config_paths.h') || confess "Could not open pg_config_paths.h"; - print O <<EOF; + print O <<EOF; #define PGBINDIR "/bin" #define PGSHAREDIR "/share" #define SYSCONFDIR "/etc" @@ -389,7 +409,9 @@ EOF foreach my $bki (@allbki) { next if $bki eq ""; - if (IsNewer('src/backend/catalog/postgres.bki', "src/include/catalog/$bki")) + if (IsNewer( + 'src/backend/catalog/postgres.bki', + "src/include/catalog/$bki")) { print "Generating postgres.bki and schemapg.h...\n"; chdir('src\backend\catalog'); @@ -398,13 +420,15 @@ EOF "perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs" ); chdir('..\..\..'); - copyFile('src\backend\catalog\schemapg.h', + copyFile( + 'src\backend\catalog\schemapg.h', 'src\include\catalog\schemapg.h'); last; } } - open(O, ">doc/src/sgml/version.sgml") || croak "Could not write to version.sgml\n"; + open(O, ">doc/src/sgml/version.sgml") + || croak "Could not write to version.sgml\n"; print O <<EOF; <!ENTITY version "$self->{strver}"> <!ENTITY majorversion "$self->{majorver}"> @@ -414,13 +438,13 @@ EOF sub GenerateDefFile { - my ($self, $deffile, $txtfile, $libname) = @_; + my ($self, $deffile, $txtfile, $libname) = @_; - if (IsNewer($deffile,$txtfile)) + if (IsNewer($deffile, $txtfile)) { print "Generating $deffile...\n"; - open(I,$txtfile) || confess("Could not open $txtfile\n"); - open(O,">$deffile") || confess("Could not open $deffile\n"); + open(I, $txtfile) || confess("Could not open $txtfile\n"); + open(O, ">$deffile") || confess("Could not open $deffile\n"); print O "LIBRARY $libname\nEXPORTS\n"; while (<I>) { @@ -438,8 +462,9 @@ sub AddProject { my ($self, $name, $type, $folder, $initialdir) = @_; - my $proj = VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); - push @{$self->{projects}->{$folder}}, $proj; + my $proj = + VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); + push @{ $self->{projects}->{$folder} }, $proj; $proj->AddDir($initialdir) if ($initialdir); if ($self->{options}->{zlib}) { @@ -449,8 +474,10 @@ sub AddProject if ($self->{options}->{openssl}) { $proj->AddIncludeDir($self->{options}->{openssl} . '\include'); - $proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); - $proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); + $proj->AddLibrary( + $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); + $proj->AddLibrary( + $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); } if ($self->{options}->{nls}) { @@ -461,8 +488,10 @@ sub AddProject { $proj->AddIncludeDir($self->{options}->{krb5} . '\inc\krb5'); $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\krb5_32.lib'); - $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\comerr32.lib'); - $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\gssapi32.lib'); + $proj->AddLibrary( + $self->{options}->{krb5} . '\lib\i386\comerr32.lib'); + $proj->AddLibrary( + $self->{options}->{krb5} . '\lib\i386\gssapi32.lib'); } if ($self->{options}->{iconv}) { @@ -488,23 +517,23 @@ sub Save my %flduid; $self->GenerateFiles(); - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { $proj->Save(); } } - open(SLN,">pgsql.sln") || croak "Could not write to pgsql.sln\n"; + open(SLN, ">pgsql.sln") || croak "Could not write to pgsql.sln\n"; print SLN <<EOF; Microsoft Visual Studio Solution File, Format Version $self->{solutionFileVersion} # $self->{visualStudioName} EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN <<EOF; Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}" @@ -530,9 +559,9 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN <<EOF; $proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform} @@ -551,10 +580,10 @@ EOF GlobalSection(NestedProjects) = preSolution EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { next if ($fld eq ""); - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN "\t\t$proj->{guid} = $flduid{$fld}\n"; } @@ -573,18 +602,19 @@ sub GetFakeConfigure my $cfg = '--enable-thread-safety'; $cfg .= ' --enable-cassert' if ($self->{options}->{asserts}); - $cfg .= ' --enable-integer-datetimes' if ($self->{options}->{integer_datetimes}); + $cfg .= ' --enable-integer-datetimes' + if ($self->{options}->{integer_datetimes}); $cfg .= ' --enable-nls' if ($self->{options}->{nls}); - $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); + $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); $cfg .= ' --without-zlib' unless ($self->{options}->{zlib}); - $cfg .= ' --with-openssl' if ($self->{options}->{ssl}); + $cfg .= ' --with-openssl' if ($self->{options}->{ssl}); $cfg .= ' --with-ossp-uuid' if ($self->{options}->{uuid}); - $cfg .= ' --with-libxml' if ($self->{options}->{xml}); - $cfg .= ' --with-libxslt' if ($self->{options}->{xslt}); - $cfg .= ' --with-krb5' if ($self->{options}->{krb5}); - $cfg .= ' --with-tcl' if ($self->{options}->{tcl}); - $cfg .= ' --with-perl' if ($self->{options}->{perl}); - $cfg .= ' --with-python' if ($self->{options}->{python}); + $cfg .= ' --with-libxml' if ($self->{options}->{xml}); + $cfg .= ' --with-libxslt' if ($self->{options}->{xslt}); + $cfg .= ' --with-krb5' if ($self->{options}->{krb5}); + $cfg .= ' --with-tcl' if ($self->{options}->{tcl}); + $cfg .= ' --with-perl' if ($self->{options}->{perl}); + $cfg .= ' --with-python' if ($self->{options}->{python}); return $cfg; } @@ -602,12 +632,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '9.00'; - $self->{vcver} = '8.00'; - $self->{visualStudioName} = 'Visual Studio 2005'; + $self->{vcver} = '8.00'; + $self->{visualStudioName} = 'Visual Studio 2005'; return $self; } @@ -625,12 +655,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '10.00'; - $self->{vcver} = '9.00'; - $self->{visualStudioName} = 'Visual Studio 2008'; + $self->{vcver} = '9.00'; + $self->{visualStudioName} = 'Visual Studio 2008'; return $self; } @@ -649,12 +679,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '11.00'; - $self->{vcver} = '10.00'; - $self->{visualStudioName} = 'Visual Studio 2010'; + $self->{vcver} = '10.00'; + $self->{visualStudioName} = 'Visual Studio 2010'; return $self; } diff --git a/src/tools/msvc/VCBuildProject.pm b/src/tools/msvc/VCBuildProject.pm index a7fd0c0d9d5..1022329dce2 100644 --- a/src/tools/msvc/VCBuildProject.pm +++ b/src/tools/msvc/VCBuildProject.pm @@ -14,7 +14,7 @@ use base qw(Project); sub _new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{filenameExtension} = '.vcproj'; @@ -32,10 +32,21 @@ sub WriteHeader <Platforms><Platform Name="$self->{platform}"/></Platforms> <Configurations> EOF - $self->WriteConfiguration($f, 'Debug', - {defs=>'_DEBUG;DEBUG=1;', wholeopt=>0, opt=>0, strpool=>'false', runtime=>3}); - $self->WriteConfiguration($f, 'Release', - {defs=>'', wholeopt=>0, opt=>3, strpool=>'true', runtime=>2}); + $self->WriteConfiguration( + $f, 'Debug', + { defs => '_DEBUG;DEBUG=1;', + wholeopt => 0, + opt => 0, + strpool => 'false', + runtime => 3 }); + $self->WriteConfiguration( + $f, + 'Release', + { defs => '', + wholeopt => 0, + opt => 3, + strpool => 'true', + runtime => 2 }); print $f <<EOF; </Configurations> EOF @@ -50,43 +61,49 @@ sub WriteFiles EOF my @dirstack = (); my %uniquefiles; - foreach my $fileNameWithPath (sort keys %{$self->{files}}) + foreach my $fileNameWithPath (sort keys %{ $self->{files} }) { confess "Bad format filename '$fileNameWithPath'\n" unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); - my $dir = $1; + my $dir = $1; my $file = $2; - # Walk backwards down the directory stack and close any dirs we're done with + # Walk backwards down the directory stack and close any dirs we're done with while ($#dirstack >= 0) { - if (join('\\',@dirstack) eq substr($dir, 0, length(join('\\',@dirstack)))) + if (join('\\', @dirstack) eq + substr($dir, 0, length(join('\\', @dirstack)))) { - last if (length($dir) == length(join('\\',@dirstack))); - last if (substr($dir, length(join('\\',@dirstack)),1) eq '\\'); + last if (length($dir) == length(join('\\', @dirstack))); + last + if (substr($dir, length(join('\\', @dirstack)), 1) eq '\\'); } print $f ' ' x $#dirstack . " </Filter>\n"; pop @dirstack; } # Now walk forwards and create whatever directories are needed - while (join('\\',@dirstack) ne $dir) + while (join('\\', @dirstack) ne $dir) { - my $left = substr($dir, length(join('\\',@dirstack))); + my $left = substr($dir, length(join('\\', @dirstack))); $left =~ s/^\\//; my @pieces = split /\\/, $left; push @dirstack, $pieces[0]; - print $f ' ' x $#dirstack . " <Filter Name=\"$pieces[0]\" Filter=\"\">\n"; + print $f ' ' x $#dirstack + . " <Filter Name=\"$pieces[0]\" Filter=\"\">\n"; } - print $f ' ' x $#dirstack . " <File RelativePath=\"$fileNameWithPath\""; + print $f ' ' x $#dirstack + . " <File RelativePath=\"$fileNameWithPath\""; if ($fileNameWithPath =~ /\.y$/) { my $of = $fileNameWithPath; $of =~ s/\.y$/.c/; - $of =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; + $of =~ +s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; print $f '>' - . $self->GenerateCustomTool('Running bison on ' . $fileNameWithPath, + . $self->GenerateCustomTool( + 'Running bison on ' . $fileNameWithPath, "perl src\\tools\\msvc\\pgbison.pl $fileNameWithPath", $of) . '</File>' . "\n"; } @@ -95,7 +112,8 @@ EOF my $of = $fileNameWithPath; $of =~ s/\.l$/.c/; print $f '>' - . $self->GenerateCustomTool('Running flex on ' . $fileNameWithPath, + . $self->GenerateCustomTool( + 'Running flex on ' . $fileNameWithPath, "perl src\\tools\\msvc\\pgflex.pl $fileNameWithPath", $of) . '</File>' . "\n"; } @@ -139,7 +157,8 @@ EOF sub WriteConfiguration { my ($self, $f, $cfgname, $p) = @_; - my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4); + my $cfgtype = + ($self->{type} eq "exe") ? 1 : ($self->{type} eq "dll" ? 2 : 4); my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ' '); my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17; @@ -168,7 +187,8 @@ EOF EOF if ($self->{disablelinkerwarnings}) { - print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n"; + print $f +"\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n"; } if ($self->{implib}) { @@ -202,7 +222,7 @@ sub WriteReferences { my ($self, $f) = @_; print $f " <References>\n"; - foreach my $ref (@{$self->{references}}) + foreach my $ref (@{ $self->{references} }) { print $f " <ProjectReference ReferencedProjectIdentifier=\"$ref->{guid}\" Name=\"$ref->{name}\" />\n"; @@ -216,7 +236,7 @@ sub GenerateCustomTool if (!defined($cfg)) { return $self->GenerateCustomTool($desc, $tool, $output, 'Debug') - .$self->GenerateCustomTool($desc, $tool, $output, 'Release'); + . $self->GenerateCustomTool($desc, $tool, $output, 'Release'); } return "<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>"; @@ -235,7 +255,7 @@ use base qw(VCBuildProject); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{vcver} = '8.00'; @@ -256,7 +276,7 @@ use base qw(VCBuildProject); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{vcver} = '9.00'; diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm index e222b04c681..c3aa33ec24f 100644 --- a/src/tools/msvc/VSObjectFactory.pm +++ b/src/tools/msvc/VSObjectFactory.pm @@ -17,7 +17,7 @@ use VCBuildProject; use MSBuildProject; our (@ISA, @EXPORT); -@ISA = qw(Exporter); +@ISA = qw(Exporter); @EXPORT = qw(CreateSolution CreateProject DetermineVisualStudioVersion); sub CreateSolution @@ -81,12 +81,12 @@ sub DetermineVisualStudioVersion if (!defined($nmakeVersion)) { - # Determine version of nmake command, to set proper version of visual studio - # we use nmake as it has existed for a long time and still exists in visual studio 2010 - open(P,"nmake /? 2>&1 |") +# Determine version of nmake command, to set proper version of visual studio +# we use nmake as it has existed for a long time and still exists in visual studio 2010 + open(P, "nmake /? 2>&1 |") || croak - "Unable to determine Visual Studio version: The nmake command wasn't found."; - while(<P>) +"Unable to determine Visual Studio version: The nmake command wasn't found."; + while (<P>) { chomp; if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/) @@ -96,17 +96,17 @@ sub DetermineVisualStudioVersion } close(P); } - elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/) + elsif ($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/) { return _GetVisualStudioVersion($1, $2); } croak - "Unable to determine Visual Studio version: The nmake version could not be determined."; +"Unable to determine Visual Studio version: The nmake version could not be determined."; } sub _GetVisualStudioVersion { - my($major, $minor) = @_; + my ($major, $minor) = @_; if ($major > 10) { carp diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl index 4fa309738b4..8979402d4c1 100644 --- a/src/tools/msvc/build.pl +++ b/src/tools/msvc/build.pl @@ -5,7 +5,7 @@ BEGIN { - chdir("../../..") if (-d "../msvc" && -d "../../../src"); + chdir("../../..") if (-d "../msvc" && -d "../../../src"); } @@ -37,8 +37,8 @@ my $vcver = Mkvcbuild::mkvcbuild($config); # check what sort of build we are doing -my $bconf = $ENV{CONFIG} || "Release"; -my $buildwhat = $ARGV[1] || ""; +my $bconf = $ENV{CONFIG} || "Release"; +my $buildwhat = $ARGV[1] || ""; if ($ARGV[0] eq 'DEBUG') { $bconf = "Debug"; @@ -52,7 +52,8 @@ elsif ($ARGV[0] ne "RELEASE") if ($buildwhat and $vcver eq '10.00') { - system("msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf"); + system( +"msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf"); } elsif ($buildwhat) { diff --git a/src/tools/msvc/builddoc.pl b/src/tools/msvc/builddoc.pl index b567f542a74..2b56ced43ce 100644 --- a/src/tools/msvc/builddoc.pl +++ b/src/tools/msvc/builddoc.pl @@ -9,10 +9,10 @@ use strict; use File::Copy; use Cwd qw(abs_path getcwd); -my $startdir = getcwd(); +my $startdir = getcwd(); my $openjade = 'openjade-1.3.1'; -my $dsssl = 'docbook-dsssl-1.79'; +my $dsssl = 'docbook-dsssl-1.79'; chdir '../../..' if (-d '../msvc' && -d '../../../src'); @@ -26,7 +26,7 @@ die "bad DOCROOT '$docroot'" unless ($docroot && -d $docroot); my @notfound; foreach my $dir ('docbook', $openjade, $dsssl) { - push(@notfound,$dir) unless -d "$docroot/$dir"; + push(@notfound, $dir) unless -d "$docroot/$dir"; } missing() if @notfound; @@ -35,7 +35,8 @@ renamefiles(); chdir 'doc/src/sgml'; -$ENV{SGML_CATALOG_FILES} = "$docroot/$openjade/dsssl/catalog;" ."$docroot/docbook/docbook.cat"; +$ENV{SGML_CATALOG_FILES} = + "$docroot/$openjade/dsssl/catalog;" . "$docroot/docbook/docbook.cat"; my $cmd; @@ -43,45 +44,46 @@ my $cmd; # can't die on "failure" $cmd = - "perl mk_feature_tables.pl YES " - ."../../../src/backend/catalog/sql_feature_packages.txt " - ."../../../src/backend/catalog/sql_features.txt " - ."> features-supported.sgml"; + "perl mk_feature_tables.pl YES " + . "../../../src/backend/catalog/sql_feature_packages.txt " + . "../../../src/backend/catalog/sql_features.txt " + . "> features-supported.sgml"; system($cmd); die "features_supported" if $?; $cmd = - "perl mk_feature_tables.pl NO " - ."\"../../../src/backend/catalog/sql_feature_packages.txt\" " - ."\"../../../src/backend/catalog/sql_features.txt\" " - ."> features-unsupported.sgml"; + "perl mk_feature_tables.pl NO " + . "\"../../../src/backend/catalog/sql_feature_packages.txt\" " + . "\"../../../src/backend/catalog/sql_features.txt\" " + . "> features-unsupported.sgml"; system($cmd); die "features_unsupported" if $?; -$cmd ="perl generate-errcodes-table.pl \"../../../src/backend/utils/errcodes.txt\" " - ."> errcodes-table.sgml"; +$cmd = +"perl generate-errcodes-table.pl \"../../../src/backend/utils/errcodes.txt\" " + . "> errcodes-table.sgml"; system($cmd); die "errcodes-table" if $?; print "Running first build...\n"; $cmd = - "\"$docroot/$openjade/bin/openjade\" -V html-index -wall " - ."-wno-unused-param -wno-empty -D . -c \"$docroot/$dsssl/catalog\" " - ."-d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 " - ."| findstr /V \"DTDDECL catalog entries are not supported\" "; -system($cmd); # die "openjade" if $?; + "\"$docroot/$openjade/bin/openjade\" -V html-index -wall " + . "-wno-unused-param -wno-empty -D . -c \"$docroot/$dsssl/catalog\" " + . "-d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 " + . "| findstr /V \"DTDDECL catalog entries are not supported\" "; +system($cmd); # die "openjade" if $?; print "Running collateindex...\n"; -$cmd = - "perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex "."-o bookindex.sgml HTML.index"; +$cmd = "perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex " + . "-o bookindex.sgml HTML.index"; system($cmd); die "collateindex" if $?; mkdir "html"; print "Running second build...\n"; $cmd = - "\"$docroot/$openjade/bin/openjade\" -wall -wno-unused-param -wno-empty " - ."-D . -c \"$docroot/$dsssl/catalog\" -d stylesheet.dsl -t sgml " - ."-i output-html -i include-index postgres.sgml 2>&1 " - ."| findstr /V \"DTDDECL catalog entries are not supported\" "; + "\"$docroot/$openjade/bin/openjade\" -wall -wno-unused-param -wno-empty " + . "-D . -c \"$docroot/$dsssl/catalog\" -d stylesheet.dsl -t sgml " + . "-i output-html -i include-index postgres.sgml 2>&1 " + . "| findstr /V \"DTDDECL catalog entries are not supported\" "; -system($cmd); # die "openjade" if $?; +system($cmd); # die "openjade" if $?; copy "stylesheet.css", "html/stylesheet.css"; @@ -116,6 +118,7 @@ sub missing sub noversion { - print STDERR "Could not find version.sgml. ","Please run mkvcbuild.pl first!\n"; + print STDERR "Could not find version.sgml. ", + "Please run mkvcbuild.pl first!\n"; exit 1; } diff --git a/src/tools/msvc/config_default.pl b/src/tools/msvc/config_default.pl index 95e9cd93dab..2489d3827fd 100644 --- a/src/tools/msvc/config_default.pl +++ b/src/tools/msvc/config_default.pl @@ -3,25 +3,25 @@ use strict; use warnings; our $config = { - asserts=>0, # --enable-cassert - # integer_datetimes=>1, # --enable-integer-datetimes - on is now default - # float4byval=>1, # --disable-float4-byval, on by default - # float8byval=>0, # --disable-float8-byval, off by default - # blocksize => 8, # --with-blocksize, 8kB by default - # wal_blocksize => 8, # --with-wal-blocksize, 8kB by default - # wal_segsize => 16, # --with-wal-segsize, 16MB by default - ldap=>1, # --with-ldap - nls=>undef, # --enable-nls=<path> - tcl=>undef, # --with-tls=<path> - perl=>undef, # --with-perl - python=>undef, # --with-python=<path> - krb5=>undef, # --with-krb5=<path> - openssl=>undef, # --with-ssl=<path> - uuid=>undef, # --with-ossp-uuid - xml=>undef, # --with-libxml=<path> - xslt=>undef, # --with-libxslt=<path> - iconv=>undef, # (not in configure, path to iconv) - zlib=>undef # --with-zlib=<path> + asserts => 0, # --enable-cassert + # integer_datetimes=>1, # --enable-integer-datetimes - on is now default + # float4byval=>1, # --disable-float4-byval, on by default + # float8byval=>0, # --disable-float8-byval, off by default + # blocksize => 8, # --with-blocksize, 8kB by default + # wal_blocksize => 8, # --with-wal-blocksize, 8kB by default + # wal_segsize => 16, # --with-wal-segsize, 16MB by default + ldap => 1, # --with-ldap + nls => undef, # --enable-nls=<path> + tcl => undef, # --with-tls=<path> + perl => undef, # --with-perl + python => undef, # --with-python=<path> + krb5 => undef, # --with-krb5=<path> + openssl => undef, # --with-ssl=<path> + uuid => undef, # --with-ossp-uuid + xml => undef, # --with-libxml=<path> + xslt => undef, # --with-libxslt=<path> + iconv => undef, # (not in configure, path to iconv) + zlib => undef # --with-zlib=<path> }; 1; diff --git a/src/tools/msvc/gendef.pl b/src/tools/msvc/gendef.pl index 2fc8c4a2903..ab65c46cfae 100644 --- a/src/tools/msvc/gendef.pl +++ b/src/tools/msvc/gendef.pl @@ -7,8 +7,9 @@ my @def; # die "Usage: gendef.pl <modulepath> <platform>\n" - unless(($ARGV[0] =~ /\\([^\\]+$)/) && ($ARGV[1] == 'Win32' || $ARGV[1] == 'x64')); -my $defname = uc $1; + unless (($ARGV[0] =~ /\\([^\\]+$)/) + && ($ARGV[1] == 'Win32' || $ARGV[1] == 'x64')); +my $defname = uc $1; my $platform = $ARGV[1]; if (-f "$ARGV[0]/$defname.def") @@ -22,9 +23,10 @@ print "Generating $defname.DEF from directory $ARGV[0], platform $platform\n"; while (<$ARGV[0]/*.obj>) { my $symfile = $_; - $symfile=~ s/\.obj$/.sym/i; + $symfile =~ s/\.obj$/.sym/i; print "."; - system("dumpbin /symbols /out:symbols.out $_ >NUL") && die "Could not call dumpbin"; + system("dumpbin /symbols /out:symbols.out $_ >NUL") + && die "Could not call dumpbin"; open(F, "<symbols.out") || die "Could not open symbols.out for $_\n"; while (<F>) { @@ -46,19 +48,20 @@ while (<$ARGV[0]/*.obj>) push @def, $pieces[6]; } close(F); - rename("symbols.out",$symfile); + rename("symbols.out", $symfile); } print "\n"; -open(DEF,">$ARGV[0]/$defname.def") || die "Could not write to $defname\n"; +open(DEF, ">$ARGV[0]/$defname.def") || die "Could not write to $defname\n"; print DEF "EXPORTS\n"; -my $i = 0; +my $i = 0; my $last = ""; foreach my $f (sort @def) { next if ($f eq $last); $last = $f; - $f =~ s/^_// unless ($platform eq "x64"); # win64 has new format of exports + $f =~ s/^_// + unless ($platform eq "x64"); # win64 has new format of exports $i++; # print DEF " $f \@ $i\n"; # ordinaled exports? diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl index 32861cbbd6d..6f1c42e5044 100644 --- a/src/tools/msvc/mkvcbuild.pl +++ b/src/tools/msvc/mkvcbuild.pl @@ -10,10 +10,13 @@ use warnings; use Mkvcbuild; chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src'); -die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src'); +die 'Must run from root or msvc directory' + unless (-d 'src\tools\msvc' && -d 'src'); -die 'Could not find config_default.pl' unless (-f 'src/tools/msvc/config_default.pl'); -print "Warning: no config.pl found, using default.\n" unless (-f 'src/tools/msvc/config.pl'); +die 'Could not find config_default.pl' + unless (-f 'src/tools/msvc/config_default.pl'); +print "Warning: no config.pl found, using default.\n" + unless (-f 'src/tools/msvc/config.pl'); our $config; require 'src/tools/msvc/config_default.pl'; diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl index f0c9e26007a..d6f2444841d 100644 --- a/src/tools/msvc/pgbison.pl +++ b/src/tools/msvc/pgbison.pl @@ -9,8 +9,8 @@ use File::Basename; require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; -my ($bisonver) = `bison -V`; # grab first line -$bisonver=(split(/\s+/,$bisonver))[3]; # grab version number +my ($bisonver) = `bison -V`; # grab first line +$bisonver = (split(/\s+/, $bisonver))[3]; # grab version number unless ($bisonver eq '1.875' || $bisonver ge '2.2') { @@ -38,9 +38,9 @@ $output =~ s/gram\.c$/pl_gram.c/ if $input =~ /src.pl.plpgsql.src.gram\.y$/; my $makefile = dirname($input) . "/Makefile"; my ($mf, $make); -open($mf,$makefile); +open($mf, $makefile); local $/ = undef; -$make=<$mf>; +$make = <$mf>; close($mf); my $headerflag = ($make =~ /\$\(BISON\)\s+-d/ ? '-d' : ''); diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl index 551b8f67ae8..259f2187ed3 100644 --- a/src/tools/msvc/pgflex.pl +++ b/src/tools/msvc/pgflex.pl @@ -12,10 +12,10 @@ use File::Basename; require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; -my ($flexver) = `flex -V`; # grab first line -$flexver=(split(/\s+/,$flexver))[1]; +my ($flexver) = `flex -V`; # grab first line +$flexver = (split(/\s+/, $flexver))[1]; $flexver =~ s/[^0-9.]//g; -my @verparts = split(/\./,$flexver); +my @verparts = split(/\./, $flexver); unless ($verparts[0] == 2 && $verparts[1] == 5 && $verparts[2] >= 31) { print "WARNING! Flex install not found, or unsupported Flex version.\n"; @@ -40,9 +40,9 @@ elsif (!-e $input) # get flex flags from make file my $makefile = dirname($input) . "/Makefile"; my ($mf, $make); -open($mf,$makefile); +open($mf, $makefile); local $/ = undef; -$make=<$mf>; +$make = <$mf>; close($mf); my $flexflags = ($make =~ /^\s*FLEXFLAGS\s*=\s*(\S.*)/m ? $1 : ''); @@ -55,24 +55,24 @@ if ($? == 0) # For reentrant scanners (like the core scanner) we do not # need to (and must not) change the yywrap definition. my $lfile; - open($lfile,$input) || die "opening $input for reading: $!"; + open($lfile, $input) || die "opening $input for reading: $!"; my $lcode = <$lfile>; close($lfile); if ($lcode !~ /\%option\sreentrant/) { my $cfile; - open($cfile,$output) || die "opening $output for reading: $!"; + open($cfile, $output) || die "opening $output for reading: $!"; my $ccode = <$cfile>; close($cfile); $ccode =~ s/yywrap\(n\)/yywrap()/; - open($cfile,">$output") || die "opening $output for reading: $!"; + open($cfile, ">$output") || die "opening $output for reading: $!"; print $cfile $ccode; close($cfile); } if ($flexflags =~ /\s-b\s/) { my $lexback = "lex.backup"; - open($lfile,$lexback) || die "opening $lexback for reading: $!"; + open($lfile, $lexback) || die "opening $lexback for reading: $!"; my $lexbacklines = <$lfile>; close($lfile); my $linecount = $lexbacklines =~ tr /\n/\n/; diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index ef7035068b4..530770ced39 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -26,7 +26,8 @@ if (-e "src/tools/msvc/buildenv.pl") } my $what = shift || ""; -if ($what =~ /^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck)$/i) +if ($what =~ + /^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck)$/i) { $what = uc $what; } @@ -38,10 +39,10 @@ else # use a capital C here because config.pl has $config my $Config = -e "release/postgres/postgres.exe" ? "Release" : "Debug"; -copy("$Config/refint/refint.dll","src/test/regress"); -copy("$Config/autoinc/autoinc.dll","src/test/regress"); -copy("$Config/regress/regress.dll","src/test/regress"); -copy("$Config/dummy_seclabel/dummy_seclabel.dll","src/test/regress"); +copy("$Config/refint/refint.dll", "src/test/regress"); +copy("$Config/autoinc/autoinc.dll", "src/test/regress"); +copy("$Config/regress/regress.dll", "src/test/regress"); +copy("$Config/dummy_seclabel/dummy_seclabel.dll", "src/test/regress"); $ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}"; @@ -67,13 +68,12 @@ $temp_config = "--temp-config=\"$ENV{TEMP_CONFIG}\"" chdir "src/test/regress"; my %command = ( - CHECK => \&check, - PLCHECK => \&plcheck, - INSTALLCHECK => \&installcheck, - ECPGCHECK => \&ecpgcheck, - CONTRIBCHECK => \&contribcheck, - ISOLATIONCHECK => \&isolationcheck, -); + CHECK => \&check, + PLCHECK => \&plcheck, + INSTALLCHECK => \&installcheck, + ECPGCHECK => \&ecpgcheck, + CONTRIBCHECK => \&contribcheck, + ISOLATIONCHECK => \&isolationcheck,); my $proc = $command{$what}; @@ -88,28 +88,33 @@ exit 0; sub installcheck { my @args = ( - "../../../$Config/pg_regress/pg_regress","--dlpath=.", - "--psqldir=../../../$Config/psql","--schedule=${schedule}_schedule", - "--encoding=SQL_ASCII","--no-locale" - ); - push(@args,$maxconn) if $maxconn; + "../../../$Config/pg_regress/pg_regress", + "--dlpath=.", + "--psqldir=../../../$Config/psql", + "--schedule=${schedule}_schedule", + "--encoding=SQL_ASCII", + "--no-locale"); + push(@args, $maxconn) if $maxconn; system(@args); - my $status = $? >>8; + my $status = $? >> 8; exit $status if $status; } sub check { my @args = ( - "../../../$Config/pg_regress/pg_regress","--dlpath=.", - "--psqldir=../../../$Config/psql","--schedule=${schedule}_schedule", - "--encoding=SQL_ASCII","--no-locale", - "--temp-install=./tmp_check","--top-builddir=\"$topdir\"" - ); - push(@args,$maxconn) if $maxconn; - push(@args,$temp_config) if $temp_config; + "../../../$Config/pg_regress/pg_regress", + "--dlpath=.", + "--psqldir=../../../$Config/psql", + "--schedule=${schedule}_schedule", + "--encoding=SQL_ASCII", + "--no-locale", + "--temp-install=./tmp_check", + "--top-builddir=\"$topdir\""); + push(@args, $maxconn) if $maxconn; + push(@args, $temp_config) if $temp_config; system(@args); - my $status = $? >>8; + my $status = $? >> 8; exit $status if $status; } @@ -117,10 +122,10 @@ sub ecpgcheck { chdir $startdir; system("msbuild ecpg_regression.proj /p:config=$Config"); - my $status = $? >>8; + my $status = $? >> 8; exit $status if $status; chdir "$topdir/src/interfaces/ecpg/test"; - $schedule="ecpg"; + $schedule = "ecpg"; my @args = ( "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg", "--psqldir=../../../$Config/psql", @@ -130,26 +135,25 @@ sub ecpgcheck "--encoding=SQL_ASCII", "--no-locale", "--temp-install=./tmp_chk", - "--top-builddir=\"$topdir\"" - ); - push(@args,$maxconn) if $maxconn; + "--top-builddir=\"$topdir\""); + push(@args, $maxconn) if $maxconn; system(@args); - $status = $? >>8; + $status = $? >> 8; exit $status if $status; } sub isolationcheck { chdir "../isolation"; - copy("../../../$Config/isolationtester/isolationtester.exe","."); + copy("../../../$Config/isolationtester/isolationtester.exe", "."); my @args = ( "../../../$Config/pg_isolation_regress/pg_isolation_regress", "--psqldir=../../../$Config/psql", - "--inputdir=.","--schedule=./isolation_schedule" - ); - push(@args,$maxconn) if $maxconn; + "--inputdir=.", + "--schedule=./isolation_schedule"); + push(@args, $maxconn) if $maxconn; system(@args); - my $status = $? >>8; + my $status = $? >> 8; exit $status if $status; } @@ -178,16 +182,16 @@ sub plcheck use Config; if ($Config{usemultiplicity} eq 'define') { - push(@tests,'plperl_plperlu'); + push(@tests, 'plperl_plperlu'); } } - print "============================================================\n"; + print + "============================================================\n"; print "Checking $lang\n"; my @args = ( "../../../$Config/pg_regress/pg_regress", "--psqldir=../../../$Config/psql", - "--dbname=pl_regression",@lang_args,@tests - ); + "--dbname=pl_regression", @lang_args, @tests); system(@args); my $status = $? >> 8; exit $status if $status; @@ -207,18 +211,18 @@ sub contribcheck next if ($module eq 'xml2' && !$config->{xml}); next unless -d "$module/sql" - &&-d "$module/expected" - &&(-f "$module/GNUmakefile" || -f "$module/Makefile"); + && -d "$module/expected" + && (-f "$module/GNUmakefile" || -f "$module/Makefile"); chdir $module; - print "============================================================\n"; + print + "============================================================\n"; print "Checking $module\n"; my @tests = fetchTests(); - my @opts = fetchRegressOpts(); - my @args = ( + my @opts = fetchRegressOpts(); + my @args = ( "../../$Config/pg_regress/pg_regress", "--psqldir=../../$Config/psql", - "--dbname=contrib_regression",@opts,@tests - ); + "--dbname=contrib_regression", @opts, @tests); system(@args); my $status = $? >> 8; $mstat ||= $status; @@ -230,10 +234,10 @@ sub contribcheck sub fetchRegressOpts { my $handle; - open($handle,"<GNUmakefile") - || open($handle,"<Makefile") + open($handle, "<GNUmakefile") + || open($handle, "<Makefile") || die "Could not open Makefile"; - local($/) = undef; + local ($/) = undef; my $m = <$handle>; close($handle); my @opts; @@ -242,7 +246,7 @@ sub fetchRegressOpts # ignore options that use makefile variables - can't handle those # ignore anything that isn't an option staring with -- - @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/,$1); + @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/, $1); } if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) { @@ -259,10 +263,10 @@ sub fetchTests { my $handle; - open($handle,"<GNUmakefile") - || open($handle,"<Makefile") + open($handle, "<GNUmakefile") + || open($handle, "<Makefile") || die "Could not open Makefile"; - local($/) = undef; + local ($/) = undef; my $m = <$handle>; close($handle); my $t = ""; @@ -281,24 +285,24 @@ sub fetchTests my $cftests = $config->{openssl} - ?GetTests("OSSL_TESTS",$m) - : GetTests("INT_TESTS",$m); + ? GetTests("OSSL_TESTS", $m) + : GetTests("INT_TESTS", $m); my $pgptests = $config->{zlib} - ?GetTests("ZLIB_TST",$m) - : GetTests("ZLIB_OFF_TST",$m); + ? GetTests("ZLIB_TST", $m) + : GetTests("ZLIB_OFF_TST", $m); $t =~ s/\$\(CF_TESTS\)/$cftests/; $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/; } } - return split(/\s+/,$t); + return split(/\s+/, $t); } sub GetTests { my $testname = shift; - my $m = shift; + my $m = shift; if ($m =~ /^$testname\s*=\s*(.*)$/gm) { return $1; diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl index e8cc38feb77..eb058a16f9e 100755 --- a/src/tools/version_stamp.pl +++ b/src/tools/version_stamp.pl @@ -29,31 +29,45 @@ $major2 = 2; $minor = shift; defined($minor) || die "$0: missing required argument: minor-version\n"; -if ($minor =~ m/^\d+$/) { - $dotneeded = 1; - $numericminor = $minor; -} elsif ($minor eq "devel") { - $dotneeded = 0; - $numericminor = 0; -} elsif ($minor =~ m/^alpha\d+$/) { - $dotneeded = 0; - $numericminor = 0; -} elsif ($minor =~ m/^beta\d+$/) { - $dotneeded = 0; - $numericminor = 0; -} elsif ($minor =~ m/^rc\d+$/) { - $dotneeded = 0; - $numericminor = 0; -} else { - die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n"; +if ($minor =~ m/^\d+$/) +{ + $dotneeded = 1; + $numericminor = $minor; +} +elsif ($minor eq "devel") +{ + $dotneeded = 0; + $numericminor = 0; +} +elsif ($minor =~ m/^alpha\d+$/) +{ + $dotneeded = 0; + $numericminor = 0; +} +elsif ($minor =~ m/^beta\d+$/) +{ + $dotneeded = 0; + $numericminor = 0; +} +elsif ($minor =~ m/^rc\d+$/) +{ + $dotneeded = 0; + $numericminor = 0; +} +else +{ + die "$0: minor-version must be N, devel, alphaN, betaN, or rcN\n"; } # Create various required forms of the version number $majorversion = $major1 . "." . $major2; -if ($dotneeded) { - $fullversion = $majorversion . "." . $minor; -} else { - $fullversion = $majorversion . $minor; +if ($dotneeded) +{ + $fullversion = $majorversion . "." . $minor; +} +else +{ + $fullversion = $majorversion . $minor; } $numericversion = $majorversion . "." . $numericminor; $padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor); @@ -63,54 +77,64 @@ $padnumericversion = sprintf("%d%02d%02d", $major1, $major2, $numericminor); $aconfver = ""; open(FILE, "configure.in") || die "could not read configure.in: $!\n"; -while (<FILE>) { - if (m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/) { - $aconfver = $1; - last; - } +while (<FILE>) +{ + if ( +m/^m4_if\(m4_defn\(\[m4_PACKAGE_VERSION\]\), \[(.*)\], \[\], \[m4_fatal/) + { + $aconfver = $1; + last; + } } close(FILE); -$aconfver ne "" || die "could not find autoconf version number in configure.in\n"; +$aconfver ne "" + || die "could not find autoconf version number in configure.in\n"; # Update configure.in and other files that contain version numbers $fixedfiles = ""; sed_file("configure.in", - "-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'"); +"-e 's/AC_INIT(\\[PostgreSQL\\], \\[[0-9a-z.]*\\]/AC_INIT([PostgreSQL], [$fullversion]/'" +); sed_file("doc/bug.template", - "-e 's/PostgreSQL version (example: PostgreSQL .*) *: PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion): PostgreSQL $fullversion/'"); +"-e 's/PostgreSQL version (example: PostgreSQL .*) *: PostgreSQL .*/PostgreSQL version (example: PostgreSQL $fullversion): PostgreSQL $fullversion/'" +); sed_file("src/include/pg_config.h.win32", - "-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' " . - "-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' " . - "-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' " . - "-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'"); +"-e 's/#define PACKAGE_STRING \"PostgreSQL .*\"/#define PACKAGE_STRING \"PostgreSQL $fullversion\"/' " + . "-e 's/#define PACKAGE_VERSION \".*\"/#define PACKAGE_VERSION \"$fullversion\"/' " + . "-e 's/#define PG_VERSION \".*\"/#define PG_VERSION \"$fullversion\"/' " + . "-e 's/#define PG_VERSION_NUM .*/#define PG_VERSION_NUM $padnumericversion/'" +); sed_file("src/interfaces/libpq/libpq.rc.in", - "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " . - "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' " . - "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' " . - "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'"); +"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " + . "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/' " + . "-e 's/VALUE \"FileVersion\", \"[0-9.]*/VALUE \"FileVersion\", \"$numericversion/' " + . "-e 's/VALUE \"ProductVersion\", \"[0-9.]*/VALUE \"ProductVersion\", \"$numericversion/'" +); sed_file("src/port/win32ver.rc", - "-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " . - "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'"); +"-e 's/FILEVERSION [0-9]*,[0-9]*,[0-9]*,0/FILEVERSION $major1,$major2,$numericminor,0/' " + . "-e 's/PRODUCTVERSION [0-9]*,[0-9]*,[0-9]*,0/PRODUCTVERSION $major1,$major2,$numericminor,0/'" +); print "Stamped these files with version number $fullversion:\n$fixedfiles"; print "Don't forget to run autoconf $aconfver before committing.\n"; exit 0; -sub sed_file { - my($filename, $sedargs) = @_; - my($tmpfilename) = $filename . ".tmp"; +sub sed_file +{ + my ($filename, $sedargs) = @_; + my ($tmpfilename) = $filename . ".tmp"; - system("sed $sedargs $filename >$tmpfilename") == 0 - or die "sed failed: $?"; - system("mv $tmpfilename $filename") == 0 - or die "mv failed: $?"; + system("sed $sedargs $filename >$tmpfilename") == 0 + or die "sed failed: $?"; + system("mv $tmpfilename $filename") == 0 + or die "mv failed: $?"; - $fixedfiles .= "\t$filename\n"; + $fixedfiles .= "\t$filename\n"; } diff --git a/src/tools/win32tzlist.pl b/src/tools/win32tzlist.pl index c2e423f854b..c5a1aaed05d 100755 --- a/src/tools/win32tzlist.pl +++ b/src/tools/win32tzlist.pl @@ -26,7 +26,8 @@ my $tzfile = 'src/bin/initdb/findtimezone.c'; # Fetch all timezones in the registry # my $basekey; -$HKEY_LOCAL_MACHINE->Open("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", $basekey) +$HKEY_LOCAL_MACHINE->Open( + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones", $basekey) or die $!; my @subkeys; @@ -36,21 +37,19 @@ my @system_zones; foreach my $keyname (@subkeys) { - my $subkey; - my %vals; - - $basekey->Open($keyname, $subkey) or die $!; - $subkey->GetValues(\%vals) or die $!; - $subkey->Close(); - - die "Incomplete timezone data for $keyname!\n" - unless ($vals{Std} && $vals{Dlt} && $vals{Display}); - push @system_zones, - { - 'std'=>$vals{Std}->[2], - 'dlt'=>$vals{Dlt}->[2], - 'display'=>clean_displayname($vals{Display}->[2]), - }; + my $subkey; + my %vals; + + $basekey->Open($keyname, $subkey) or die $!; + $subkey->GetValues(\%vals) or die $!; + $subkey->Close(); + + die "Incomplete timezone data for $keyname!\n" + unless ($vals{Std} && $vals{Dlt} && $vals{Display}); + push @system_zones, + { 'std' => $vals{Std}->[2], + 'dlt' => $vals{Dlt}->[2], + 'display' => clean_displayname($vals{Display}->[2]), }; } $basekey->Close(); @@ -59,7 +58,7 @@ $basekey->Close(); # Fetch all timezones currently in the file # my @file_zones; -open(TZFILE,"<$tzfile") or die "Could not open $tzfile!\n"; +open(TZFILE, "<$tzfile") or die "Could not open $tzfile!\n"; my $t = $/; undef $/; my $pgtz = <TZFILE>; @@ -72,15 +71,14 @@ $pgtz =~ /win32_tzmap\[\] =\s+{\s+\/\*[^\/]+\*\/\s+(.+?)};/gs $pgtz = $1; # Extract each individual record from the struct -while ($pgtz =~ m/{\s+"([^"]+)",\s+"([^"]+)",\s+"([^"]+)",?\s+},\s+\/\*(.+?)\*\//gs) +while ($pgtz =~ + m/{\s+"([^"]+)",\s+"([^"]+)",\s+"([^"]+)",?\s+},\s+\/\*(.+?)\*\//gs) { - push @file_zones, - { - 'std'=>$1, - 'dlt'=>$2, - 'match'=>$3, - 'display'=>clean_displayname($4), - }; + push @file_zones, + { 'std' => $1, + 'dlt' => $2, + 'match' => $3, + 'display' => clean_displayname($4), }; } # @@ -90,47 +88,48 @@ my @add; for my $sys (@system_zones) { - my $match = 0; - for my $file (@file_zones) - { - if ($sys->{std} eq $file->{std}) - { - $match=1; - if ($sys->{dlt} ne $file->{dlt}) - { - print "Timezone $sys->{std}, changed name of daylight zone!\n"; - } - if ($sys->{display} ne $file->{display}) - { - print + my $match = 0; + for my $file (@file_zones) + { + if ($sys->{std} eq $file->{std}) + { + $match = 1; + if ($sys->{dlt} ne $file->{dlt}) + { + print + "Timezone $sys->{std}, changed name of daylight zone!\n"; + } + if ($sys->{display} ne $file->{display}) + { + print "Timezone $sys->{std} changed displayname ('$sys->{display}' from '$file->{display}')!\n"; - } - last; - } - } - unless ($match) - { - push @add, $sys; - } + } + last; + } + } + unless ($match) + { + push @add, $sys; + } } if (@add) { - print "\n\nOther than that, add the following timezones:\n"; - for my $z (@add) - { - print + print "\n\nOther than that, add the following timezones:\n"; + for my $z (@add) + { + print "\t{\n\t\t\"$z->{std}\", \"$z->{dlt}\",\n\t\t\"FIXME\"\n\t},\t\t\t\t\t\t\t/* $z->{display} */\n"; - } + } } sub clean_displayname { - my $dn = shift; + my $dn = shift; - $dn =~ s/\s+/ /gs; - $dn =~ s/\*//gs; - $dn =~ s/^\s+//gs; - $dn =~ s/\s+$//gs; - return $dn; + $dn =~ s/\s+/ /gs; + $dn =~ s/\*//gs; + $dn =~ s/^\s+//gs; + $dn =~ s/\s+$//gs; + return $dn; } |