diff options
author | Bruce Momjian | 2012-06-10 19:20:04 +0000 |
---|---|---|
committer | Bruce Momjian | 2012-06-10 19:20:04 +0000 |
commit | 927d61eeff78363ea3938c818d07e511ebaf75cf (patch) | |
tree | 2f0bcecf53327f76272a8ce690fa62505520fab9 /src/tools | |
parent | 60801944fa105252b48ea5688d47dfc05c695042 (diff) |
Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
Diffstat (limited to 'src/tools')
-rw-r--r-- | src/tools/msvc/Install.pm | 1056 | ||||
-rw-r--r-- | src/tools/msvc/MSBuildProject.pm | 325 | ||||
-rw-r--r-- | src/tools/msvc/Mkvcbuild.pm | 1278 | ||||
-rw-r--r-- | src/tools/msvc/Project.pm | 607 | ||||
-rw-r--r-- | src/tools/msvc/Solution.pm | 980 | ||||
-rw-r--r-- | src/tools/msvc/VCBuildProject.pm | 292 | ||||
-rw-r--r-- | src/tools/msvc/VSObjectFactory.pm | 152 | ||||
-rw-r--r-- | src/tools/msvc/build.pl | 20 | ||||
-rw-r--r-- | src/tools/msvc/builddoc.pl | 32 | ||||
-rw-r--r-- | src/tools/msvc/config_default.pl | 38 | ||||
-rw-r--r-- | src/tools/msvc/gendef.pl | 66 | ||||
-rwxr-xr-x | src/tools/msvc/install.pl | 4 | ||||
-rw-r--r-- | src/tools/msvc/pgbison.pl | 14 | ||||
-rw-r--r-- | src/tools/msvc/pgflex.pl | 60 | ||||
-rw-r--r-- | src/tools/msvc/vcregress.pl | 400 |
15 files changed, 2693 insertions, 2631 deletions
diff --git a/src/tools/msvc/Install.pm b/src/tools/msvc/Install.pm index 7c743d17b4f..058fab3e5ab 100644 --- a/src/tools/msvc/Install.pm +++ b/src/tools/msvc/Install.pm @@ -19,593 +19,615 @@ our (@ISA,@EXPORT_OK); sub lcopy { - my $src = shift; - my $target = shift; + my $src = shift; + my $target = shift; - if (-f $target) - { - unlink $target || confess "Could not delete $target\n"; - } + if (-f $target) + { + unlink $target || confess "Could not delete $target\n"; + } - copy($src,$target) - || confess "Could not copy $src to $target\n"; + copy($src,$target) + || confess "Could not copy $src to $target\n"; } sub Install { - $| = 1; - - my $target = shift; - our $config; - require "config_default.pl"; - require "config.pl" if (-f "config.pl"); - - chdir("../../..") if (-f "../../../configure"); - chdir("../../../..") if (-f "../../../../configure"); - my $conf = ""; - if (-d "debug") - { - $conf = "debug"; - } - if (-d "release") - { - $conf = "release"; - } - die "Could not find debug or release binaries" if ($conf eq ""); - 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'); - - CopySolutionOutput($conf, $target); - lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); - my $sample_files = []; - File::Find::find( - { - wanted =>sub { - /^.*\.sample\z/s - &&push(@$sample_files, $File::Find::name); - } - }, - "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" - ); - CopySetOfFiles( - 'timezone names', - [ glob('src\timezone\tznames\*.txt') ], - $target . '/share/timezonesets/' - ); - CopyFiles( - 'timezone sets', - $target . '/share/timezonesets/', - '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/'); - CopyFiles( - 'Information schema data', - $target . '/share/', - 'src/backend/catalog/', 'sql_features.txt' - ); - GenerateConversionScript($target); - GenerateTimezoneFiles($target,$conf); - GenerateTsearchFiles($target); - CopySetOfFiles( - 'Stopword files', - [ glob("src\\backend\\snowball\\stopwords\\*.stop") ], - $target . '/share/tsearch_data/' - ); - CopySetOfFiles( - 'Dictionaries sample files', - [ glob("src\\backend\\tsearch\\*_sample.*") ], - $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}; - File::Find::find( - { - wanted =>sub { - /^(.*--.*\.sql|.*\.control)\z/s - &&push(@$pl_extension_files, $File::Find::name); - } - }, - @pldirs - ); - CopySetOfFiles('PL Extension files', $pl_extension_files,$target . '/share/extension/'); - - GenerateNLSFiles($target,$config->{nls},$majorver) if ($config->{nls}); - - print "Installation complete.\n"; + $| = 1; + + my $target = shift; + our $config; + require "config_default.pl"; + require "config.pl" if (-f "config.pl"); + + chdir("../../..") if (-f "../../../configure"); + chdir("../../../..") if (-f "../../../../configure"); + my $conf = ""; + if (-d "debug") + { + $conf = "debug"; + } + if (-d "release") + { + $conf = "release"; + } + die "Could not find debug or release binaries" if ($conf eq ""); + 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'); + + CopySolutionOutput($conf, $target); + lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll'); + my $sample_files = []; + File::Find::find( + { + wanted =>sub { + /^.*\.sample\z/s + &&push(@$sample_files, $File::Find::name); + } + }, + "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" + ); + CopySetOfFiles( + 'timezone names', + [ glob('src\timezone\tznames\*.txt') ], + $target . '/share/timezonesets/' + ); + CopyFiles( + 'timezone sets', + $target . '/share/timezonesets/', + '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/'); + CopyFiles( + 'Information schema data',$target . '/share/', + 'src/backend/catalog/', 'sql_features.txt' + ); + GenerateConversionScript($target); + GenerateTimezoneFiles($target,$conf); + GenerateTsearchFiles($target); + CopySetOfFiles( + 'Stopword files', + [ glob("src\\backend\\snowball\\stopwords\\*.stop") ], + $target . '/share/tsearch_data/' + ); + CopySetOfFiles( + 'Dictionaries sample files', + [ glob("src\\backend\\tsearch\\*_sample.*") ], + $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}; + File::Find::find( + { + wanted =>sub { + /^(.*--.*\.sql|.*\.control)\z/s + &&push(@$pl_extension_files, + $File::Find::name); + } + }, + @pldirs + ); + CopySetOfFiles('PL Extension files', $pl_extension_files,$target . '/share/extension/'); + + GenerateNLSFiles($target,$config->{nls},$majorver) if ($config->{nls}); + + print "Installation complete.\n"; } sub EnsureDirectories { - my $target = shift; - mkdir $target unless -d ($target); - while (my $d = shift) - { - mkdir $target . '/' . $d unless -d ($target . '/' . $d); - } + my $target = shift; + mkdir $target unless -d ($target); + while (my $d = shift) + { + mkdir $target . '/' . $d unless -d ($target . '/' . $d); + } } sub CopyFiles { - my $what = shift; - my $target = shift; - my $basedir = shift; - - print "Copying $what"; - while (my $f = shift) - { - print "."; - $f = $basedir . $f; - die "No file $f\n" if (!-f $f); - lcopy($f, $target . basename($f)); - } - print "\n"; + my $what = shift; + my $target = shift; + my $basedir = shift; + + print "Copying $what"; + while (my $f = shift) + { + print "."; + $f = $basedir . $f; + die "No file $f\n" if (!-f $f); + lcopy($f, $target . basename($f)); + } + print "\n"; } sub CopySetOfFiles { - 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 - my $tgt = $target . basename($_); - print "."; - lcopy($_, $tgt) || croak "Could not copy $_: $!\n"; - } - print "\n"; + 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 + my $tgt = $target . basename($_); + print "."; + lcopy($_, $tgt) || croak "Could not copy $_: $!\n"; + } + print "\n"; } sub CopySolutionOutput { - my $conf = shift; - my $target = shift; - 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) - { - $vcproj = 'vcxproj'; - } - - print "Copying build output files..."; - while ($sln =~ $rem) - { - my $pf = $1; - my $dir; - my $ext; - - $sln =~ s/$rem//; - - my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n"; - if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"}) - { - if ($1 == 1) - { - $dir = "bin"; - $ext = "exe"; - } - elsif ($1 == 2) - { - $dir = "lib"; - $ext = "dll"; - } - else - { - - # Static lib, such as libpgport, only used internally during build, don't install - next; - } - } - elsif ($vcproj eq 'vcxproj' && $proj =~ qr{<ConfigurationType>(\w+)</ConfigurationType>}) - { - if ($1 eq 'Application') - { - $dir = "bin"; - $ext = "exe"; - } - elsif ($1 eq 'DynamicLibrary') - { - $dir = "lib"; - $ext = "dll"; - } - else # 'StaticLibrary' - { - - # Static lib, such as libpgport, only used internally during build, don't install - next; - } - } - else - { - croak "Could not parse $pf.$vcproj\n"; - } - 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") - || croak "Could not copy $pf.pdb\n"; - print "."; - } - print "\n"; + my $conf = shift; + my $target = shift; + 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) + { + $vcproj = 'vcxproj'; + } + + print "Copying build output files..."; + while ($sln =~ $rem) + { + my $pf = $1; + my $dir; + my $ext; + + $sln =~ s/$rem//; + + my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n"; + if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"}) + { + if ($1 == 1) + { + $dir = "bin"; + $ext = "exe"; + } + elsif ($1 == 2) + { + $dir = "lib"; + $ext = "dll"; + } + else + { + + # Static lib, such as libpgport, only used internally during build, don't install + next; + } + } + elsif ( $vcproj eq 'vcxproj' + && $proj =~ qr{<ConfigurationType>(\w+)</ConfigurationType>}) + { + if ($1 eq 'Application') + { + $dir = "bin"; + $ext = "exe"; + } + elsif ($1 eq 'DynamicLibrary') + { + $dir = "lib"; + $ext = "dll"; + } + else # 'StaticLibrary' + { + + # Static lib, such as libpgport, only used internally during build, don't install + next; + } + } + else + { + croak "Could not parse $pf.$vcproj\n"; + } + 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") + || croak "Could not copy $pf.pdb\n"; + print "."; + } + print "\n"; } sub GenerateConversionScript { - my $target = shift; - my $sql = ""; - my $F; - - print "Generating conversion proc script..."; - my $mf = read_file('src/backend/utils/mb/conversion_procs/Makefile'); - $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; - while ($#pieces > 0) - { - my $name = shift @pieces; - my $se = shift @pieces; - my $de = shift @pieces; - my $func = shift @pieces; - my $obj = shift @pieces; - $sql .= "-- $se --> $de\n"; - $sql .= + my $target = shift; + my $sql = ""; + my $F; + + print "Generating conversion proc script..."; + my $mf = read_file('src/backend/utils/mb/conversion_procs/Makefile'); + $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; + while ($#pieces > 0) + { + my $name = shift @pieces; + my $se = shift @pieces; + my $de = shift @pieces; + my $func = 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"; - $sql .= + $sql .= "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"; - } - open($F,">$target/share/conversion_create.sql") - || die "Could not write to conversion_create.sql\n"; - print $F $sql; - close($F); - print "\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"; + } + open($F,">$target/share/conversion_create.sql") + || die "Could not write to conversion_create.sql\n"; + print $F $sql; + close($F); + print "\n"; } sub GenerateTimezoneFiles { - my $target = shift; - 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,''; - print "Generating timezone files..."; - system( - "$conf\\zic\\zic -d \"$target/share/timezone\" " . join(" src/timezone/data/", @tzfiles)); - print "\n"; + my $target = shift; + 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,''; + print "Generating timezone files..."; + system("$conf\\zic\\zic -d \"$target/share/timezone\" " + . join(" src/timezone/data/", @tzfiles)); + print "\n"; } sub GenerateTsearchFiles { - my $target = shift; - - print "Generating tsearch script..."; - my $F; - my $tmpl = read_file('src/backend/snowball/snowball.sql.in'); - 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") - || 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 $asclang = shift @pieces || last; - my $txt = $tmpl; - my $stop = ''; - - if (-s "src/backend/snowball/stopwords/$lang.stop") - { - $stop = ", StopWords=$lang"; - } - - $txt =~ s#_LANGNAME_#${lang}#gs; - $txt =~ s#_DICTNAME_#${lang}_stem#gs; - $txt =~ s#_CFGNAME_#${lang}#gs; - $txt =~ s#_ASCDICTNAME_#${asclang}_stem#gs; - $txt =~ s#_NONASCDICTNAME_#${lang}_stem#gs; - $txt =~ s#_STOPWORDS_#$stop#gs; - print $F $txt; - print "."; - } - close($F); - print "\n"; + my $target = shift; + + print "Generating tsearch script..."; + my $F; + my $tmpl = read_file('src/backend/snowball/snowball.sql.in'); + 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") + || 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 $asclang = shift @pieces || last; + my $txt = $tmpl; + my $stop = ''; + + if (-s "src/backend/snowball/stopwords/$lang.stop") + { + $stop = ", StopWords=$lang"; + } + + $txt =~ s#_LANGNAME_#${lang}#gs; + $txt =~ s#_DICTNAME_#${lang}_stem#gs; + $txt =~ s#_CFGNAME_#${lang}#gs; + $txt =~ s#_ASCDICTNAME_#${asclang}_stem#gs; + $txt =~ s#_NONASCDICTNAME_#${lang}_stem#gs; + $txt =~ s#_STOPWORDS_#$stop#gs; + print $F $txt; + print "."; + } + close($F); + print "\n"; } sub CopyContribFiles { - my $config = shift; - my $target = shift; - - print "Copying contrib data files..."; - my $D; - opendir($D, 'contrib') || croak "Could not opendir on contrib!\n"; - while (my $d = readdir($D)) - { - 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 "sepgsql"); - - my $mf = read_file("contrib/$d/Makefile"); - $mf =~ s{\\s*[\r\n]+}{}mg; - - # Note: we currently don't support setting MODULEDIR in the makefile - my $moduledir = 'contrib'; - - my $flist = ''; - if ($mf =~ /^EXTENSION\s*=\s*(.*)$/m) {$flist .= $1} - if ($flist ne '') - { - $moduledir = 'extension'; - $flist = ParseAndCleanRule($flist, $mf); - - 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"); - 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 ($flist ne '') - { - $flist = ParseAndCleanRule($flist, $mf); - - foreach my $f (split /\s+/,$flist) - { - lcopy('contrib/' . $d . '/' . $f, - $target . '/share/' . $moduledir . '/' . basename($f)) - || croak("Could not copy file $f in contrib $d"); - print '.'; - } - } - - $flist = ''; - if ($mf =~ /^DATA_TSEARCH\s*=\s*(.*)$/m) {$flist .= $1} - if ($flist ne '') - { - $flist = ParseAndCleanRule($flist, $mf); - - foreach my $f (split /\s+/,$flist) - { - lcopy('contrib/' . $d . '/' . $f,$target . '/share/tsearch_data/' . basename($f)) - || croak("Could not copy file $f in contrib $d"); - print '.'; - } - } - - $flist = ''; - if ($mf =~ /^DOCS\s*=\s*(.*)$/mg) {$flist .= $1} - if ($flist ne '') - { - $flist = ParseAndCleanRule($flist, $mf); - - # Special case for contrib/spi - $flist = + my $config = shift; + my $target = shift; + + print "Copying contrib data files..."; + my $D; + opendir($D, 'contrib') || croak "Could not opendir on contrib!\n"; + while (my $d = readdir($D)) + { + 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 "sepgsql"); + + my $mf = read_file("contrib/$d/Makefile"); + $mf =~ s{\\s*[\r\n]+}{}mg; + + # Note: we currently don't support setting MODULEDIR in the makefile + my $moduledir = 'contrib'; + + my $flist = ''; + if ($mf =~ /^EXTENSION\s*=\s*(.*)$/m) {$flist .= $1} + if ($flist ne '') + { + $moduledir = 'extension'; + $flist = ParseAndCleanRule($flist, $mf); + + 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"); + 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 ($flist ne '') + { + $flist = ParseAndCleanRule($flist, $mf); + + foreach my $f (split /\s+/,$flist) + { + lcopy('contrib/' . $d . '/' . $f, + $target . '/share/' . $moduledir . '/' . basename($f)) + || croak("Could not copy file $f in contrib $d"); + print '.'; + } + } + + $flist = ''; + if ($mf =~ /^DATA_TSEARCH\s*=\s*(.*)$/m) {$flist .= $1} + if ($flist ne '') + { + $flist = ParseAndCleanRule($flist, $mf); + + foreach my $f (split /\s+/,$flist) + { + lcopy('contrib/' . $d . '/' . $f, + $target . '/share/tsearch_data/' . basename($f)) + || croak("Could not copy file $f in contrib $d"); + print '.'; + } + } + + $flist = ''; + if ($mf =~ /^DOCS\s*=\s*(.*)$/mg) {$flist .= $1} + if ($flist ne '') + { + $flist = ParseAndCleanRule($flist, $mf); + + # Special case for contrib/spi + $flist = "autoinc.example insert_username.example moddatetime.example refint.example timetravel.example" - if ($d eq 'spi'); - foreach my $f (split /\s+/,$flist) - { - lcopy('contrib/' . $d . '/' . $f,$target . '/doc/' . $moduledir . '/' . $f) - || croak("Could not copy file $f in contrib $d"); - print '.'; - } - } - } - closedir($D); - print "\n"; + if ($d eq 'spi'); + foreach my $f (split /\s+/,$flist) + { + lcopy('contrib/' . $d . '/' . $f, + $target . '/doc/' . $moduledir . '/' . $f) + || croak("Could not copy file $f in contrib $d"); + print '.'; + } + } + } + closedir($D); + print "\n"; } sub ParseAndCleanRule { - my $flist = 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++) - { - $pcount++ if (substr($flist, $i, 1) eq '('); - $pcount-- if (substr($flist, $i, 1) eq ')'); - last if ($pcount < 0); - } - $flist = substr($flist, 0, index($flist, '$(addsuffix ')) . substr($flist, $i+1); - } - return $flist; + my $flist = 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++) + { + $pcount++ if (substr($flist, $i, 1) eq '('); + $pcount-- if (substr($flist, $i, 1) eq ')'); + last if ($pcount < 0); + } + $flist = substr($flist, 0, index($flist, '$(addsuffix ')) . substr($flist, $i+1); + } + return $flist; } sub CopyIncludeFiles { - my $target = shift; - - 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' - ); - 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' - ); - CopyFiles( - 'Libpq internal headers', - $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' - ); - 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' - ); - CopyFiles('Grammar header', $target . '/include/server/parser/','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'); - - # some xcopy progs don't like mixed slash style paths - (my $ctarget = $target) =~ s!/!\\!g; - while (my $d = readdir($D)) - { - next if ($d =~ /^\./); - next if ($d eq '.git'); - next if ($d eq 'CVS'); - next unless (-d "src/include/$d"); - - 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"); - } - 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"; - 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"; - EnsureDirectories($target . '/include', 'informix', 'informix/esql'); - CopyFiles( - 'ECPG informix headers', - $target .'/include/informix/esql/', - 'src/interfaces/ecpg/include/', - split /\s+/,$1 - ); + my $target = shift; + + 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' + ); + 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' + ); + CopyFiles( + 'Libpq internal headers', + $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' + ); + 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' + ); + CopyFiles( + 'Grammar header', + $target . '/include/server/parser/', + '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' + ); + + # some xcopy progs don't like mixed slash style paths + (my $ctarget = $target) =~ s!/!\\!g; + while (my $d = readdir($D)) + { + next if ($d =~ /^\./); + next if ($d eq '.git'); + next if ($d eq 'CVS'); + next unless (-d "src/include/$d"); + + 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"); + } + 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"; + 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"; + EnsureDirectories($target . '/include', 'informix', 'informix/esql'); + CopyFiles( + 'ECPG informix headers', + $target .'/include/informix/esql/', + 'src/interfaces/ecpg/include/', + split /\s+/,$1 + ); } sub GenerateNLSFiles { - my $target = shift; - my $nlspath = shift; - my $majorver = shift; - - print "Installing NLS files..."; - EnsureDirectories($target, "share/locale"); - my @flist; - File::Find::find( - { - wanted =>sub { - /^nls\.mk\z/s - &&!push(@flist, $File::Find::name); - } - }, - "src" - ); - foreach (@flist) - { - my $prgm = DetermineCatalogName($_); - s/nls.mk/po/; - my $dir = $_; - next unless ($dir =~ /([^\/]+)\/po$/); - foreach (glob("$dir/*.po")) - { - my $lang; - next unless /([^\/]+)\.po/; - $lang = $1; - - EnsureDirectories($target, "share/locale/$lang", "share/locale/$lang/LC_MESSAGES"); - system( + my $target = shift; + my $nlspath = shift; + my $majorver = shift; + + print "Installing NLS files..."; + EnsureDirectories($target, "share/locale"); + my @flist; + File::Find::find( + { + wanted =>sub { + /^nls\.mk\z/s + &&!push(@flist, $File::Find::name); + } + }, + "src" + ); + foreach (@flist) + { + my $prgm = DetermineCatalogName($_); + s/nls.mk/po/; + my $dir = $_; + next unless ($dir =~ /([^\/]+)\/po$/); + foreach (glob("$dir/*.po")) + { + my $lang; + next unless /([^\/]+)\.po/; + $lang = $1; + + EnsureDirectories($target, "share/locale/$lang", + "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\\$_"); - print "."; - } - } - print "\n"; + )&& croak("Could not run msgfmt on $dir\\$_"); + print "."; + } + } + print "\n"; } sub DetermineMajorVersion { - 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; + 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; } sub DetermineCatalogName { - my $filename = shift; + my $filename = shift; - my $f = read_file($filename) || croak "Could not open $filename"; - $f =~ /CATALOG_NAME\s*\:?=\s*(\S+)/m || croak "Could not determine catalog name in $filename"; - return $1; + my $f = read_file($filename) || croak "Could not open $filename"; + $f =~ /CATALOG_NAME\s*\:?=\s*(\S+)/m + || croak "Could not determine catalog name in $filename"; + return $1; } sub read_file { - my $filename = shift; - my $F; - my $t = $/; + my $filename = shift; + my $F; + my $t = $/; - undef $/; - open($F, $filename) || die "Could not open file $filename\n"; - my $txt = <$F>; - close($F); - $/ = $t; + undef $/; + open($F, $filename) || die "Could not open file $filename\n"; + my $txt = <$F>; + close($F); + $/ = $t; - return $txt; + return $txt; } 1; diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm index fcce9ebb68d..4e6ea1f7409 100644 --- a/src/tools/msvc/MSBuildProject.pm +++ b/src/tools/msvc/MSBuildProject.pm @@ -13,158 +13,159 @@ use base qw(Project); sub _new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{filenameExtension} = '.vcxproj'; + $self->{filenameExtension} = '.vcxproj'; - return $self; + return $self; } sub WriteHeader { - my ($self, $f) = @_; + my ($self, $f) = @_; - print $f <<EOF; + print $f <<EOF; <?xml version="1.0" encoding="Windows-1252"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> EOF - $self->WriteConfigurationHeader($f, 'Debug'); - $self->WriteConfigurationHeader($f, 'Release'); - print $f <<EOF; + $self->WriteConfigurationHeader($f, 'Debug'); + $self->WriteConfigurationHeader($f, 'Release'); + print $f <<EOF; </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>$self->{guid}</ProjectGuid> </PropertyGroup> <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> EOF - $self->WriteConfigurationPropertyGroup($f, 'Release',{ wholeopt=>'false' }); - $self->WriteConfigurationPropertyGroup($f, 'Debug',{ wholeopt=>'false' }); - print $f <<EOF; + $self->WriteConfigurationPropertyGroup($f, 'Release',{wholeopt=>'false'}); + $self->WriteConfigurationPropertyGroup($f, 'Debug',{wholeopt=>'false'}); + print $f <<EOF; <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> EOF - $self->WritePropertySheetsPropertyGroup($f, 'Release'); - $self->WritePropertySheetsPropertyGroup($f, 'Debug'); - print $f <<EOF; + $self->WritePropertySheetsPropertyGroup($f, 'Release'); + $self->WritePropertySheetsPropertyGroup($f, 'Debug'); + print $f <<EOF; <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> EOF - $self->WriteAdditionalProperties($f, 'Debug'); - $self->WriteAdditionalProperties($f, 'Release'); - print $f <<EOF; + $self->WriteAdditionalProperties($f, 'Debug'); + $self->WriteAdditionalProperties($f, 'Release'); + print $f <<EOF; </PropertyGroup> 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' }); + $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'}); } sub AddDefine { - my ($self, $def) = @_; + my ($self, $def) = @_; - $self->{defines} .= $def . ';'; + $self->{defines} .= $def . ';'; } sub WriteReferences { - my ($self, $f) = @_; + my ($self, $f) = @_; - my @references = @{$self->{references}}; + my @references = @{$self->{references}}; - if (scalar(@references)) - { - print $f <<EOF; + if (scalar(@references)) + { + print $f <<EOF; <ItemGroup> EOF - foreach my $ref (@references) - { - print $f <<EOF; + foreach my $ref (@references) + { + print $f <<EOF; <ProjectReference Include="$ref->{name}$ref->{filenameExtension}"> <Project>$ref->{guid}</Project> </ProjectReference> EOF - } - print $f <<EOF; + } + print $f <<EOF; </ItemGroup> EOF - } + } } sub WriteFiles { - my ($self, $f) = @_; - print $f <<EOF; + my ($self, $f) = @_; + print $f <<EOF; <ItemGroup> EOF - my @grammarFiles = (); - my @resourceFiles = (); - my %uniquefiles; - foreach my $fileNameWithPath (sort keys %{ $self->{files} }) - { - confess "Bad format filename '$fileNameWithPath'\n" - unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); - my $dir = $1; - my $fileName = $2; - if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/) - { - push @grammarFiles, $fileNameWithPath; - } - elsif ($fileNameWithPath =~ /\.rc$/) - { - push @resourceFiles, $fileNameWithPath; - } - elsif (defined($uniquefiles{$fileName})) - { - - # File already exists, so fake a new name - my $obj = $dir; - $obj =~ s/\\/_/g; - - print $f <<EOF; + my @grammarFiles = (); + my @resourceFiles = (); + my %uniquefiles; + foreach my $fileNameWithPath (sort keys %{$self->{files}}) + { + confess "Bad format filename '$fileNameWithPath'\n" + unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); + my $dir = $1; + my $fileName = $2; + if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/) + { + push @grammarFiles, $fileNameWithPath; + } + elsif ($fileNameWithPath =~ /\.rc$/) + { + push @resourceFiles, $fileNameWithPath; + } + elsif (defined($uniquefiles{$fileName})) + { + + # File already exists, so fake a new name + my $obj = $dir; + $obj =~ s/\\/_/g; + + print $f <<EOF; <ClCompile Include="$fileNameWithPath"> <ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">.\\debug\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName> <ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">.\\release\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName> </ClCompile> EOF - } - else - { - $uniquefiles{$fileName} = 1; - print $f <<EOF; + } + else + { + $uniquefiles{$fileName} = 1; + print $f <<EOF; <ClCompile Include="$fileNameWithPath" /> EOF - } + } - } - print $f <<EOF; + } + print $f <<EOF; </ItemGroup> EOF - if (scalar(@grammarFiles)) - { - print $f <<EOF; + if (scalar(@grammarFiles)) + { + print $f <<EOF; <ItemGroup> EOF - foreach my $grammarFile (@grammarFiles) - { - (my $outputFile = $grammarFile) =~ s/\.(y|l)$/.c/; - if ($grammarFile =~ /\.y$/) - { - $outputFile =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; - print $f <<EOF; + foreach my $grammarFile (@grammarFiles) + { + (my $outputFile = $grammarFile) =~ s/\.(y|l)$/.c/; + if ($grammarFile =~ /\.y$/) + { + $outputFile =~ +s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; + print $f <<EOF; <CustomBuild Include="$grammarFile"> <Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running bison on $grammarFile</Message> <Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgbison.pl" "$grammarFile"</Command> @@ -176,10 +177,10 @@ EOF <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs> </CustomBuild> EOF - } - else #if ($grammarFile =~ /\.l$/) - { - print $f <<EOF; + } + else #if ($grammarFile =~ /\.l$/) + { + print $f <<EOF; <CustomBuild Include="$grammarFile"> <Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running flex on $grammarFile</Message> <Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgflex.pl" "$grammarFile"</Command> @@ -191,33 +192,33 @@ EOF <Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs> </CustomBuild> EOF - } - } - print $f <<EOF; + } + } + print $f <<EOF; </ItemGroup> EOF - } - if (scalar(@resourceFiles)) - { - print $f <<EOF; + } + if (scalar(@resourceFiles)) + { + print $f <<EOF; <ItemGroup> EOF - foreach my $rcFile (@resourceFiles) - { - print $f <<EOF; + foreach my $rcFile (@resourceFiles) + { + print $f <<EOF; <ResourceCompile Include="$rcFile" /> EOF - } - print $f <<EOF; + } + print $f <<EOF; </ItemGroup> EOF - } + } } sub WriteConfigurationHeader { - my ($self, $f, $cfgname) = @_; - print $f <<EOF; + my ($self, $f, $cfgname) = @_; + print $f <<EOF; <ProjectConfiguration Include="$cfgname|$self->{platform}"> <Configuration>$cfgname</Configuration> <Platform>$self->{platform}</Platform> @@ -227,13 +228,13 @@ EOF sub WriteConfigurationPropertyGroup { - my ($self, $f, $cfgname, $p) = @_; - my $cfgtype = - ($self->{type} eq "exe") - ?'Application' - :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); + my ($self, $f, $cfgname, $p) = @_; + my $cfgtype = + ($self->{type} eq "exe") + ?'Application' + :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); - print $f <<EOF; + print $f <<EOF; <PropertyGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="Configuration"> <ConfigurationType>$cfgtype</ConfigurationType> <UseOfMfc>false</UseOfMfc> @@ -245,8 +246,8 @@ EOF sub WritePropertySheetsPropertyGroup { - my ($self, $f, $cfgname) = @_; - print $f <<EOF; + my ($self, $f, $cfgname) = @_; + print $f <<EOF; <ImportGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="PropertySheets"> <Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> @@ -255,8 +256,8 @@ EOF sub WriteAdditionalProperties { - my ($self, $f, $cfgname) = @_; - print $f <<EOF; + my ($self, $f, $cfgname) = @_; + print $f <<EOF; <OutDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</OutDir> <IntDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</IntDir> <LinkIncremental Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">false</LinkIncremental> @@ -265,21 +266,21 @@ EOF sub WriteItemDefinitionGroup { - my ($self, $f, $cfgname, $p) = @_; - my $cfgtype = - ($self->{type} eq "exe") - ?'Application' - :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); - my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';'); - - my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; - - my $includes = $self->{includes}; - unless ($includes eq '' or $includes =~ /;$/) - { - $includes .= ';'; - } - print $f <<EOF; + my ($self, $f, $cfgname, $p) = @_; + my $cfgtype = + ($self->{type} eq "exe") + ?'Application' + :($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); + my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';'); + + my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; + + my $includes = $self->{includes}; + unless ($includes eq '' or $includes =~ /;$/) + { + $includes .= ';'; + } + print $f <<EOF; <ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'"> <ClCompile> <Optimization>$p->{opt}</Optimization> @@ -314,49 +315,49 @@ sub WriteItemDefinitionGroup <SubSystem>Console</SubSystem> <TargetMachine>$targetmachine</TargetMachine> EOF - if ($self->{disablelinkerwarnings}) - { - print $f + if ($self->{disablelinkerwarnings}) + { + print $f " <AdditionalOptions>/ignore:$self->{disablelinkerwarnings} \%(AdditionalOptions)</AdditionalOptions>\n"; - } - if ($self->{implib}) - { - my $l = $self->{implib}; - $l =~ s/__CFGNAME__/$cfgname/g; - print $f " <ImportLibrary>$l</ImportLibrary>\n"; - } - if ($self->{def}) - { - my $d = $self->{def}; - $d =~ s/__CFGNAME__/$cfgname/g; - print $f " <ModuleDefinitionFile>$d</ModuleDefinitionFile>\n"; - } - print $f <<EOF; + } + if ($self->{implib}) + { + my $l = $self->{implib}; + $l =~ s/__CFGNAME__/$cfgname/g; + print $f " <ImportLibrary>$l</ImportLibrary>\n"; + } + if ($self->{def}) + { + my $d = $self->{def}; + $d =~ s/__CFGNAME__/$cfgname/g; + print $f " <ModuleDefinitionFile>$d</ModuleDefinitionFile>\n"; + } + print $f <<EOF; </Link> <ResourceCompile> <AdditionalIncludeDirectories>src\\include;\%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> EOF - if ($self->{builddef}) - { - print $f <<EOF; + if ($self->{builddef}) + { + print $f <<EOF; <PreLinkEvent> <Message>Generate DEF file</Message> <Command>perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}</Command> </PreLinkEvent> EOF - } - print $f <<EOF; + } + print $f <<EOF; </ItemDefinitionGroup> EOF } sub Footer { - my ($self, $f) = @_; - $self->WriteReferences($f); + my ($self, $f) = @_; + $self->WriteReferences($f); - print $f <<EOF; + print $f <<EOF; <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> @@ -376,13 +377,13 @@ use base qw(MSBuildProject); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{vcver} = '10.00'; + $self->{vcver} = '10.00'; - return $self; + return $self; } 1; diff --git a/src/tools/msvc/Mkvcbuild.pm b/src/tools/msvc/Mkvcbuild.pm index f0fad43fead..23023e54b7e 100644 --- a/src/tools/msvc/Mkvcbuild.pm +++ b/src/tools/msvc/Mkvcbuild.pm @@ -30,488 +30,506 @@ 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' + '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'] + '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'); - - my $vsVersion = DetermineVisualStudioVersion(); - - $solution = CreateSolution($vsVersion, $config); - - our @pgportfiles = qw( - chklocale.c crypt.c fls.c fseeko.c getrusage.c inet_aton.c random.c - srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c - erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c exec.c noblock.c path.c - pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c - 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->AddDefine('FRONTEND'); - $libpgport->AddFiles('src\port',@pgportfiles); - - $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->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->AddDefine('BUILDING_DLL'); - $postgres->AddLibrary('wsock32.lib'); - $postgres->AddLibrary('ws2_32.lib'); - $postgres->AddLibrary('secur32.lib'); - $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap}); - $postgres->FullExportDLL('postgres.lib'); - - 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'); - $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'); - $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")) - { - my $xsubppdir = first { -e "$_\\ExtUtils\\xsubpp" } @INC; - print "Building $plperlsrc$xsc...\n"; - system( $solution->{options}->{perl} - . '/bin/perl ' - . "$xsubppdir/ExtUtils/xsubpp -typemap " - . $solution->{options}->{perl} - . '/lib/ExtUtils/typemap ' - . "$plperlsrc$xs " - . ">$plperlsrc$xsc"); - if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc") - { - unlink("$plperlsrc$xsc"); # if zero size - die "Failed to create $xsc.\n"; - } - } - } - 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')) - { - print 'Building src\pl\plperl\perlchunks.h ...' . "\n"; - my $basedir = getcwd; - chdir 'src\pl\plperl'; - system( $solution->{options}->{perl} - . '/bin/perl ' - . 'text2macro.pl ' - . '--strip="^(\#.*|\s*)$$" ' - . 'plc_perlboot.pl plc_trusted.pl ' - . '>perlchunks.h'); - chdir $basedir; - if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h') - { - unlink('src\pl\plperl\perlchunks.h'); # if zero size - die 'Failed to create perlchunks.h' . "\n"; - } - } - if ( Solution::IsNewer('src\pl\plperl\plperl_opmask.h','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} - . '/bin/perl ' - . 'plperl_opmask.pl ' - . '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 - 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'); - if (@perl_libs == 1) - { - $plperl->AddLibrary($perl_libs[0]); - } - else - { - die "could not identify perl library version"; - } - } - - if ($solution->{options}->{python}) - { - - # Attempt to get python version and location. - # Assume python.exe in specified dir. - open(P, - $solution->{options}->{python} - . "\\python -c \"import sys;print(sys.prefix);print(str(sys.version_info[0])+str(sys.version_info[1]))\" |" - ) || die "Could not query for python version!\n"; - my $pyprefix = <P>; - chomp($pyprefix); - my $pyver = <P>; - chomp($pyver); - close(P); - - # Sometimes (always?) if python is not present, the execution - # appears to work, but gives no data... - die "Failed to query python for version information\n" - if (!(defined($pyprefix) && defined($pyver))); - - my $pymajorver = substr($pyver, 0, 1); - 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); - } - - if ($solution->{options}->{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'); - } - else - { - $pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl84.lib'); - } - } - - $libpq = $solution->AddProject('libpq','dll','interfaces','src\interfaces\libpq'); - $libpq->AddDefine('FRONTEND'); - $libpq->AddDefine('UNSAFE_STAT_OK'); - $libpq->AddIncludeDir('src\port'); - $libpq->AddLibrary('wsock32.lib'); - $libpq->AddLibrary('secur32.lib'); - $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->AddReference($libpgport); - - my $libpqwalreceiver = $solution->AddProject('libpqwalreceiver', 'dll', '', - 'src\backend\replication\libpqwalreceiver'); - $libpqwalreceiver->AddIncludeDir('src\interfaces\libpq'); - $libpqwalreceiver->AddReference($postgres,$libpq); - - 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'); - $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); - - 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); - - 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->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'); - $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'); - $pgregress_ecpg->AddIncludeDir('src\test\regress'); - $pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); - $pgregress_ecpg->AddDefine('FRONTEND'); - $pgregress_ecpg->AddReference($libpgport); - - 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'); - $isolation_tester->AddFile('src\test\isolation\specparse.c'); - $isolation_tester->AddIncludeDir('src\test\isolation'); - $isolation_tester->AddIncludeDir('src\port'); - $isolation_tester->AddIncludeDir('src\test\regress'); - $isolation_tester->AddIncludeDir('src\interfaces\libpq'); - $isolation_tester->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); - $isolation_tester->AddDefine('FRONTEND'); - $isolation_tester->AddLibrary('wsock32.lib'); - $isolation_tester->AddReference($libpq, $libpgport); - - 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'); - $pgregress_isolation->AddIncludeDir('src\test\regress'); - $pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); - $pgregress_isolation->AddDefine('FRONTEND'); - $pgregress_isolation->AddReference($libpgport); - - # src/bin - my $initdb = AddSimpleFrontend('initdb'); - $initdb->AddIncludeDir('src\interfaces\libpq'); - $initdb->AddIncludeDir('src\timezone'); - $initdb->AddDefine('FRONTEND'); - $initdb->AddLibrary('wsock32.lib'); - $initdb->AddLibrary('ws2_32.lib'); - - my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1); - $pgbasebackup->AddFile('src\bin\pg_basebackup\pg_basebackup.c'); - $pgbasebackup->AddLibrary('ws2_32.lib'); - - my $pgreceivexlog = AddSimpleFrontend('pg_basebackup', 1); - $pgreceivexlog->{name} = 'pg_receivexlog'; - $pgreceivexlog->AddFile('src\bin\pg_basebackup\pg_receivexlog.c'); - $pgreceivexlog->AddLibrary('ws2_32.lib'); - - my $pgconfig = AddSimpleFrontend('pg_config'); - - my $pgcontrol = AddSimpleFrontend('pg_controldata'); - - my $pgctl = AddSimpleFrontend('pg_ctl', 1); - - 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'); - $pgevent->RemoveFile('src\bin\pgevent\win32ver.rc'); - $pgevent->UseDef('src\bin\pgevent\pgevent.def'); - $pgevent->DisableLinkerWarnings('4104'); - - my $psql = AddSimpleFrontend('psql', 1); - $psql->AddIncludeDir('src\bin\pg_dump'); - $psql->AddIncludeDir('src\backend'); - $psql->AddFile('src\bin\psql\psqlscan.l'); - - my $pgdump = AddSimpleFrontend('pg_dump', 1); - $pgdump->AddIncludeDir('src\backend'); - $pgdump->AddFile('src\bin\pg_dump\pg_dump.c'); - $pgdump->AddFile('src\bin\pg_dump\common.c'); - $pgdump->AddFile('src\bin\pg_dump\pg_dump_sort.c'); - $pgdump->AddFile('src\bin\pg_dump\keywords.c'); - $pgdump->AddFile('src\backend\parser\kwlookup.c'); - - my $pgdumpall = AddSimpleFrontend('pg_dump', 1); - - # pg_dumpall doesn't use the files in the Makefile's $(OBJS), unlike - # 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}; - $pgdumpall->{name} = 'pg_dumpall'; - $pgdumpall->AddIncludeDir('src\backend'); - $pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c'); - $pgdumpall->AddFile('src\bin\pg_dump\dumputils.c'); - $pgdumpall->AddFile('src\bin\pg_dump\dumpmem.c'); - $pgdumpall->AddFile('src\bin\pg_dump\keywords.c'); - $pgdumpall->AddFile('src\backend\parser\kwlookup.c'); - - my $pgrestore = AddSimpleFrontend('pg_dump', 1); - $pgrestore->{name} = 'pg_restore'; - $pgrestore->AddIncludeDir('src\backend'); - $pgrestore->AddFile('src\bin\pg_dump\pg_restore.c'); - $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'); - $zic->AddReference($libpgport); - - if ($solution->{options}->{xml}) - { - $contrib_extraincludes->{'pgxml'} = [ - $solution->{options}->{xml} . '\include', - $solution->{options}->{xslt} . '\include', - $solution->{options}->{iconv} . '\include' - ]; - - $contrib_extralibs->{'pgxml'} = [ - $solution->{options}->{xml} . '\lib\libxml2.lib', - $solution->{options}->{xslt} . '\lib\libxslt.lib' - ]; - } - else - { - push @contrib_excludes,'xml2'; - } - - if (!$solution->{options}->{openssl}) - { - push @contrib_excludes,'sslinfo'; - } - - if ($solution->{options}->{uuid}) - { - $contrib_extraincludes->{'uuid-ossp'} = [ $solution->{options}->{uuid} . '\include' ]; - $contrib_extralibs->{'uuid-ossp'} = [ $solution->{options}->{uuid} . '\lib\uuid.lib' ]; - } - else - { - push @contrib_excludes,'uuid-ossp'; - } - - # Pgcrypto makefile too complex to parse.... - 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' - ); - if ($solution->{options}->{openssl}) - { - $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' - ); - } - $pgcrypto->AddReference($postgres); - $pgcrypto->AddLibrary('wsock32.lib'); - my $mf = Project::read_file('contrib/pgcrypto/Makefile'); - GenerateContribSqlFiles('pgcrypto', $mf); - - my $D; - opendir($D, 'contrib') || croak "Could not opendir on contrib!\n"; - while (my $d = readdir($D)) - { - next if ($d =~ /^\./); - next unless (-f "contrib/$d/Makefile"); - next if (grep {/^$d$/} @contrib_excludes); - AddContrib($d); - } - closedir($D); - - $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) - { - 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'); - if ($mf =~ m{^SRCS\s*\+=\s*(.*)$}m) - { - $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) - { - 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/; - if ($f eq 'keywords.c') - { - $proj->AddFile('src\bin\pg_dump\keywords.c'); - } - elsif ($f eq 'kwlookup.c') - { - $proj->AddFile('src\backend\parser\kwlookup.c'); - } - elsif ($f eq 'dumputils.c') - { - $proj->AddFile('src\bin\pg_dump\dumputils.c'); - } - elsif ($f =~ /print\.c$/) - { # Also catches mbprint.c - $proj->AddFile('src\bin\psql\\' . $f); - } - elsif ($f =~ /\.c$/) - { - $proj->AddFile('src\bin\scripts\\' . $f); - } - } - $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'); - } - - # Regression DLL and EXE - 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'); - $pgregress->AddFile('src\test\regress\pg_regress.c'); - $pgregress->AddFile('src\test\regress\pg_regress_main.c'); - $pgregress->AddIncludeDir('src\port'); - $pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); - $pgregress->AddReference($libpgport); - - $solution->Save(); - return $solution->{vcver}; + our $config = shift; + + chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src'); + die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src'); + + my $vsVersion = DetermineVisualStudioVersion(); + + $solution = CreateSolution($vsVersion, $config); + + our @pgportfiles = qw( + chklocale.c crypt.c fls.c fseeko.c getrusage.c inet_aton.c random.c + srandom.c getaddrinfo.c gettimeofday.c inet_net_ntop.c kill.c open.c + erand48.c snprintf.c strlcat.c strlcpy.c dirmod.c exec.c noblock.c path.c + pgcheckdir.c pg_crc.c pgmkdirp.c pgsleep.c pgstrcasecmp.c qsort.c qsort_arg.c + 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->AddDefine('FRONTEND'); + $libpgport->AddFiles('src\port',@pgportfiles); + + $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->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->AddDefine('BUILDING_DLL'); + $postgres->AddLibrary('wsock32.lib'); + $postgres->AddLibrary('ws2_32.lib'); + $postgres->AddLibrary('secur32.lib'); + $postgres->AddLibrary('wldap32.lib') if ($solution->{options}->{ldap}); + $postgres->FullExportDLL('postgres.lib'); + + 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'); + $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'); + $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")) + { + my $xsubppdir = first { -e "$_\\ExtUtils\\xsubpp" } @INC; + print "Building $plperlsrc$xsc...\n"; + system( $solution->{options}->{perl} + . '/bin/perl ' + . "$xsubppdir/ExtUtils/xsubpp -typemap " + . $solution->{options}->{perl} + . '/lib/ExtUtils/typemap ' + . "$plperlsrc$xs " + . ">$plperlsrc$xsc"); + if ((!(-f "$plperlsrc$xsc")) || -z "$plperlsrc$xsc") + { + unlink("$plperlsrc$xsc"); # if zero size + die "Failed to create $xsc.\n"; + } + } + } + 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' + ) + ) + { + print 'Building src\pl\plperl\perlchunks.h ...' . "\n"; + my $basedir = getcwd; + chdir 'src\pl\plperl'; + system( $solution->{options}->{perl} + . '/bin/perl ' + . 'text2macro.pl ' + . '--strip="^(\#.*|\s*)$$" ' + . 'plc_perlboot.pl plc_trusted.pl ' + . '>perlchunks.h'); + chdir $basedir; + if ((!(-f 'src\pl\plperl\perlchunks.h')) || -z 'src\pl\plperl\perlchunks.h') + { + unlink('src\pl\plperl\perlchunks.h'); # if zero size + die 'Failed to create perlchunks.h' . "\n"; + } + } + if ( + Solution::IsNewer( + 'src\pl\plperl\plperl_opmask.h', + '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} + . '/bin/perl ' + . 'plperl_opmask.pl ' + . '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 + 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'); + if (@perl_libs == 1) + { + $plperl->AddLibrary($perl_libs[0]); + } + else + { + die "could not identify perl library version"; + } + } + + if ($solution->{options}->{python}) + { + + # Attempt to get python version and location. + # Assume python.exe in specified dir. + open(P, + $solution->{options}->{python} + . "\\python -c \"import sys;print(sys.prefix);print(str(sys.version_info[0])+str(sys.version_info[1]))\" |" + ) || die "Could not query for python version!\n"; + my $pyprefix = <P>; + chomp($pyprefix); + my $pyver = <P>; + chomp($pyver); + close(P); + + # Sometimes (always?) if python is not present, the execution + # appears to work, but gives no data... + die "Failed to query python for version information\n" + if (!(defined($pyprefix) && defined($pyver))); + + my $pymajorver = substr($pyver, 0, 1); + 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); + } + + if ($solution->{options}->{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'); + } + else + { + $pltcl->AddLibrary($solution->{options}->{tcl} . '\lib\tcl84.lib'); + } + } + + $libpq = $solution->AddProject('libpq','dll','interfaces','src\interfaces\libpq'); + $libpq->AddDefine('FRONTEND'); + $libpq->AddDefine('UNSAFE_STAT_OK'); + $libpq->AddIncludeDir('src\port'); + $libpq->AddLibrary('wsock32.lib'); + $libpq->AddLibrary('secur32.lib'); + $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->AddReference($libpgport); + + my $libpqwalreceiver = $solution->AddProject('libpqwalreceiver', 'dll', '', + 'src\backend\replication\libpqwalreceiver'); + $libpqwalreceiver->AddIncludeDir('src\interfaces\libpq'); + $libpqwalreceiver->AddReference($postgres,$libpq); + + 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'); + $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); + + 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); + + 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->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'); + $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'); + $pgregress_ecpg->AddIncludeDir('src\test\regress'); + $pgregress_ecpg->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); + $pgregress_ecpg->AddDefine('FRONTEND'); + $pgregress_ecpg->AddReference($libpgport); + + 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'); + $isolation_tester->AddFile('src\test\isolation\specparse.c'); + $isolation_tester->AddIncludeDir('src\test\isolation'); + $isolation_tester->AddIncludeDir('src\port'); + $isolation_tester->AddIncludeDir('src\test\regress'); + $isolation_tester->AddIncludeDir('src\interfaces\libpq'); + $isolation_tester->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); + $isolation_tester->AddDefine('FRONTEND'); + $isolation_tester->AddLibrary('wsock32.lib'); + $isolation_tester->AddReference($libpq, $libpgport); + + 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'); + $pgregress_isolation->AddIncludeDir('src\test\regress'); + $pgregress_isolation->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); + $pgregress_isolation->AddDefine('FRONTEND'); + $pgregress_isolation->AddReference($libpgport); + + # src/bin + my $initdb = AddSimpleFrontend('initdb'); + $initdb->AddIncludeDir('src\interfaces\libpq'); + $initdb->AddIncludeDir('src\timezone'); + $initdb->AddDefine('FRONTEND'); + $initdb->AddLibrary('wsock32.lib'); + $initdb->AddLibrary('ws2_32.lib'); + + my $pgbasebackup = AddSimpleFrontend('pg_basebackup', 1); + $pgbasebackup->AddFile('src\bin\pg_basebackup\pg_basebackup.c'); + $pgbasebackup->AddLibrary('ws2_32.lib'); + + my $pgreceivexlog = AddSimpleFrontend('pg_basebackup', 1); + $pgreceivexlog->{name} = 'pg_receivexlog'; + $pgreceivexlog->AddFile('src\bin\pg_basebackup\pg_receivexlog.c'); + $pgreceivexlog->AddLibrary('ws2_32.lib'); + + my $pgconfig = AddSimpleFrontend('pg_config'); + + my $pgcontrol = AddSimpleFrontend('pg_controldata'); + + my $pgctl = AddSimpleFrontend('pg_ctl', 1); + + 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'); + $pgevent->RemoveFile('src\bin\pgevent\win32ver.rc'); + $pgevent->UseDef('src\bin\pgevent\pgevent.def'); + $pgevent->DisableLinkerWarnings('4104'); + + my $psql = AddSimpleFrontend('psql', 1); + $psql->AddIncludeDir('src\bin\pg_dump'); + $psql->AddIncludeDir('src\backend'); + $psql->AddFile('src\bin\psql\psqlscan.l'); + + my $pgdump = AddSimpleFrontend('pg_dump', 1); + $pgdump->AddIncludeDir('src\backend'); + $pgdump->AddFile('src\bin\pg_dump\pg_dump.c'); + $pgdump->AddFile('src\bin\pg_dump\common.c'); + $pgdump->AddFile('src\bin\pg_dump\pg_dump_sort.c'); + $pgdump->AddFile('src\bin\pg_dump\keywords.c'); + $pgdump->AddFile('src\backend\parser\kwlookup.c'); + + my $pgdumpall = AddSimpleFrontend('pg_dump', 1); + + # pg_dumpall doesn't use the files in the Makefile's $(OBJS), unlike + # 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}; + $pgdumpall->{name} = 'pg_dumpall'; + $pgdumpall->AddIncludeDir('src\backend'); + $pgdumpall->AddFile('src\bin\pg_dump\pg_dumpall.c'); + $pgdumpall->AddFile('src\bin\pg_dump\dumputils.c'); + $pgdumpall->AddFile('src\bin\pg_dump\dumpmem.c'); + $pgdumpall->AddFile('src\bin\pg_dump\keywords.c'); + $pgdumpall->AddFile('src\backend\parser\kwlookup.c'); + + my $pgrestore = AddSimpleFrontend('pg_dump', 1); + $pgrestore->{name} = 'pg_restore'; + $pgrestore->AddIncludeDir('src\backend'); + $pgrestore->AddFile('src\bin\pg_dump\pg_restore.c'); + $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'); + $zic->AddReference($libpgport); + + if ($solution->{options}->{xml}) + { + $contrib_extraincludes->{'pgxml'} = [ + $solution->{options}->{xml} . '\include', + $solution->{options}->{xslt} . '\include', + $solution->{options}->{iconv} . '\include' + ]; + + $contrib_extralibs->{'pgxml'} = [ + $solution->{options}->{xml} . '\lib\libxml2.lib', + $solution->{options}->{xslt} . '\lib\libxslt.lib' + ]; + } + else + { + push @contrib_excludes,'xml2'; + } + + if (!$solution->{options}->{openssl}) + { + push @contrib_excludes,'sslinfo'; + } + + if ($solution->{options}->{uuid}) + { + $contrib_extraincludes->{'uuid-ossp'} = + [ $solution->{options}->{uuid} . '\include' ]; + $contrib_extralibs->{'uuid-ossp'} = + [ $solution->{options}->{uuid} . '\lib\uuid.lib' ]; + } + else + { + push @contrib_excludes,'uuid-ossp'; + } + + # Pgcrypto makefile too complex to parse.... + 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' + ); + if ($solution->{options}->{openssl}) + { + $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' + ); + } + $pgcrypto->AddReference($postgres); + $pgcrypto->AddLibrary('wsock32.lib'); + my $mf = Project::read_file('contrib/pgcrypto/Makefile'); + GenerateContribSqlFiles('pgcrypto', $mf); + + my $D; + opendir($D, 'contrib') || croak "Could not opendir on contrib!\n"; + while (my $d = readdir($D)) + { + next if ($d =~ /^\./); + next unless (-f "contrib/$d/Makefile"); + next if (grep {/^$d$/} @contrib_excludes); + AddContrib($d); + } + closedir($D); + + $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) + { + 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'); + if ($mf =~ m{^SRCS\s*\+=\s*(.*)$}m) + { + $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) + { + 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/; + if ($f eq 'keywords.c') + { + $proj->AddFile('src\bin\pg_dump\keywords.c'); + } + elsif ($f eq 'kwlookup.c') + { + $proj->AddFile('src\backend\parser\kwlookup.c'); + } + elsif ($f eq 'dumputils.c') + { + $proj->AddFile('src\bin\pg_dump\dumputils.c'); + } + elsif ($f =~ /print\.c$/) + { # Also catches mbprint.c + $proj->AddFile('src\bin\psql\\' . $f); + } + elsif ($f =~ /\.c$/) + { + $proj->AddFile('src\bin\scripts\\' . $f); + } + } + $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'); + } + + # Regression DLL and EXE + 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'); + $pgregress->AddFile('src\test\regress\pg_regress.c'); + $pgregress->AddFile('src\test\regress\pg_regress_main.c'); + $pgregress->AddIncludeDir('src\port'); + $pgregress->AddDefine('HOST_TUPLE="i686-pc-win32vc"'); + $pgregress->AddReference($libpgport); + + $solution->Save(); + return $solution->{vcver}; } ##################### @@ -521,174 +539,178 @@ sub mkvcbuild # Add a simple frontend project (exe) sub AddSimpleFrontend { - my $n = shift; - my $uselibpq= shift; - - my $p = $solution->AddProject($n,'exe','bin'); - $p->AddDir('src\bin\\' . $n); - $p->AddReference($libpgport); - if ($uselibpq) - { - $p->AddIncludeDir('src\interfaces\libpq'); - $p->AddReference($libpq); - } - return $p; + my $n = shift; + my $uselibpq= shift; + + my $p = $solution->AddProject($n,'exe','bin'); + $p->AddDir('src\bin\\' . $n); + $p->AddReference($libpgport); + if ($uselibpq) + { + $p->AddIncludeDir('src\interfaces\libpq'); + $p->AddReference($libpq); + } + return $p; } # Add a simple contrib project sub AddContrib { - my $n = shift; - my $mf = Project::read_file('contrib\\' . $n . '\Makefile'); - - if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg) - { - my $dn = $1; - $mf =~ s{\\\s*[\r\n]+}{}mg; - my $proj = $solution->AddProject($dn, 'dll', 'contrib'); - $mf =~ /^OBJS\s*=\s*(.*)$/gm || croak "Could not find objects in MODULE_big for $n\n"; - my $objs = $1; - while ($objs =~ /\b([\w-]+\.o)\b/g) - { - my $o = $1; - $o =~ s/\.o$/.c/; - $proj->AddFile('contrib\\' . $n . '\\' . $o); - } - $proj->AddReference($postgres); - if ($mf =~ /^SUBDIRS\s*:?=\s*(.*)$/mg) - { - foreach my $d (split /\s+/, $1) - { - my $mf2 = Project::read_file('contrib\\' . $n . '\\' . $d . '\Makefile'); - $mf2 =~ s{\\\s*[\r\n]+}{}mg; - $mf2 =~ /^SUBOBJS\s*=\s*(.*)$/gm - || croak "Could not find objects in MODULE_big for $n, subdir $d\n"; - $objs = $1; - while ($objs =~ /\b([\w-]+\.o)\b/g) - { - my $o = $1; - $o =~ s/\.o$/.c/; - $proj->AddFile('contrib\\' . $n . '\\' . $d . '\\' . $o); - } - } - } - AdjustContribProj($proj); - } - elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg) - { - foreach my $mod (split /\s+/, $1) - { - my $proj = $solution->AddProject($mod, 'dll', 'contrib'); - $proj->AddFile('contrib\\' . $n . '\\' . $mod . '.c'); - $proj->AddReference($postgres); - AdjustContribProj($proj); - } - } - elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg) - { - 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"; - my $objs = $1; - while ($objs =~ /\b([\w-]+\.o)\b/g) - { - my $o = $1; - $o =~ s/\.o$/.c/; - $proj->AddFile('contrib\\' . $n . '\\' . $o); - } - AdjustContribProj($proj); - } - else - { - croak "Could not determine contrib module type for $n\n"; - } - - # Are there any output data files to build? - GenerateContribSqlFiles($n, $mf); + my $n = shift; + my $mf = Project::read_file('contrib\\' . $n . '\Makefile'); + + if ($mf =~ /^MODULE_big\s*=\s*(.*)$/mg) + { + my $dn = $1; + $mf =~ s{\\\s*[\r\n]+}{}mg; + my $proj = $solution->AddProject($dn, 'dll', 'contrib'); + $mf =~ /^OBJS\s*=\s*(.*)$/gm + || croak "Could not find objects in MODULE_big for $n\n"; + my $objs = $1; + while ($objs =~ /\b([\w-]+\.o)\b/g) + { + my $o = $1; + $o =~ s/\.o$/.c/; + $proj->AddFile('contrib\\' . $n . '\\' . $o); + } + $proj->AddReference($postgres); + if ($mf =~ /^SUBDIRS\s*:?=\s*(.*)$/mg) + { + foreach my $d (split /\s+/, $1) + { + my $mf2 = + Project::read_file('contrib\\' . $n . '\\' . $d . '\Makefile'); + $mf2 =~ s{\\\s*[\r\n]+}{}mg; + $mf2 =~ /^SUBOBJS\s*=\s*(.*)$/gm + || croak + "Could not find objects in MODULE_big for $n, subdir $d\n"; + $objs = $1; + while ($objs =~ /\b([\w-]+\.o)\b/g) + { + my $o = $1; + $o =~ s/\.o$/.c/; + $proj->AddFile('contrib\\' . $n . '\\' . $d . '\\' . $o); + } + } + } + AdjustContribProj($proj); + } + elsif ($mf =~ /^MODULES\s*=\s*(.*)$/mg) + { + foreach my $mod (split /\s+/, $1) + { + my $proj = $solution->AddProject($mod, 'dll', 'contrib'); + $proj->AddFile('contrib\\' . $n . '\\' . $mod . '.c'); + $proj->AddReference($postgres); + AdjustContribProj($proj); + } + } + elsif ($mf =~ /^PROGRAM\s*=\s*(.*)$/mg) + { + 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"; + my $objs = $1; + while ($objs =~ /\b([\w-]+\.o)\b/g) + { + my $o = $1; + $o =~ s/\.o$/.c/; + $proj->AddFile('contrib\\' . $n . '\\' . $o); + } + AdjustContribProj($proj); + } + else + { + croak "Could not determine contrib module type for $n\n"; + } + + # Are there any output data files to build? + GenerateContribSqlFiles($n, $mf); } sub GenerateContribSqlFiles { - my $n = shift; - my $mf = shift; - if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg) - { - my $l = $1; - - # Strip out $(addsuffix) rules - if (index($l, '$(addsuffix ') >= 0) - { - my $pcount = 0; - my $i; - for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++) - { - $pcount++ if (substr($l, $i, 1) eq '('); - $pcount-- if (substr($l, $i, 1) eq ')'); - last if ($pcount < 0); - } - $l = substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i+1); - } - - foreach my $d (split /\s+/, $l) - { - 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$//; - $cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g; - my $o; - open($o,">contrib/$n/$out") || croak "Could not write to contrib/$n/$d"; - print $o $cont; - close($o); - } - } - } + my $n = shift; + my $mf = shift; + if ($mf =~ /^DATA_built\s*=\s*(.*)$/mg) + { + my $l = $1; + + # Strip out $(addsuffix) rules + if (index($l, '$(addsuffix ') >= 0) + { + my $pcount = 0; + my $i; + for ($i = index($l, '$(addsuffix ') + 12; $i < length($l); $i++) + { + $pcount++ if (substr($l, $i, 1) eq '('); + $pcount-- if (substr($l, $i, 1) eq ')'); + last if ($pcount < 0); + } + $l = substr($l, 0, index($l, '$(addsuffix ')) . substr($l, $i+1); + } + + foreach my $d (split /\s+/, $l) + { + 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$//; + $cont =~ s/MODULE_PATHNAME/\$libdir\/$dn/g; + my $o; + open($o,">contrib/$n/$out") + || croak "Could not write to contrib/$n/$d"; + print $o $cont; + close($o); + } + } + } } sub AdjustContribProj { - my $proj = shift; - my $n = $proj->{name}; - - if ($contrib_defines->{$n}) - { - foreach my $d ($contrib_defines->{$n}) - { - $proj->AddDefine($d); - } - } - if (grep {/^$n$/} @contrib_uselibpq) - { - $proj->AddIncludeDir('src\interfaces\libpq'); - $proj->AddReference($libpq); - } - if (grep {/^$n$/} @contrib_uselibpgport) - { - $proj->AddReference($libpgport); - } - if ($contrib_extralibs->{$n}) - { - foreach my $l (@{$contrib_extralibs->{$n}}) - { - $proj->AddLibrary($l); - } - } - if ($contrib_extraincludes->{$n}) - { - foreach my $i (@{$contrib_extraincludes->{$n}}) - { - $proj->AddIncludeDir($i); - } - } - if ($contrib_extrasource->{$n}) - { - $proj->AddFiles('contrib\\' . $n, @{$contrib_extrasource->{$n}}); - } + my $proj = shift; + my $n = $proj->{name}; + + if ($contrib_defines->{$n}) + { + foreach my $d ($contrib_defines->{$n}) + { + $proj->AddDefine($d); + } + } + if (grep {/^$n$/} @contrib_uselibpq) + { + $proj->AddIncludeDir('src\interfaces\libpq'); + $proj->AddReference($libpq); + } + if (grep {/^$n$/} @contrib_uselibpgport) + { + $proj->AddReference($libpgport); + } + if ($contrib_extralibs->{$n}) + { + foreach my $l (@{$contrib_extralibs->{$n}}) + { + $proj->AddLibrary($l); + } + } + if ($contrib_extraincludes->{$n}) + { + foreach my $i (@{$contrib_extraincludes->{$n}}) + { + $proj->AddIncludeDir($i); + } + } + if ($contrib_extrasource->{$n}) + { + $proj->AddFiles('contrib\\' . $n, @{$contrib_extrasource->{$n}}); + } } 1; diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm index 98db076e58c..53cfdb17538 100644 --- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -12,393 +12,394 @@ use File::Basename; sub _new { - my ($classname, $name, $type, $solution) = @_; - my $good_types = { - lib => 1, - exe => 1, - dll => 1, - }; - confess("Bad project type: $type\n") unless exists $good_types->{$type}; - my $self = { - name => $name, - type => $type, - guid => Win32::GuidGen(), - files => {}, - references => [], - libraries => [], - suffixlib => [], - includes => '', - prefixincludes => '', - defines => ';', - solution => $solution, - disablewarnings => '4018;4244;4273;4102;4090;4267', - disablelinkerwarnings => '', - platform => $solution->{platform}, - }; - - bless($self, $classname); - return $self; + my ($classname, $name, $type, $solution) = @_; + my $good_types = { + lib => 1, + exe => 1, + dll => 1, + }; + confess("Bad project type: $type\n") unless exists $good_types->{$type}; + my $self = { + name => $name, + type => $type, + guid => Win32::GuidGen(), + files => {}, + references => [], + libraries => [], + suffixlib => [], + includes => '', + prefixincludes => '', + defines => ';', + solution => $solution, + disablewarnings => '4018;4244;4273;4102;4090;4267', + disablelinkerwarnings => '', + platform => $solution->{platform}, + }; + + bless($self, $classname); + return $self; } sub AddFile { - my ($self, $filename) = @_; + my ($self, $filename) = @_; - $self->{files}->{$filename} = 1; + $self->{files}->{$filename} = 1; } sub AddFiles { - my $self = shift; - my $dir = shift; + my $self = shift; + my $dir = shift; - while (my $f = shift) - { - $self->{files}->{$dir . "\\" . $f} = 1; - } + while (my $f = shift) + { + $self->{files}->{$dir . "\\" . $f} = 1; + } } sub ReplaceFile { - my ($self, $filename, $newname) = @_; - my $re = "\\\\$filename\$"; - - foreach my $file ( keys %{ $self->{files} } ) - { - - # Match complete filename - if ($filename =~ /\\/) - { - if ($file eq $filename) - { - delete $self->{files}{$file}; - $self->{files}{$newname} = 1; - return; - } - } - elsif ($file =~ m/($re)/) - { - delete $self->{files}{$file}; - $self->{files}{"$newname\\$filename"} = 1; - return; - } - } - confess("Could not find file $filename to replace\n"); + my ($self, $filename, $newname) = @_; + my $re = "\\\\$filename\$"; + + foreach my $file (keys %{$self->{files}}) + { + + # Match complete filename + if ($filename =~ /\\/) + { + if ($file eq $filename) + { + delete $self->{files}{$file}; + $self->{files}{$newname} = 1; + return; + } + } + elsif ($file =~ m/($re)/) + { + delete $self->{files}{$file}; + $self->{files}{"$newname\\$filename"} = 1; + return; + } + } + confess("Could not find file $filename to replace\n"); } sub RemoveFile { - my ($self, $filename) = @_; - my $orig = scalar keys %{ $self->{files} }; - delete $self->{files}->{$filename}; - if ($orig > scalar keys %{$self->{files}} ) - { - return; - } - confess("Could not find file $filename to remove\n"); + my ($self, $filename) = @_; + my $orig = scalar keys %{$self->{files}}; + delete $self->{files}->{$filename}; + if ($orig > scalar keys %{$self->{files}}) + { + return; + } + confess("Could not find file $filename to remove\n"); } sub RelocateFiles { - my ($self, $targetdir, $proc) = @_; - foreach my $f (keys %{$self->{files}}) - { - my $r = &$proc($f); - if ($r) - { - $self->RemoveFile($f); - $self->AddFile($targetdir . '\\' . basename($f)); - } - } + my ($self, $targetdir, $proc) = @_; + foreach my $f (keys %{$self->{files}}) + { + my $r = &$proc($f); + if ($r) + { + $self->RemoveFile($f); + $self->AddFile($targetdir . '\\' . basename($f)); + } + } } sub AddReference { - my $self = shift; + my $self = shift; - while (my $ref = shift) - { - push @{$self->{references}},$ref; - $self->AddLibrary("__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); - } + while (my $ref = shift) + { + push @{$self->{references}},$ref; + $self->AddLibrary("__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); + } } sub AddLibrary { - my ($self, $lib, $dbgsuffix) = @_; - - if ($lib =~ m/\s/) - { - $lib = '"' . $lib . """; - } - - push @{$self->{libraries}}, $lib; - if ($dbgsuffix) - { - push @{$self->{suffixlib}}, $lib; - } + my ($self, $lib, $dbgsuffix) = @_; + + if ($lib =~ m/\s/) + { + $lib = '"' . $lib . """; + } + + push @{$self->{libraries}}, $lib; + if ($dbgsuffix) + { + push @{$self->{suffixlib}}, $lib; + } } sub AddIncludeDir { - my ($self, $inc) = @_; + my ($self, $inc) = @_; - if ($self->{includes} ne '') - { - $self->{includes} .= ';'; - } - $self->{includes} .= $inc; + if ($self->{includes} ne '') + { + $self->{includes} .= ';'; + } + $self->{includes} .= $inc; } sub AddPrefixInclude { - my ($self, $inc) = @_; + my ($self, $inc) = @_; - $self->{prefixincludes} = $inc . ';' . $self->{prefixincludes}; + $self->{prefixincludes} = $inc . ';' . $self->{prefixincludes}; } sub AddDefine { - my ($self, $def) = @_; + my ($self, $def) = @_; - $def =~ s/"/""/g; - $self->{defines} .= $def . ';'; + $def =~ s/"/""/g; + $self->{defines} .= $def . ';'; } sub FullExportDLL { - my ($self, $libname) = @_; + my ($self, $libname) = @_; - $self->{builddef} = 1; - $self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; - $self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; + $self->{builddef} = 1; + $self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; + $self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; } sub UseDef { - my ($self, $def) = @_; + my ($self, $def) = @_; - $self->{def} = $def; + $self->{def} = $def; } sub AddDir { - my ($self, $reldir) = @_; - my $MF; - - my $t = $/; - undef $/; - open($MF,"$reldir\\Makefile") - || open($MF,"$reldir\\GNUMakefile") - || croak "Could not open $reldir\\Makefile\n"; - my $mf = <$MF>; - close($MF); - - $mf =~ s{\\\s*[\r\n]+}{}mg; - if ($mf =~ m{^(?:SUB)?DIRS[^=]*=\s*(.*)$}mg) - { - foreach my $subdir (split /\s+/,$1) - { - next - if $subdir eq "\$(top_builddir)/src/timezone"; #special case for non-standard include - next - if $reldir . "\\" . $subdir eq "src\\backend\\port\\darwin"; - - $self->AddDir($reldir . "\\" . $subdir); - } - } - while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m) - { - my $s = $1; - my $filter_re = qr{\$\(filter ([^,]+),\s+\$\(([^\)]+)\)\)}; - while ($s =~ /$filter_re/) - { - - # Process $(filter a b c, $(VAR)) expressions - my $list = $1; - my $filter = $2; - $list =~ s/\.o/\.c/g; - my @pieces = split /\s+/, $list; - my $matches = ""; - foreach my $p (@pieces) - { - - if ($filter eq "LIBOBJS") - { - if (grep(/$p/, @main::pgportfiles) == 1) - { - $p =~ s/\.c/\.o/; - $matches .= $p . " "; - } - } - else - { - confess "Unknown filter $filter\n"; - } - } - $s =~ s/$filter_re/$matches/; - } - 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 - next unless $f =~ /.*\.o$/; - $f =~ s/\.o$/\.c/; - if ($f =~ /^\$\(top_builddir\)\/(.*)/) - { - $f = $1; - $f =~ s/\//\\/g; - $self->{files}->{$f} = 1; - } - else - { - $f =~ s/\//\\/g; - $self->{files}->{"$reldir\\$f"} = 1; - } - } - $mf =~ s{OBJS[^=]*=\s*(.*)$}{}m; - } - - # 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; - while ($mf =~ m{$replace_re}m) - { - my $match = $1; - my $top = $2; - my $target = $3; - $target =~ s{/}{\\}g; - my @pieces = split /\s+/,$match; - foreach my $fn (@pieces) - { - if ($top eq "(top_srcdir)") - { - eval { $self->ReplaceFile($fn, $target) }; - } - elsif ($top eq "(backend_src)") - { - eval { $self->ReplaceFile($fn, "src\\backend\\$target") }; - } - else - { - confess "Bad replacement top: $top, on line $_\n"; - } - } - $mf =~ s{$replace_re}{}m; - } - - # See if this Makefile contains a description, and should have a RC file - if ($mf =~ /^PGFILEDESC\s*=\s*\"([^\"]+)\"/m) - { - my $desc = $1; - my $ico; - if ($mf =~ /^PGAPPICON\s*=\s*(.*)$/m) { $ico = $1; } - $self->AddResourceFile($reldir,$desc,$ico); - } - $/ = $t; + my ($self, $reldir) = @_; + my $MF; + + my $t = $/; + undef $/; + open($MF,"$reldir\\Makefile") + || open($MF,"$reldir\\GNUMakefile") + || croak "Could not open $reldir\\Makefile\n"; + my $mf = <$MF>; + close($MF); + + $mf =~ s{\\\s*[\r\n]+}{}mg; + if ($mf =~ m{^(?:SUB)?DIRS[^=]*=\s*(.*)$}mg) + { + foreach my $subdir (split /\s+/,$1) + { + next + if $subdir eq "\$(top_builddir)/src/timezone" + ; #special case for non-standard include + next + if $reldir . "\\" . $subdir eq "src\\backend\\port\\darwin"; + + $self->AddDir($reldir . "\\" . $subdir); + } + } + while ($mf =~ m{^(?:EXTRA_)?OBJS[^=]*=\s*(.*)$}m) + { + my $s = $1; + my $filter_re = qr{\$\(filter ([^,]+),\s+\$\(([^\)]+)\)\)}; + while ($s =~ /$filter_re/) + { + + # Process $(filter a b c, $(VAR)) expressions + my $list = $1; + my $filter = $2; + $list =~ s/\.o/\.c/g; + my @pieces = split /\s+/, $list; + my $matches = ""; + foreach my $p (@pieces) + { + + if ($filter eq "LIBOBJS") + { + if (grep(/$p/, @main::pgportfiles) == 1) + { + $p =~ s/\.c/\.o/; + $matches .= $p . " "; + } + } + else + { + confess "Unknown filter $filter\n"; + } + } + $s =~ s/$filter_re/$matches/; + } + 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 + next unless $f =~ /.*\.o$/; + $f =~ s/\.o$/\.c/; + if ($f =~ /^\$\(top_builddir\)\/(.*)/) + { + $f = $1; + $f =~ s/\//\\/g; + $self->{files}->{$f} = 1; + } + else + { + $f =~ s/\//\\/g; + $self->{files}->{"$reldir\\$f"} = 1; + } + } + $mf =~ s{OBJS[^=]*=\s*(.*)$}{}m; + } + + # 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; + while ($mf =~ m{$replace_re}m) + { + my $match = $1; + my $top = $2; + my $target = $3; + $target =~ s{/}{\\}g; + my @pieces = split /\s+/,$match; + foreach my $fn (@pieces) + { + if ($top eq "(top_srcdir)") + { + eval { $self->ReplaceFile($fn, $target) }; + } + elsif ($top eq "(backend_src)") + { + eval { $self->ReplaceFile($fn, "src\\backend\\$target") }; + } + else + { + confess "Bad replacement top: $top, on line $_\n"; + } + } + $mf =~ s{$replace_re}{}m; + } + + # See if this Makefile contains a description, and should have a RC file + if ($mf =~ /^PGFILEDESC\s*=\s*\"([^\"]+)\"/m) + { + my $desc = $1; + my $ico; + if ($mf =~ /^PGAPPICON\s*=\s*(.*)$/m) { $ico = $1; } + $self->AddResourceFile($reldir,$desc,$ico); + } + $/ = $t; } sub AddResourceFile { - my ($self, $dir, $desc, $ico) = @_; - - 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')) - { - 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\"":""; - while (<I>) - { - s/FILEDESC/"$desc"/gm; - s/_ICO_/$icostr/gm; - s/(VERSION.*),0/$1,$d/; - if ($self->{type} eq "dll") - { - s/VFT_APP/VFT_DLL/gm; - } - print O; - } - } - close(O); - close(I); - $self->AddFile("$dir\\win32ver.rc"); + my ($self, $dir, $desc, $ico) = @_; + + 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')) + { + 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\"":""; + while (<I>) + { + s/FILEDESC/"$desc"/gm; + s/_ICO_/$icostr/gm; + s/(VERSION.*),0/$1,$d/; + if ($self->{type} eq "dll") + { + s/VFT_APP/VFT_DLL/gm; + } + print O; + } + } + close(O); + close(I); + $self->AddFile("$dir\\win32ver.rc"); } sub DisableLinkerWarnings { - my ($self, $warnings) = @_; + my ($self, $warnings) = @_; - $self->{disablelinkerwarnings} .= ',' unless ($self->{disablelinkerwarnings} eq ''); - $self->{disablelinkerwarnings} .= $warnings; + $self->{disablelinkerwarnings} .= ',' unless ($self->{disablelinkerwarnings} eq ''); + $self->{disablelinkerwarnings} .= $warnings; } 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 ($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 - $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"); - $self->WriteHeader(*F); - $self->WriteFiles(*F); - $self->Footer(*F); - close(F); + my ($self) = @_; + + # 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 + $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"); + $self->WriteHeader(*F); + $self->WriteFiles(*F); + $self->Footer(*F); + close(F); } sub GetAdditionalLinkerDependencies { - my ($self, $cfgname, $seperator) = @_; - my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd"; - my $libs = ''; - foreach my $lib (@{$self->{libraries}}) - { - my $xlib = $lib; - foreach my $slib (@{$self->{suffixlib}}) - { - if ($slib eq $lib) - { - $xlib =~ s/\.lib$/$libcfg.lib/; - last; - } - } - $libs .= $xlib . $seperator; - } - $libs =~ s/.$//; - $libs =~ s/__CFGNAME__/$cfgname/g; - return $libs; + my ($self, $cfgname, $seperator) = @_; + my $libcfg = (uc $cfgname eq "RELEASE")?"MD":"MDd"; + my $libs = ''; + foreach my $lib (@{$self->{libraries}}) + { + my $xlib = $lib; + foreach my $slib (@{$self->{suffixlib}}) + { + if ($slib eq $lib) + { + $xlib =~ s/\.lib$/$libcfg.lib/; + last; + } + } + $libs .= $xlib . $seperator; + } + $libs =~ s/.$//; + $libs =~ s/__CFGNAME__/$cfgname/g; + return $libs; } # Utility function that loads a complete file sub read_file { - my $filename = shift; - my $F; - my $t = $/; + my $filename = shift; + my $F; + my $t = $/; - undef $/; - open($F, $filename) || croak "Could not open file $filename\n"; - my $txt = <$F>; - close($F); - $/ = $t; + undef $/; + open($F, $filename) || croak "Could not open file $filename\n"; + my $txt = <$F>; + close($F); + $/ = $t; - return $txt; + return $txt; } 1; diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index e1d85c85ad0..0c50c057347 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -12,346 +12,359 @@ use VSObjectFactory; sub _new { - my $classname = shift; - my $options = shift; - my $self = { - projects => {}, - options => $options, - numver => '', - strver => '', - vcver => undef, - platform => undef, - }; - bless($self, $classname); - - # integer_datetimes is now the default - $options->{integer_datetimes} = 1 - unless exists $options->{integer_datetimes}; - $options->{float4byval} = 1 - unless exists $options->{float4byval}; - if ($options->{xml}) - { - if (!($options->{xslt} && $options->{iconv})) - { - die "XML requires both XSLT and ICONV\n"; - } - } - $options->{blocksize} = 8 - unless $options->{blocksize}; # undef or 0 means default - die "Bad blocksize $options->{blocksize}" - 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 - die "Bad segsize $options->{segsize}" - unless $options->{segsize} == 1; - $options->{wal_blocksize} = 8 - 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); - $options->{wal_segsize} = 16 - 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); - - $self->DeterminePlatform(); - - return $self; + my $classname = shift; + my $options = shift; + my $self = { + projects => {}, + options => $options, + numver => '', + strver => '', + vcver => undef, + platform => undef, + }; + bless($self, $classname); + + # integer_datetimes is now the default + $options->{integer_datetimes} = 1 + unless exists $options->{integer_datetimes}; + $options->{float4byval} = 1 + unless exists $options->{float4byval}; + if ($options->{xml}) + { + if (!($options->{xslt} && $options->{iconv})) + { + die "XML requires both XSLT and ICONV\n"; + } + } + $options->{blocksize} = 8 + unless $options->{blocksize}; # undef or 0 means default + die "Bad blocksize $options->{blocksize}" + 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 + die "Bad segsize $options->{segsize}" + unless $options->{segsize} == 1; + $options->{wal_blocksize} = 8 + 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); + $options->{wal_segsize} = 16 + 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); + + $self->DeterminePlatform(); + + return $self; } sub DeterminePlatform { - my $self = shift; - - # 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"; - while (<P>) - { - if (/^\/favor:</) - { - $self->{platform} = 'x64'; - last; - } - } - close(P); - print "Detected hardware platform: $self->{platform}\n"; + my $self = shift; + + # 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"; + while (<P>) + { + if (/^\/favor:</) + { + $self->{platform} = 'x64'; + last; + } + } + close(P); + print "Detected hardware platform: $self->{platform}\n"; } # Return 1 if $oldfile is newer than $newfile, or if $newfile doesn't exist. # Special case - if config.pl has changed, always return 1 sub IsNewer { - my ($newfile, $oldfile) = @_; - if ($oldfile ne 'src\tools\msvc\config.pl' && $oldfile ne 'src\tools\msvc\config_default.pl') - { - return 1 - if (-f 'src\tools\msvc\config.pl') && IsNewer($newfile, 'src\tools\msvc\config.pl'); - return 1 - if (-f 'src\tools\msvc\config_default.pl') - && IsNewer($newfile, 'src\tools\msvc\config_default.pl'); - } - return 1 if (!(-e $newfile)); - my @nstat = stat($newfile); - my @ostat = stat($oldfile); - return 1 if ($nstat[9] < $ostat[9]); - return 0; + my ($newfile, $oldfile) = @_; + if ( $oldfile ne 'src\tools\msvc\config.pl' + && $oldfile ne 'src\tools\msvc\config_default.pl') + { + return 1 + if (-f 'src\tools\msvc\config.pl') + && IsNewer($newfile, 'src\tools\msvc\config.pl'); + return 1 + if (-f 'src\tools\msvc\config_default.pl') + && IsNewer($newfile, 'src\tools\msvc\config_default.pl'); + } + return 1 if (!(-e $newfile)); + my @nstat = stat($newfile); + my @ostat = stat($oldfile); + return 1 if ($nstat[9] < $ostat[9]); + return 0; } # Copy a file, *not* preserving date. Only works for text files. sub copyFile { - my ($src, $dest) = @_; - open(I,$src) || croak "Could not open $src"; - open(O,">$dest") || croak "Could not open $dest"; - while (<I>) - { - print O; - } - close(I); - close(O); + my ($src, $dest) = @_; + open(I,$src) || croak "Could not open $src"; + open(O,">$dest") || croak "Could not open $dest"; + while (<I>) + { + print O; + } + close(I); + close(O); } sub GenerateFiles { - my $self = shift; - 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"); - while (<C>) - { - if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/) - { - $self->{strver} = $1; - if ($self->{strver} !~ /^(\d+)\.(\d+)(?:\.(\d+))?/) - { - confess "Bad format of version: $self->{strver}\n"; - } - $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3?$3:0); - $self->{majorver} = sprintf("%d.%d", $1, $2); - } - } - close(C); - 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")) - { - print "Copying pg_config_os.h...\n"; - 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")) - { - print "Generating pg_config.h...\n"; - 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"; - while (<I>) - { - s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}"}; - s{PG_VERSION_NUM \d+}{PG_VERSION_NUM $self->{numver}}; + my $self = shift; + 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"); + while (<C>) + { + if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/) + { + $self->{strver} = $1; + if ($self->{strver} !~ /^(\d+)\.(\d+)(?:\.(\d+))?/) + { + confess "Bad format of version: $self->{strver}\n"; + } + $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3?$3:0); + $self->{majorver} = sprintf("%d.%d", $1, $2); + } + } + close(C); + 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")) + { + print "Copying pg_config_os.h...\n"; + 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")) + { + print "Generating pg_config.h...\n"; + 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"; + while (<I>) + { + s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}"}; + s{PG_VERSION_NUM \d+}{PG_VERSION_NUM $self->{numver}}; s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL $self->{strver}, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", $bits-bit"}; - print O; - } - print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n"; - 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_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 ENABLE_NLS 1\n" if ($self->{options}->{nls}); - - 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 * 1024)\n"; - - if ($self->{options}->{float4byval}) - { - print O "#define USE_FLOAT4_BYVAL 1\n"; - print O "#define FLOAT4PASSBYVAL true\n"; - } - else - { - print O "#define FLOAT4PASSBYVAL false\n"; - } - if ($self->{options}->{float8byval}) - { - print O "#define USE_FLOAT8_BYVAL 1\n"; - print O "#define FLOAT8PASSBYVAL true\n"; - } - else - { - print O "#define FLOAT8PASSBYVAL false\n"; - } - - if ($self->{options}->{uuid}) - { - print O "#define HAVE_UUID_H\n"; - } - if ($self->{options}->{xml}) - { - print O "#define HAVE_LIBXML2\n"; - print O "#define USE_LIBXML\n"; - } - if ($self->{options}->{xslt}) - { - print O "#define HAVE_LIBXSLT\n"; - print O "#define USE_LIBXSLT\n"; - } - if ($self->{options}->{krb5}) - { - print O "#define KRB5 1\n"; - print O "#define HAVE_KRB5_ERROR_TEXT_DATA 1\n"; - print O "#define HAVE_KRB5_TICKET_ENC_PART2 1\n"; - print O "#define HAVE_KRB5_FREE_UNPARSED_NAME 1\n"; - print O "#define ENABLE_GSS 1\n"; - } - if (my $port = $self->{options}->{"--with-pgport"}) - { - print O "#undef DEF_PGPORT\n"; - print O "#undef DEF_PGPORT_STR\n"; - 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 "#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\\ecpg\\ecpglib\\ecpglib.def", - "src\\interfaces\\ecpg\\ecpglib\\exports.txt", - "LIBECPG" - ); - $self->GenerateDefFile( - "src\\interfaces\\ecpg\\compatlib\\compatlib.def", - "src\\interfaces\\ecpg\\compatlib\\exports.txt", - "LIBECPG_COMPAT" - ); - $self->GenerateDefFile( - "src\\interfaces\\ecpg\\pgtypeslib\\pgtypeslib.def", - "src\\interfaces\\ecpg\\pgtypeslib\\exports.txt", - "LIBPGTYPES" - ); - - 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"); - chdir('..\..\..'); - copyFile('src\backend\utils\fmgroids.h','src\include\utils\fmgroids.h'); - } - - if (IsNewer('src\include\utils\probes.h','src\backend\utils\probes.d')) - { - print "Generating probes.h...\n"; - system( + print O; + } + print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n"; + 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_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 ENABLE_NLS 1\n" if ($self->{options}->{nls}); + + 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 * 1024)\n"; + + if ($self->{options}->{float4byval}) + { + print O "#define USE_FLOAT4_BYVAL 1\n"; + print O "#define FLOAT4PASSBYVAL true\n"; + } + else + { + print O "#define FLOAT4PASSBYVAL false\n"; + } + if ($self->{options}->{float8byval}) + { + print O "#define USE_FLOAT8_BYVAL 1\n"; + print O "#define FLOAT8PASSBYVAL true\n"; + } + else + { + print O "#define FLOAT8PASSBYVAL false\n"; + } + + if ($self->{options}->{uuid}) + { + print O "#define HAVE_UUID_H\n"; + } + if ($self->{options}->{xml}) + { + print O "#define HAVE_LIBXML2\n"; + print O "#define USE_LIBXML\n"; + } + if ($self->{options}->{xslt}) + { + print O "#define HAVE_LIBXSLT\n"; + print O "#define USE_LIBXSLT\n"; + } + if ($self->{options}->{krb5}) + { + print O "#define KRB5 1\n"; + print O "#define HAVE_KRB5_ERROR_TEXT_DATA 1\n"; + print O "#define HAVE_KRB5_TICKET_ENC_PART2 1\n"; + print O "#define HAVE_KRB5_FREE_UNPARSED_NAME 1\n"; + print O "#define ENABLE_GSS 1\n"; + } + if (my $port = $self->{options}->{"--with-pgport"}) + { + print O "#undef DEF_PGPORT\n"; + print O "#undef DEF_PGPORT_STR\n"; + 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 "#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\\ecpg\\ecpglib\\ecpglib.def", + "src\\interfaces\\ecpg\\ecpglib\\exports.txt", + "LIBECPG" + ); + $self->GenerateDefFile( + "src\\interfaces\\ecpg\\compatlib\\compatlib.def", + "src\\interfaces\\ecpg\\compatlib\\exports.txt", + "LIBECPG_COMPAT" + ); + $self->GenerateDefFile( + "src\\interfaces\\ecpg\\pgtypeslib\\pgtypeslib.def", + "src\\interfaces\\ecpg\\pgtypeslib\\exports.txt", + "LIBPGTYPES" + ); + + 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"); + chdir('..\..\..'); + copyFile('src\backend\utils\fmgroids.h','src\include\utils\fmgroids.h'); + } + + if (IsNewer('src\include\utils\probes.h','src\backend\utils\probes.d')) + { + print "Generating probes.h...\n"; + system( 'psed -f src\backend\utils\Gen_dummy_probes.sed src\backend\utils\probes.d > src\include\utils\probes.h' - ); - } - - if ($self->{options}->{python} - && IsNewer('src\pl\plpython\spiexceptions.h','src\include\backend\errcodes.txt')) - { - print "Generating spiexceptions.h...\n"; - system( + ); + } + + if ($self->{options}->{python} + && IsNewer('src\pl\plpython\spiexceptions.h','src\include\backend\errcodes.txt')) + { + print "Generating spiexceptions.h...\n"; + system( 'perl src\pl\plpython\generate-spiexceptions.pl src\backend\utils\errcodes.txt > src\pl\plpython\spiexceptions.h' - ); - } + ); + } - if (IsNewer('src\include\utils\errcodes.h','src\backend\utils\errcodes.txt')) - { - print "Generating errcodes.h...\n"; - system( + 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'); - } - - if (IsNewer('src\pl\plpgsql\src\plerrcodes.h','src\backend\utils\errcodes.txt')) - { - print "Generating plerrcodes.h...\n"; - system( + ); + copyFile('src\backend\utils\errcodes.h','src\include\utils\errcodes.h'); + } + + if (IsNewer('src\pl\plpgsql\src\plerrcodes.h','src\backend\utils\errcodes.txt')) + { + print "Generating plerrcodes.h...\n"; + system( 'perl src\pl\plpgsql\src\generate-plerrcodes.pl src\backend\utils\errcodes.txt > src\pl\plpgsql\src\plerrcodes.h' - ); - } - - if (IsNewer('src\backend\utils\sort\qsort_tuple.c','src\backend\utils\sort\gen_qsort_tuple.pl')) - { - print "Generating qsort_tuple.c...\n"; - system( + ); + } + + if ( + IsNewer( + 'src\backend\utils\sort\qsort_tuple.c', + 'src\backend\utils\sort\gen_qsort_tuple.pl' + ) + ) + { + print "Generating qsort_tuple.c...\n"; + system( 'perl src\backend\utils\sort\gen_qsort_tuple.pl > src\backend\utils\sort\qsort_tuple.c' - ); - } - - 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 $d = ($year - 100) . "$yday"; - 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"; - while (<I>) - { - s/(VERSION.*),0/$1,$d/; - print O; - } - close(I); - close(O); - } - - if (IsNewer('src\bin\psql\sql_help.h','src\bin\psql\create_help.pl')) - { - print "Generating sql_help.h...\n"; - chdir('src\bin\psql'); - system("perl create_help.pl ../../../doc/src/sgml/ref sql_help"); - chdir('..\..\..'); - } - - if (IsNewer('src\interfaces\ecpg\preproc\preproc.y','src\backend\parser\gram.y')) - { - print "Generating preproc.y...\n"; - chdir('src\interfaces\ecpg\preproc'); - system('perl parse.pl < ..\..\..\backend\parser\gram.y > preproc.y'); - chdir('..\..\..\..'); - } - - if ( - IsNewer( - 'src\interfaces\ecpg\include\ecpg_config.h', - 'src\interfaces\ecpg\include\ecpg_config.h.in' - ) - ) - { - print "Generating ecpg_config.h...\n"; - open(O,'>','src\interfaces\ecpg\include\ecpg_config.h') - || confess "Could not open ecpg_config.h"; - print O <<EOF; + ); + } + + 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 $d = ($year - 100) . "$yday"; + 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"; + while (<I>) + { + s/(VERSION.*),0/$1,$d/; + print O; + } + close(I); + close(O); + } + + if (IsNewer('src\bin\psql\sql_help.h','src\bin\psql\create_help.pl')) + { + print "Generating sql_help.h...\n"; + chdir('src\bin\psql'); + system("perl create_help.pl ../../../doc/src/sgml/ref sql_help"); + chdir('..\..\..'); + } + + if (IsNewer('src\interfaces\ecpg\preproc\preproc.y','src\backend\parser\gram.y')) + { + print "Generating preproc.y...\n"; + chdir('src\interfaces\ecpg\preproc'); + system('perl parse.pl < ..\..\..\backend\parser\gram.y > preproc.y'); + chdir('..\..\..\..'); + } + + if ( + IsNewer( + 'src\interfaces\ecpg\include\ecpg_config.h', + 'src\interfaces\ecpg\include\ecpg_config.h.in' + ) + ) + { + print "Generating ecpg_config.h...\n"; + open(O,'>','src\interfaces\ecpg\include\ecpg_config.h') + || confess "Could not open ecpg_config.h"; + print O <<EOF; #if (_MSC_VER > 1200) #define HAVE_LONG_LONG_INT_64 #define ENABLE_THREAD_SAFETY 1 EOF - print O "#define USE_INTEGER_DATETIMES 1\n" if ($self->{options}->{integer_datetimes}); - print O "#endif\n"; - close(O); - } - - unless (-f "src\\port\\pg_config_paths.h") - { - print "Generating pg_config_paths.h...\n"; - open(O,'>', 'src\port\pg_config_paths.h') || confess "Could not open pg_config_paths.h"; - print O <<EOF; + print O "#define USE_INTEGER_DATETIMES 1\n" + if ($self->{options}->{integer_datetimes}); + print O "#endif\n"; + close(O); + } + + unless (-f "src\\port\\pg_config_paths.h") + { + print "Generating pg_config_paths.h...\n"; + open(O,'>', 'src\port\pg_config_paths.h') + || confess "Could not open pg_config_paths.h"; + print O <<EOF; #define PGBINDIR "/bin" #define PGSHAREDIR "/share" #define SYSCONFDIR "/etc" @@ -365,149 +378,150 @@ EOF #define HTMLDIR "/doc" #define MANDIR "/man" EOF - close(O); - } - - my $mf = Project::read_file('src\backend\catalog\Makefile'); - $mf =~ s{\\s*[\r\n]+}{}mg; - $mf =~ /^POSTGRES_BKI_SRCS\s*:?=[^,]+,(.*)\)$/gm - || croak "Could not find POSTGRES_BKI_SRCS in Makefile\n"; - my @allbki = split /\s+/, $1; - foreach my $bki (@allbki) - { - next if $bki eq ""; - if (IsNewer('src/backend/catalog/postgres.bki', "src/include/catalog/$bki")) - { - print "Generating postgres.bki and schemapg.h...\n"; - chdir('src\backend\catalog'); - my $bki_srcs = join(' ../../../src/include/catalog/', @allbki); - system( + close(O); + } + + my $mf = Project::read_file('src\backend\catalog\Makefile'); + $mf =~ s{\\s*[\r\n]+}{}mg; + $mf =~ /^POSTGRES_BKI_SRCS\s*:?=[^,]+,(.*)\)$/gm + || croak "Could not find POSTGRES_BKI_SRCS in Makefile\n"; + my @allbki = split /\s+/, $1; + foreach my $bki (@allbki) + { + next if $bki eq ""; + if (IsNewer('src/backend/catalog/postgres.bki', "src/include/catalog/$bki")) + { + print "Generating postgres.bki and schemapg.h...\n"; + chdir('src\backend\catalog'); + my $bki_srcs = join(' ../../../src/include/catalog/', @allbki); + system( "perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs" - ); - chdir('..\..\..'); - 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"; - print O <<EOF; + ); + chdir('..\..\..'); + 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"; + print O <<EOF; <!ENTITY version "$self->{strver}"> <!ENTITY majorversion "$self->{majorver}"> EOF - close(O); + close(O); } sub GenerateDefFile { - my ($self, $deffile, $txtfile, $libname) = @_; - - 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"); - print O "LIBRARY $libname\nEXPORTS\n"; - while (<I>) - { - next if (/^#/); - next if (/^\s*$/); - my ($f, $o) = split; - print O " $f @ $o\n"; - } - close(O); - close(I); - } + my ($self, $deffile, $txtfile, $libname) = @_; + + 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"); + print O "LIBRARY $libname\nEXPORTS\n"; + while (<I>) + { + next if (/^#/); + next if (/^\s*$/); + my ($f, $o) = split; + print O " $f @ $o\n"; + } + close(O); + close(I); + } } sub AddProject { - my ($self, $name, $type, $folder, $initialdir) = @_; - - my $proj = VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); - push @{$self->{projects}->{$folder}}, $proj; - $proj->AddDir($initialdir) if ($initialdir); - if ($self->{options}->{zlib}) - { - $proj->AddIncludeDir($self->{options}->{zlib} . '\include'); - $proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib'); - } - 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); - } - if ($self->{options}->{nls}) - { - $proj->AddIncludeDir($self->{options}->{nls} . '\include'); - $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib'); - } - if ($self->{options}->{krb5}) - { - $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'); - } - if ($self->{options}->{iconv}) - { - $proj->AddIncludeDir($self->{options}->{iconv} . '\include'); - $proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib'); - } - if ($self->{options}->{xml}) - { - $proj->AddIncludeDir($self->{options}->{xml} . '\include'); - $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib'); - } - if ($self->{options}->{xslt}) - { - $proj->AddIncludeDir($self->{options}->{xslt} . '\include'); - $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib'); - } - return $proj; + my ($self, $name, $type, $folder, $initialdir) = @_; + + my $proj = VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); + push @{$self->{projects}->{$folder}}, $proj; + $proj->AddDir($initialdir) if ($initialdir); + if ($self->{options}->{zlib}) + { + $proj->AddIncludeDir($self->{options}->{zlib} . '\include'); + $proj->AddLibrary($self->{options}->{zlib} . '\lib\zdll.lib'); + } + 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); + } + if ($self->{options}->{nls}) + { + $proj->AddIncludeDir($self->{options}->{nls} . '\include'); + $proj->AddLibrary($self->{options}->{nls} . '\lib\libintl.lib'); + } + if ($self->{options}->{krb5}) + { + $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'); + } + if ($self->{options}->{iconv}) + { + $proj->AddIncludeDir($self->{options}->{iconv} . '\include'); + $proj->AddLibrary($self->{options}->{iconv} . '\lib\iconv.lib'); + } + if ($self->{options}->{xml}) + { + $proj->AddIncludeDir($self->{options}->{xml} . '\include'); + $proj->AddLibrary($self->{options}->{xml} . '\lib\libxml2.lib'); + } + if ($self->{options}->{xslt}) + { + $proj->AddIncludeDir($self->{options}->{xslt} . '\include'); + $proj->AddLibrary($self->{options}->{xslt} . '\lib\libxslt.lib'); + } + return $proj; } sub Save { - my ($self) = @_; - my %flduid; - - $self->GenerateFiles(); - foreach my $fld (keys %{$self->{projects}}) - { - foreach my $proj (@{$self->{projects}->{$fld}}) - { - $proj->Save(); - } - } - - open(SLN,">pgsql.sln") || croak "Could not write to pgsql.sln\n"; - print SLN <<EOF; + my ($self) = @_; + my %flduid; + + $self->GenerateFiles(); + foreach my $fld (keys %{$self->{projects}}) + { + foreach my $proj (@{$self->{projects}->{$fld}}) + { + $proj->Save(); + } + } + + 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 $proj (@{$self->{projects}->{$fld}}) - { - print SLN <<EOF; + foreach my $fld (keys %{$self->{projects}}) + { + foreach my $proj (@{$self->{projects}->{$fld}}) + { + print SLN <<EOF; Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}" EndProject EOF - } - if ($fld ne "") - { - $flduid{$fld} = Win32::GuidGen(); - print SLN <<EOF; + } + if ($fld ne "") + { + $flduid{$fld} = Win32::GuidGen(); + print SLN <<EOF; Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "$fld", "$fld", "$flduid{$fld}" EndProject EOF - } - } + } + } - print SLN <<EOF; + print SLN <<EOF; Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|$self->{platform}= Debug|$self->{platform} @@ -516,20 +530,20 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution EOF - foreach my $fld (keys %{$self->{projects}}) - { - foreach my $proj (@{$self->{projects}->{$fld}}) - { - print SLN <<EOF; + foreach my $fld (keys %{$self->{projects}}) + { + foreach my $proj (@{$self->{projects}->{$fld}}) + { + print SLN <<EOF; $proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform} $proj->{guid}.Debug|$self->{platform}.Build.0 = Debug|$self->{platform} $proj->{guid}.Release|$self->{platform}.ActiveCfg = Release|$self->{platform} $proj->{guid}.Release|$self->{platform}.Build.0 = Release|$self->{platform} EOF - } - } + } + } - print SLN <<EOF; + print SLN <<EOF; EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -537,42 +551,42 @@ EOF GlobalSection(NestedProjects) = preSolution EOF - foreach my $fld (keys %{$self->{projects}}) - { - next if ($fld eq ""); - foreach my $proj (@{$self->{projects}->{$fld}}) - { - print SLN "\t\t$proj->{guid} = $flduid{$fld}\n"; - } - } + foreach my $fld (keys %{$self->{projects}}) + { + next if ($fld eq ""); + foreach my $proj (@{$self->{projects}->{$fld}}) + { + print SLN "\t\t$proj->{guid} = $flduid{$fld}\n"; + } + } - print SLN <<EOF; + print SLN <<EOF; EndGlobalSection EndGlobal EOF - close(SLN); + close(SLN); } sub GetFakeConfigure { - my $self = shift; - - my $cfg = '--enable-thread-safety'; - $cfg .= ' --enable-cassert' if ($self->{options}->{asserts}); - $cfg .= ' --enable-integer-datetimes' if ($self->{options}->{integer_datetimes}); - $cfg .= ' --enable-nls' if ($self->{options}->{nls}); - $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); - $cfg .= ' --without-zlib' unless ($self->{options}->{zlib}); - $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}); - - return $cfg; + my $self = shift; + + my $cfg = '--enable-thread-safety'; + $cfg .= ' --enable-cassert' if ($self->{options}->{asserts}); + $cfg .= ' --enable-integer-datetimes' if ($self->{options}->{integer_datetimes}); + $cfg .= ' --enable-nls' if ($self->{options}->{nls}); + $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); + $cfg .= ' --without-zlib' unless ($self->{options}->{zlib}); + $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}); + + return $cfg; } package VS2005Solution; @@ -587,15 +601,15 @@ use base qw(Solution); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{solutionFileVersion} = '9.00'; - $self->{vcver} = '8.00'; - $self->{visualStudioName} = 'Visual Studio 2005'; + $self->{solutionFileVersion} = '9.00'; + $self->{vcver} = '8.00'; + $self->{visualStudioName} = 'Visual Studio 2005'; - return $self; + return $self; } package VS2008Solution; @@ -610,15 +624,15 @@ use base qw(Solution); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{solutionFileVersion} = '10.00'; - $self->{vcver} = '9.00'; - $self->{visualStudioName} = 'Visual Studio 2008'; + $self->{solutionFileVersion} = '10.00'; + $self->{vcver} = '9.00'; + $self->{visualStudioName} = 'Visual Studio 2008'; - return $self; + return $self; } package VS2010Solution; @@ -634,15 +648,15 @@ use base qw(Solution); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{solutionFileVersion} = '11.00'; - $self->{vcver} = '10.00'; - $self->{visualStudioName} = 'Visual Studio 2010'; + $self->{solutionFileVersion} = '11.00'; + $self->{vcver} = '10.00'; + $self->{visualStudioName} = 'Visual Studio 2010'; - return $self; + return $self; } 1; diff --git a/src/tools/msvc/VCBuildProject.pm b/src/tools/msvc/VCBuildProject.pm index 97439d9d5c4..a7fd0c0d9d5 100644 --- a/src/tools/msvc/VCBuildProject.pm +++ b/src/tools/msvc/VCBuildProject.pm @@ -13,124 +13,124 @@ use base qw(Project); sub _new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{filenameExtension} = '.vcproj'; + $self->{filenameExtension} = '.vcproj'; - return $self; + return $self; } sub WriteHeader { - my ($self, $f) = @_; + my ($self, $f) = @_; - print $f <<EOF; + print $f <<EOF; <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" Version="$self->{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}"> <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 }); - print $f <<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}); + print $f <<EOF; </Configurations> EOF - $self->WriteReferences($f); + $self->WriteReferences($f); } sub WriteFiles { - my ($self, $f) = @_; - print $f <<EOF; + my ($self, $f) = @_; + print $f <<EOF; <Files> EOF - my @dirstack = (); - my %uniquefiles; - foreach my $fileNameWithPath (sort keys %{ $self->{files} }) - { - confess "Bad format filename '$fileNameWithPath'\n" - unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); - my $dir = $1; - my $file = $2; - - # 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)))) - { - 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) - { - 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 . " <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}; - print $f '>' - . $self->GenerateCustomTool('Running bison on ' . $fileNameWithPath, - "perl src\\tools\\msvc\\pgbison.pl $fileNameWithPath", $of) - . '</File>' . "\n"; - } - elsif ($fileNameWithPath =~ /\.l$/) - { - my $of = $fileNameWithPath; - $of =~ s/\.l$/.c/; - print $f '>' - . $self->GenerateCustomTool('Running flex on ' . $fileNameWithPath, - "perl src\\tools\\msvc\\pgflex.pl $fileNameWithPath", $of) - . '</File>' . "\n"; - } - elsif (defined($uniquefiles{$file})) - { - - # File already exists, so fake a new name - my $obj = $dir; - $obj =~ s/\\/_/g; - print $f + my @dirstack = (); + my %uniquefiles; + foreach my $fileNameWithPath (sort keys %{$self->{files}}) + { + confess "Bad format filename '$fileNameWithPath'\n" + unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); + my $dir = $1; + my $file = $2; + + # 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)))) + { + 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) + { + 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 . " <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}; + print $f '>' + . $self->GenerateCustomTool('Running bison on ' . $fileNameWithPath, + "perl src\\tools\\msvc\\pgbison.pl $fileNameWithPath", $of) + . '</File>' . "\n"; + } + elsif ($fileNameWithPath =~ /\.l$/) + { + my $of = $fileNameWithPath; + $of =~ s/\.l$/.c/; + print $f '>' + . $self->GenerateCustomTool('Running flex on ' . $fileNameWithPath, + "perl src\\tools\\msvc\\pgflex.pl $fileNameWithPath", $of) + . '</File>' . "\n"; + } + elsif (defined($uniquefiles{$file})) + { + + # File already exists, so fake a new name + my $obj = $dir; + $obj =~ s/\\/_/g; + print $f "><FileConfiguration Name=\"Debug|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj" - . "_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj" - . "_$file.obj\" /></FileConfiguration></File>\n"; - } - else - { - $uniquefiles{$file} = 1; - print $f " />\n"; - } - } - while ($#dirstack >= 0) - { - print $f ' ' x $#dirstack . " </Filter>\n"; - pop @dirstack; - } - print $f <<EOF; + . "_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj" + . "_$file.obj\" /></FileConfiguration></File>\n"; + } + else + { + $uniquefiles{$file} = 1; + print $f " />\n"; + } + } + while ($#dirstack >= 0) + { + print $f ' ' x $#dirstack . " </Filter>\n"; + pop @dirstack; + } + print $f <<EOF; </Files> EOF } sub Footer { - my ($self, $f) = @_; + my ($self, $f) = @_; - print $f <<EOF; + print $f <<EOF; <Globals/> </VisualStudioProject> EOF @@ -138,13 +138,13 @@ EOF sub WriteConfiguration { - my ($self, $f, $cfgname, $p) = @_; - my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4); - my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ' '); + my ($self, $f, $cfgname, $p) = @_; + 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; + my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17; - print $f <<EOF; + print $f <<EOF; <Configuration Name="$cfgname|$self->{platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}" ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}"> <Tool Name="VCCLCompilerTool" Optimization="$p->{opt}" @@ -154,7 +154,7 @@ sub WriteConfiguration RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}" AdditionalOptions="/MP" EOF - print $f <<EOF; + print $f <<EOF; AssemblerOutput="0" AssemblerListingLocation=".\\$cfgname\\$self->{name}\\" ObjectFile=".\\$cfgname\\$self->{name}\\" ProgramDataBaseFileName=".\\$cfgname\\$self->{name}\\" BrowseInformation="0" WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> @@ -166,59 +166,59 @@ EOF GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map" SubSystem="1" TargetMachine="$targetmachine" EOF - if ($self->{disablelinkerwarnings}) - { - print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n"; - } - if ($self->{implib}) - { - my $l = $self->{implib}; - $l =~ s/__CFGNAME__/$cfgname/g; - print $f "\t\tImportLibrary=\"$l\"\n"; - } - if ($self->{def}) - { - my $d = $self->{def}; - $d =~ s/__CFGNAME__/$cfgname/g; - print $f "\t\tModuleDefinitionFile=\"$d\"\n"; - } - - print $f "\t/>\n"; - print $f + if ($self->{disablelinkerwarnings}) + { + print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n"; + } + if ($self->{implib}) + { + my $l = $self->{implib}; + $l =~ s/__CFGNAME__/$cfgname/g; + print $f "\t\tImportLibrary=\"$l\"\n"; + } + if ($self->{def}) + { + my $d = $self->{def}; + $d =~ s/__CFGNAME__/$cfgname/g; + print $f "\t\tModuleDefinitionFile=\"$d\"\n"; + } + + print $f "\t/>\n"; + print $f "\t<Tool Name=\"VCLibrarianTool\" OutputFile=\".\\$cfgname\\$self->{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n"; - print $f - "\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n"; - if ($self->{builddef}) - { - print $f + print $f +"\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n"; + if ($self->{builddef}) + { + print $f "\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}\" />\n"; - } - print $f <<EOF; + } + print $f <<EOF; </Configuration> EOF } sub WriteReferences { - my ($self, $f) = @_; - print $f " <References>\n"; - foreach my $ref (@{$self->{references}}) - { - print $f + my ($self, $f) = @_; + print $f " <References>\n"; + foreach my $ref (@{$self->{references}}) + { + print $f " <ProjectReference ReferencedProjectIdentifier=\"$ref->{guid}\" Name=\"$ref->{name}\" />\n"; - } - print $f " </References>\n"; + } + print $f " </References>\n"; } sub GenerateCustomTool { - my ($self, $desc, $tool, $output, $cfg) = @_; - if (!defined($cfg)) - { - return $self->GenerateCustomTool($desc, $tool, $output, 'Debug') - .$self->GenerateCustomTool($desc, $tool, $output, 'Release'); - } - return + my ($self, $desc, $tool, $output, $cfg) = @_; + if (!defined($cfg)) + { + return $self->GenerateCustomTool($desc, $tool, $output, 'Debug') + .$self->GenerateCustomTool($desc, $tool, $output, 'Release'); + } + return "<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>"; } @@ -234,13 +234,13 @@ use base qw(VCBuildProject); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{vcver} = '8.00'; + $self->{vcver} = '8.00'; - return $self; + return $self; } package VC2008Project; @@ -255,13 +255,13 @@ use base qw(VCBuildProject); sub new { - my $classname = shift; - my $self = $classname->SUPER::_new(@_); - bless($self, $classname); + my $classname = shift; + my $self = $classname->SUPER::_new(@_); + bless($self, $classname); - $self->{vcver} = '9.00'; + $self->{vcver} = '9.00'; - return $self; + return $self; } 1; diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm index 3bed9229918..e222b04c681 100644 --- a/src/tools/msvc/VSObjectFactory.pm +++ b/src/tools/msvc/VSObjectFactory.pm @@ -22,101 +22,103 @@ our (@ISA, @EXPORT); sub CreateSolution { - my $visualStudioVersion = shift; + my $visualStudioVersion = shift; - if (!defined($visualStudioVersion)) - { - $visualStudioVersion = DetermineVisualStudioVersion(); - } + if (!defined($visualStudioVersion)) + { + $visualStudioVersion = DetermineVisualStudioVersion(); + } - if ($visualStudioVersion eq '8.00') - { - return new VS2005Solution(@_); - } - elsif ($visualStudioVersion eq '9.00') - { - return new VS2008Solution(@_); - } - elsif ($visualStudioVersion eq '10.00') - { - return new VS2010Solution(@_); - } - else - { - croak "The requested Visual Studio version is not supported."; - } + if ($visualStudioVersion eq '8.00') + { + return new VS2005Solution(@_); + } + elsif ($visualStudioVersion eq '9.00') + { + return new VS2008Solution(@_); + } + elsif ($visualStudioVersion eq '10.00') + { + return new VS2010Solution(@_); + } + else + { + croak "The requested Visual Studio version is not supported."; + } } sub CreateProject { - my $visualStudioVersion = shift; + my $visualStudioVersion = shift; - if (!defined($visualStudioVersion)) - { - $visualStudioVersion = DetermineVisualStudioVersion(); - } + if (!defined($visualStudioVersion)) + { + $visualStudioVersion = DetermineVisualStudioVersion(); + } - if ($visualStudioVersion eq '8.00') - { - return new VC2005Project(@_); - } - elsif ($visualStudioVersion eq '9.00') - { - return new VC2008Project(@_); - } - elsif ($visualStudioVersion eq '10.00') - { - return new VC2010Project(@_); - } - else - { - croak "The requested Visual Studio version is not supported."; - } + if ($visualStudioVersion eq '8.00') + { + return new VC2005Project(@_); + } + elsif ($visualStudioVersion eq '9.00') + { + return new VC2008Project(@_); + } + elsif ($visualStudioVersion eq '10.00') + { + return new VC2010Project(@_); + } + else + { + croak "The requested Visual Studio version is not supported."; + } } sub DetermineVisualStudioVersion { - my $nmakeVersion = shift; + my $nmakeVersion = shift; - if (!defined($nmakeVersion)) - { + 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 |") - || croak "Unable to determine Visual Studio version: The nmake command wasn't found."; - while(<P>) - { - chomp; - if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/) - { - return _GetVisualStudioVersion($1, $2); - } - } - close(P); - } - elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/) - { - return _GetVisualStudioVersion($1, $2); - } - croak "Unable to determine Visual Studio version: The nmake version could not be determined."; + # 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>) + { + chomp; + if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/) + { + return _GetVisualStudioVersion($1, $2); + } + } + close(P); + } + elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/) + { + return _GetVisualStudioVersion($1, $2); + } + croak + "Unable to determine Visual Studio version: The nmake version could not be determined."; } sub _GetVisualStudioVersion { - my($major, $minor) = @_; - if ($major > 10) - { - carp + my($major, $minor) = @_; + if ($major > 10) + { + carp "The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead."; - return '10.00'; - } - elsif ($major < 6) - { - croak + return '10.00'; + } + elsif ($major < 6) + { + croak "Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported."; - } - return "$major.$minor"; + } + return "$major.$minor"; } 1; diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl index 151849bba51..4fa309738b4 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"); } @@ -19,13 +19,13 @@ use Mkvcbuild; # it should contain lines like: # $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}"; -if ( -e "src/tools/msvc/buildenv.pl") +if (-e "src/tools/msvc/buildenv.pl") { - require "src/tools/msvc/buildenv.pl"; + require "src/tools/msvc/buildenv.pl"; } -elsif (-e "./buildenv.pl" ) +elsif (-e "./buildenv.pl") { - require "./buildenv.pl"; + require "./buildenv.pl"; } # set up the project @@ -41,26 +41,26 @@ my $bconf = $ENV{CONFIG} || "Release"; my $buildwhat = $ARGV[1] || ""; if ($ARGV[0] eq 'DEBUG') { - $bconf = "Debug"; + $bconf = "Debug"; } elsif ($ARGV[0] ne "RELEASE") { - $buildwhat = $ARGV[0] || ""; + $buildwhat = $ARGV[0] || ""; } # ... and do it 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) { - system("vcbuild $buildwhat.vcproj $bconf"); + system("vcbuild $buildwhat.vcproj $bconf"); } else { - system("msbuild pgsql.sln /verbosity:detailed /p:Configuration=$bconf"); + system("msbuild pgsql.sln /verbosity:detailed /p:Configuration=$bconf"); } # report status diff --git a/src/tools/msvc/builddoc.pl b/src/tools/msvc/builddoc.pl index 8d8d8a35ccf..b567f542a74 100644 --- a/src/tools/msvc/builddoc.pl +++ b/src/tools/msvc/builddoc.pl @@ -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; @@ -94,28 +94,28 @@ exit; sub renamefiles { - # Rename ISO entity files - my $savedir = getcwd(); - chdir "$docroot/docbook"; - foreach my $f (glob('ISO*')) - { - next if $f =~ /\.gml$/i; - my $nf = $f; - $nf =~ s/ISO(.*)/ISO-$1.gml/; - move $f, $nf; - } - chdir $savedir; + # Rename ISO entity files + my $savedir = getcwd(); + chdir "$docroot/docbook"; + foreach my $f (glob('ISO*')) + { + next if $f =~ /\.gml$/i; + my $nf = $f; + $nf =~ s/ISO(.*)/ISO-$1.gml/; + move $f, $nf; + } + chdir $savedir; } sub missing { - print STDERR "could not find $docroot/$_\n" foreach (@notfound); - exit 1; + print STDERR "could not find $docroot/$_\n" foreach (@notfound); + exit 1; } sub noversion { - print STDERR "Could not find version.sgml. ","Please run mkvcbuild.pl first!\n"; - exit 1; + 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 971d740a9e5..95e9cd93dab 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 b8538dd79b8..2fc8c4a2903 100644 --- a/src/tools/msvc/gendef.pl +++ b/src/tools/msvc/gendef.pl @@ -13,40 +13,40 @@ my $platform = $ARGV[1]; if (-f "$ARGV[0]/$defname.def") { - print "Not re-generating $defname.DEF, file already exists.\n"; - exit(0); + print "Not re-generating $defname.DEF, file already exists.\n"; + exit(0); } print "Generating $defname.DEF from directory $ARGV[0], platform $platform\n"; while (<$ARGV[0]/*.obj>) { - my $symfile = $_; - $symfile=~ s/\.obj$/.sym/i; - print "."; - 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>) - { - s/\(\)//g; - my @pieces = split; - next unless $pieces[0] =~ /^[A-F0-9]{3,}$/; - next unless $pieces[6]; - next if ($pieces[2] eq "UNDEF"); - next unless ($pieces[4] eq "External"); - next if $pieces[6] =~ /^@/; - next if $pieces[6] =~ /^\(/; - next if $pieces[6] =~ /^__real/; - next if $pieces[6] =~ /^__imp/; - next if $pieces[6] =~ /NULL_THUNK_DATA$/; - next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/; - next if $pieces[6] =~ /^__NULL_IMPORT/; - next if $pieces[6] =~ /^\?\?_C/; + my $symfile = $_; + $symfile=~ s/\.obj$/.sym/i; + print "."; + 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>) + { + s/\(\)//g; + my @pieces = split; + next unless $pieces[0] =~ /^[A-F0-9]{3,}$/; + next unless $pieces[6]; + next if ($pieces[2] eq "UNDEF"); + next unless ($pieces[4] eq "External"); + next if $pieces[6] =~ /^@/; + next if $pieces[6] =~ /^\(/; + next if $pieces[6] =~ /^__real/; + next if $pieces[6] =~ /^__imp/; + next if $pieces[6] =~ /NULL_THUNK_DATA$/; + next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/; + next if $pieces[6] =~ /^__NULL_IMPORT/; + next if $pieces[6] =~ /^\?\?_C/; - push @def, $pieces[6]; - } - close(F); - rename("symbols.out",$symfile); + push @def, $pieces[6]; + } + close(F); + rename("symbols.out",$symfile); } print "\n"; @@ -56,13 +56,13 @@ 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 - $i++; + next if ($f eq $last); + $last = $f; + $f =~ s/^_// unless ($platform eq "x64"); # win64 has new format of exports + $i++; - # print DEF " $f \@ $i\n"; # ordinaled exports? - print DEF " $f\n"; + # print DEF " $f \@ $i\n"; # ordinaled exports? + print DEF " $f\n"; } close(DEF); print "Generated $i symbols\n"; diff --git a/src/tools/msvc/install.pl b/src/tools/msvc/install.pl index 28563a930d5..f27a7b3f162 100755 --- a/src/tools/msvc/install.pl +++ b/src/tools/msvc/install.pl @@ -13,6 +13,6 @@ Install($target); sub Usage { - print "Usage: install.pl <targetdir>\n"; - exit(1); + print "Usage: install.pl <targetdir>\n"; + exit(1); } diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl index c48863aff60..f0c9e26007a 100644 --- a/src/tools/msvc/pgbison.pl +++ b/src/tools/msvc/pgbison.pl @@ -14,21 +14,21 @@ $bisonver=(split(/\s+/,$bisonver))[3]; # grab version number unless ($bisonver eq '1.875' || $bisonver ge '2.2') { - print "WARNING! Bison install not found, or unsupported Bison version.\n"; - print "echo Attempting to build without.\n"; - exit 0; + print "WARNING! Bison install not found, or unsupported Bison version.\n"; + print "echo Attempting to build without.\n"; + exit 0; } my $input = shift; if ($input !~ /\.y$/) { - print "Input must be a .y file\n"; - exit 1; + print "Input must be a .y file\n"; + exit 1; } elsif (!-e $input) { - print "Input file $input not found\n"; - exit 1; + print "Input file $input not found\n"; + exit 1; } (my $output = $input) =~ s/\.y$/.c/; diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl index 7b9021d2ba2..551b8f67ae8 100644 --- a/src/tools/msvc/pgflex.pl +++ b/src/tools/msvc/pgflex.pl @@ -13,26 +13,26 @@ 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]; -$flexver =~ s/[^0-9.]//g; +$flexver=(split(/\s+/,$flexver))[1]; +$flexver =~ s/[^0-9.]//g; 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"; - print "echo Attempting to build without.\n"; - exit 0; + print "WARNING! Flex install not found, or unsupported Flex version.\n"; + print "echo Attempting to build without.\n"; + exit 0; } my $input = shift; if ($input !~ /\.l$/) { - print "Input must be a .l file\n"; - exit 1; + print "Input must be a .l file\n"; + exit 1; } elsif (!-e $input) { - print "Input file $input not found\n"; - exit 1; + print "Input file $input not found\n"; + exit 1; } (my $output = $input) =~ s/\.l$/.c/; @@ -50,25 +50,25 @@ system("flex $flexflags -o$output $input"); if ($? == 0) { - # For non-reentrant scanners we need to fix up the yywrap macro definition - # to keep the MS compiler happy. - # 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: $!"; - my $lcode = <$lfile>; - close($lfile); - if ($lcode !~ /\%option\sreentrant/) - { - my $cfile; - 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: $!"; - print $cfile $ccode; - close($cfile); - } + # For non-reentrant scanners we need to fix up the yywrap macro definition + # to keep the MS compiler happy. + # 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: $!"; + my $lcode = <$lfile>; + close($lfile); + if ($lcode !~ /\%option\sreentrant/) + { + my $cfile; + 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: $!"; + print $cfile $ccode; + close($cfile); + } if ($flexflags =~ /\s-b\s/) { my $lexback = "lex.backup"; @@ -84,11 +84,11 @@ if ($? == 0) unlink $lexback; } - exit 0; + exit 0; } else { - exit $? >> 8; + exit $? >> 8; } diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index f81611bc3d6..ef7035068b4 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -20,19 +20,19 @@ require 'src/tools/msvc/config.pl' if (-f 'src/tools/msvc/config.pl'); # it should contian lines like: # $ENV{PATH} = "c:/path/to/bison/bin;$ENV{PATH}"; -if ( -e "src/tools/msvc/buildenv.pl") +if (-e "src/tools/msvc/buildenv.pl") { - require "src/tools/msvc/buildenv.pl"; + require "src/tools/msvc/buildenv.pl"; } my $what = shift || ""; if ($what =~ /^(check|installcheck|plcheck|contribcheck|ecpgcheck|isolationcheck)$/i) { - $what = uc $what; + $what = uc $what; } else { - usage(); + usage(); } # use a capital C here because config.pl has $config @@ -48,8 +48,8 @@ $ENV{PATH} = "../../../$Config/libpq;../../$Config/libpq;$ENV{PATH}"; my $schedule = shift; unless ($schedule) { - $schedule = "serial"; - $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/); + $schedule = "serial"; + $schedule = "parallel" if ($what eq 'CHECK' || $what =~ /PARALLEL/); } my $topdir = getcwd(); @@ -67,12 +67,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}; @@ -87,229 +87,229 @@ 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; - system(@args); - my $status = $? >>8; - exit $status if $status; + my @args = ( + "../../../$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; + 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; - system(@args); - my $status = $? >>8; - exit $status if $status; + 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; + system(@args); + my $status = $? >>8; + exit $status if $status; } sub ecpgcheck { - chdir $startdir; - system("msbuild ecpg_regression.proj /p:config=$Config"); - my $status = $? >>8; - exit $status if $status; - chdir "$topdir/src/interfaces/ecpg/test"; - $schedule="ecpg"; - my @args = ( - "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg", - "--psqldir=../../../$Config/psql", - "--dbname=regress1,connectdb", - "--create-role=connectuser,connectdb", - "--schedule=${schedule}_schedule", - "--encoding=SQL_ASCII", - "--no-locale", - "--temp-install=./tmp_chk", - "--top-builddir=\"$topdir\"" - ); - push(@args,$maxconn) if $maxconn; - system(@args); - $status = $? >>8; - exit $status if $status; + chdir $startdir; + system("msbuild ecpg_regression.proj /p:config=$Config"); + my $status = $? >>8; + exit $status if $status; + chdir "$topdir/src/interfaces/ecpg/test"; + $schedule="ecpg"; + my @args = ( + "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg", + "--psqldir=../../../$Config/psql", + "--dbname=regress1,connectdb", + "--create-role=connectuser,connectdb", + "--schedule=${schedule}_schedule", + "--encoding=SQL_ASCII", + "--no-locale", + "--temp-install=./tmp_chk", + "--top-builddir=\"$topdir\"" + ); + push(@args,$maxconn) if $maxconn; + system(@args); + $status = $? >>8; + exit $status if $status; } sub isolationcheck { - chdir "../isolation"; - 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; - system(@args); - my $status = $? >>8; - exit $status if $status; + chdir "../isolation"; + 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; + system(@args); + my $status = $? >>8; + exit $status if $status; } sub plcheck { - chdir "../../pl"; - - foreach my $pl (glob("*")) - { - next unless -d "$pl/sql" && -d "$pl/expected"; - my $lang = $pl eq 'tcl' ? 'pltcl' : $pl; - next unless -d "../../$Config/$lang"; - $lang = 'plpythonu' if $lang eq 'plpython'; - my @lang_args = ("--load-extension=$lang"); - chdir $pl; - my @tests = fetchTests(); - if ($lang eq 'plperl') - { - - # run both trusted and untrusted perl tests - push(@lang_args, "--load-extension=plperlu"); - - # assume we're using this perl to built postgres - # test if we can run two interpreters in one backend, and if so - # run the trusted/untrusted interaction tests - use Config; - if ($Config{usemultiplicity} eq 'define') - { - push(@tests,'plperl_plperlu'); - } - } - print "============================================================\n"; - print "Checking $lang\n"; - my @args = ( - "../../../$Config/pg_regress/pg_regress", - "--psqldir=../../../$Config/psql", - "--dbname=pl_regression",@lang_args,@tests - ); - system(@args); - my $status = $? >> 8; - exit $status if $status; - chdir ".."; - } - - chdir "../../.."; + chdir "../../pl"; + + foreach my $pl (glob("*")) + { + next unless -d "$pl/sql" && -d "$pl/expected"; + my $lang = $pl eq 'tcl' ? 'pltcl' : $pl; + next unless -d "../../$Config/$lang"; + $lang = 'plpythonu' if $lang eq 'plpython'; + my @lang_args = ("--load-extension=$lang"); + chdir $pl; + my @tests = fetchTests(); + if ($lang eq 'plperl') + { + + # run both trusted and untrusted perl tests + push(@lang_args, "--load-extension=plperlu"); + + # assume we're using this perl to built postgres + # test if we can run two interpreters in one backend, and if so + # run the trusted/untrusted interaction tests + use Config; + if ($Config{usemultiplicity} eq 'define') + { + push(@tests,'plperl_plperlu'); + } + } + print "============================================================\n"; + print "Checking $lang\n"; + my @args = ( + "../../../$Config/pg_regress/pg_regress", + "--psqldir=../../../$Config/psql", + "--dbname=pl_regression",@lang_args,@tests + ); + system(@args); + my $status = $? >> 8; + exit $status if $status; + chdir ".."; + } + + chdir "../../.."; } sub contribcheck { - chdir "../../../contrib"; - my $mstat = 0; - foreach my $module (glob("*")) - { - next if ($module eq 'sepgsql'); - next if ($module eq 'xml2' && !$config->{xml}); - next - unless -d "$module/sql" - &&-d "$module/expected" - &&(-f "$module/GNUmakefile" || -f "$module/Makefile"); - chdir $module; - print "============================================================\n"; - print "Checking $module\n"; - my @tests = fetchTests(); - my @opts = fetchRegressOpts(); - my @args = ( - "../../$Config/pg_regress/pg_regress", - "--psqldir=../../$Config/psql", - "--dbname=contrib_regression",@opts,@tests - ); - system(@args); - my $status = $? >> 8; - $mstat ||= $status; - chdir ".."; - } - exit $mstat if $mstat; + chdir "../../../contrib"; + my $mstat = 0; + foreach my $module (glob("*")) + { + next if ($module eq 'sepgsql'); + next if ($module eq 'xml2' && !$config->{xml}); + next + unless -d "$module/sql" + &&-d "$module/expected" + &&(-f "$module/GNUmakefile" || -f "$module/Makefile"); + chdir $module; + print "============================================================\n"; + print "Checking $module\n"; + my @tests = fetchTests(); + my @opts = fetchRegressOpts(); + my @args = ( + "../../$Config/pg_regress/pg_regress", + "--psqldir=../../$Config/psql", + "--dbname=contrib_regression",@opts,@tests + ); + system(@args); + my $status = $? >> 8; + $mstat ||= $status; + chdir ".."; + } + exit $mstat if $mstat; } sub fetchRegressOpts { - my $handle; - open($handle,"<GNUmakefile") - || open($handle,"<Makefile") - || die "Could not open Makefile"; - local($/) = undef; - my $m = <$handle>; - close($handle); - my @opts; - if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m) - { - - # ignore options that use makefile variables - can't handle those - # ignore anything that isn't an option staring with -- - @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/,$1); - } - if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) - { - push @opts, "--encoding=$1"; - } - if ($m =~ /^\s*NO_LOCALE\s*=\s*\S+/m) - { - push @opts, "--no-locale"; - } - return @opts; + my $handle; + open($handle,"<GNUmakefile") + || open($handle,"<Makefile") + || die "Could not open Makefile"; + local($/) = undef; + my $m = <$handle>; + close($handle); + my @opts; + if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m) + { + + # ignore options that use makefile variables - can't handle those + # ignore anything that isn't an option staring with -- + @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/,$1); + } + if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) + { + push @opts, "--encoding=$1"; + } + if ($m =~ /^\s*NO_LOCALE\s*=\s*\S+/m) + { + push @opts, "--no-locale"; + } + return @opts; } sub fetchTests { - my $handle; - open($handle,"<GNUmakefile") - || open($handle,"<Makefile") - || die "Could not open Makefile"; - local($/) = undef; - my $m = <$handle>; - close($handle); - my $t = ""; - - $m =~ s/\\[\r\n]*//gs; - if ($m =~ /^REGRESS\s*=\s*(.*)$/gm) - { - $t = $1; - $t =~ s/\s+/ /g; - - if ($m =~ /contrib\/pgcrypto/) - { - - # pgcrypto is special since the tests depend on the - # configuration of the build - - my $cftests = - $config->{openssl} - ?GetTests("OSSL_TESTS",$m) - : GetTests("INT_TESTS",$m); - my $pgptests = - $config->{zlib} - ?GetTests("ZLIB_TST",$m) - : GetTests("ZLIB_OFF_TST",$m); - $t =~ s/\$\(CF_TESTS\)/$cftests/; - $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/; - } - } - - return split(/\s+/,$t); + my $handle; + open($handle,"<GNUmakefile") + || open($handle,"<Makefile") + || die "Could not open Makefile"; + local($/) = undef; + my $m = <$handle>; + close($handle); + my $t = ""; + + $m =~ s/\\[\r\n]*//gs; + if ($m =~ /^REGRESS\s*=\s*(.*)$/gm) + { + $t = $1; + $t =~ s/\s+/ /g; + + if ($m =~ /contrib\/pgcrypto/) + { + + # pgcrypto is special since the tests depend on the + # configuration of the build + + my $cftests = + $config->{openssl} + ?GetTests("OSSL_TESTS",$m) + : GetTests("INT_TESTS",$m); + my $pgptests = + $config->{zlib} + ?GetTests("ZLIB_TST",$m) + : GetTests("ZLIB_OFF_TST",$m); + $t =~ s/\$\(CF_TESTS\)/$cftests/; + $t =~ s/\$\(CF_PGP_TESTS\)/$pgptests/; + } + } + + return split(/\s+/,$t); } sub GetTests { - my $testname = shift; - my $m = shift; - if ($m =~ /^$testname\s*=\s*(.*)$/gm) - { - return $1; - } - return ""; + my $testname = shift; + my $m = shift; + if ($m =~ /^$testname\s*=\s*(.*)$/gm) + { + return $1; + } + return ""; } sub usage { - print STDERR - "Usage: vcregress.pl ", - "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n"; - exit(1); + print STDERR + "Usage: vcregress.pl ", + "<check|installcheck|plcheck|contribcheck|ecpgcheck> [schedule]\n"; + exit(1); } |