diff options
Diffstat (limited to 'src/tools/msvc/Solution.pm')
-rw-r--r-- | src/tools/msvc/Solution.pm | 246 |
1 files changed, 138 insertions, 108 deletions
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 0c50c057347..d6b79dcc29c 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -13,15 +13,14 @@ use VSObjectFactory; sub _new { my $classname = shift; - my $options = shift; - my $self = { + my $options = shift; + my $self = { projects => {}, options => $options, numver => '', strver => '', vcver => undef, - platform => undef, - }; + platform => undef, }; bless($self, $classname); # integer_datetimes is now the default @@ -37,22 +36,23 @@ sub _new } } $options->{blocksize} = 8 - unless $options->{blocksize}; # undef or 0 means default + unless $options->{blocksize}; # undef or 0 means default die "Bad blocksize $options->{blocksize}" - unless grep {$_ == $options->{blocksize}} (1,2,4,8,16,32); + unless grep { $_ == $options->{blocksize} } (1, 2, 4, 8, 16, 32); $options->{segsize} = 1 - unless $options->{segsize}; # undef or 0 means default - # only allow segsize 1 for now, as we can't do large files yet in windows + unless $options->{segsize}; # undef or 0 means default + # only allow segsize 1 for now, as we can't do large files yet in windows die "Bad segsize $options->{segsize}" unless $options->{segsize} == 1; $options->{wal_blocksize} = 8 - unless $options->{wal_blocksize}; # undef or 0 means default + unless $options->{wal_blocksize}; # undef or 0 means default die "Bad wal_blocksize $options->{wal_blocksize}" - unless grep {$_ == $options->{wal_blocksize}} (1,2,4,8,16,32,64); + unless grep { $_ == $options->{wal_blocksize} } + (1, 2, 4, 8, 16, 32, 64); $options->{wal_segsize} = 16 - unless $options->{wal_segsize}; # undef or 0 means default + unless $options->{wal_segsize}; # undef or 0 means default die "Bad wal_segsize $options->{wal_segsize}" - unless grep {$_ == $options->{wal_segsize}} (1,2,4,8,16,32,64); + unless grep { $_ == $options->{wal_segsize} } (1, 2, 4, 8, 16, 32, 64); $self->DeterminePlatform(); @@ -66,7 +66,7 @@ sub DeterminePlatform # Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has # 64-bit only parameters. $self->{platform} = 'Win32'; - open(P,"cl /? 2>NUL|") || die "cl command not found"; + open(P, "cl /? 2>NUL|") || die "cl command not found"; while (<P>) { if (/^\/favor:</) @@ -84,7 +84,7 @@ sub DeterminePlatform sub IsNewer { my ($newfile, $oldfile) = @_; - if ( $oldfile ne 'src\tools\msvc\config.pl' + if ( $oldfile ne 'src\tools\msvc\config.pl' && $oldfile ne 'src\tools\msvc\config_default.pl') { return 1 @@ -105,8 +105,8 @@ sub IsNewer sub copyFile { my ($src, $dest) = @_; - open(I,$src) || croak "Could not open $src"; - open(O,">$dest") || croak "Could not open $dest"; + open(I, $src) || croak "Could not open $src"; + open(O, ">$dest") || croak "Could not open $dest"; while (<I>) { print O; @@ -121,7 +121,8 @@ sub GenerateFiles my $bits = $self->{platform} eq 'Win32' ? 32 : 64; # Parse configure.in to get version numbers - open(C,"configure.in") || confess("Could not open configure.in for reading\n"); + open(C, "configure.in") + || confess("Could not open configure.in for reading\n"); while (<C>) { if (/^AC_INIT\(\[PostgreSQL\], \[([^\]]+)\]/) @@ -131,7 +132,7 @@ sub GenerateFiles { confess "Bad format of version: $self->{strver}\n"; } - $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3?$3:0); + $self->{numver} = sprintf("%d%02d%02d", $1, $2, $3 ? $3 : 0); $self->{majorver} = sprintf("%d.%d", $1, $2); } } @@ -139,18 +140,22 @@ sub GenerateFiles confess "Unable to parse configure.in for all variables!" if ($self->{strver} eq '' || $self->{numver} eq ''); - if (IsNewer("src\\include\\pg_config_os.h","src\\include\\port\\win32.h")) + if (IsNewer( + "src\\include\\pg_config_os.h", "src\\include\\port\\win32.h")) { print "Copying pg_config_os.h...\n"; - copyFile("src\\include\\port\\win32.h","src\\include\\pg_config_os.h"); + copyFile("src\\include\\port\\win32.h", + "src\\include\\pg_config_os.h"); } - if (IsNewer("src\\include\\pg_config.h","src\\include\\pg_config.h.win32")) + if (IsNewer( + "src\\include\\pg_config.h", "src\\include\\pg_config.h.win32")) { print "Generating pg_config.h...\n"; - open(I,"src\\include\\pg_config.h.win32") + open(I, "src\\include\\pg_config.h.win32") || confess "Could not open pg_config.h.win32\n"; - open(O,">src\\include\\pg_config.h") || confess "Could not write to pg_config.h\n"; + open(O, ">src\\include\\pg_config.h") + || confess "Could not write to pg_config.h\n"; while (<I>) { s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}"}; @@ -159,22 +164,27 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY print O; } print O "#define PG_MAJORVERSION \"$self->{majorver}\"\n"; - print O "#define LOCALEDIR \"/share/locale\"\n" if ($self->{options}->{nls}); + print O "#define LOCALEDIR \"/share/locale\"\n" + if ($self->{options}->{nls}); print O "/* defines added by config steps */\n"; print O "#ifndef IGNORE_CONFIGURED_SETTINGS\n"; - print O "#define USE_ASSERT_CHECKING 1\n" if ($self->{options}->{asserts}); + print O "#define USE_ASSERT_CHECKING 1\n" + if ($self->{options}->{asserts}); print O "#define USE_INTEGER_DATETIMES 1\n" if ($self->{options}->{integer_datetimes}); - print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap}); - print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib}); - print O "#define USE_SSL 1\n" if ($self->{options}->{openssl}); + print O "#define USE_LDAP 1\n" if ($self->{options}->{ldap}); + print O "#define HAVE_LIBZ 1\n" if ($self->{options}->{zlib}); + print O "#define USE_SSL 1\n" if ($self->{options}->{openssl}); print O "#define ENABLE_NLS 1\n" if ($self->{options}->{nls}); - print O "#define BLCKSZ ",1024 * $self->{options}->{blocksize},"\n"; + print O "#define BLCKSZ ", 1024 * $self->{options}->{blocksize}, "\n"; print O "#define RELSEG_SIZE ", - (1024 / $self->{options}->{blocksize}) *$self->{options}->{segsize} * 1024, "\n"; - print O "#define XLOG_BLCKSZ ",1024 * $self->{options}->{wal_blocksize},"\n"; - print O "#define XLOG_SEG_SIZE (",$self->{options}->{wal_segsize}, + (1024 / $self->{options}->{blocksize}) * + $self->{options}->{segsize} * + 1024, "\n"; + print O "#define XLOG_BLCKSZ ", + 1024 * $self->{options}->{wal_blocksize}, "\n"; + print O "#define XLOG_SEG_SIZE (", $self->{options}->{wal_segsize}, " * 1024 * 1024)\n"; if ($self->{options}->{float4byval}) @@ -225,40 +235,43 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY print O "#define DEF_PGPORT $port\n"; print O "#define DEF_PGPORT_STR \"$port\"\n"; } - print O "#define VAL_CONFIGURE \"" . $self->GetFakeConfigure() . "\"\n"; + print O "#define VAL_CONFIGURE \"" + . $self->GetFakeConfigure() . "\"\n"; print O "#endif /* IGNORE_CONFIGURED_SETTINGS */\n"; close(O); close(I); } - $self->GenerateDefFile("src\\interfaces\\libpq\\libpqdll.def", - "src\\interfaces\\libpq\\exports.txt","LIBPQ"); + $self->GenerateDefFile( + "src\\interfaces\\libpq\\libpqdll.def", + "src\\interfaces\\libpq\\exports.txt", + "LIBPQ"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\ecpglib\\ecpglib.def", "src\\interfaces\\ecpg\\ecpglib\\exports.txt", - "LIBECPG" - ); + "LIBECPG"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\compatlib\\compatlib.def", "src\\interfaces\\ecpg\\compatlib\\exports.txt", - "LIBECPG_COMPAT" - ); + "LIBECPG_COMPAT"); $self->GenerateDefFile( "src\\interfaces\\ecpg\\pgtypeslib\\pgtypeslib.def", "src\\interfaces\\ecpg\\pgtypeslib\\exports.txt", - "LIBPGTYPES" - ); + "LIBPGTYPES"); - if (IsNewer('src\backend\utils\fmgrtab.c','src\include\catalog\pg_proc.h')) + if (IsNewer( + 'src\backend\utils\fmgrtab.c', 'src\include\catalog\pg_proc.h')) { print "Generating fmgrtab.c and fmgroids.h...\n"; chdir('src\backend\utils'); - system("perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h"); + system( +"perl -I ../catalog Gen_fmgrtab.pl ../../../src/include/catalog/pg_proc.h"); chdir('..\..\..'); - copyFile('src\backend\utils\fmgroids.h','src\include\utils\fmgroids.h'); + copyFile('src\backend\utils\fmgroids.h', + 'src\include\utils\fmgroids.h'); } - if (IsNewer('src\include\utils\probes.h','src\backend\utils\probes.d')) + if (IsNewer('src\include\utils\probes.h', 'src\backend\utils\probes.d')) { print "Generating probes.h...\n"; system( @@ -267,7 +280,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY } if ($self->{options}->{python} - && IsNewer('src\pl\plpython\spiexceptions.h','src\include\backend\errcodes.txt')) + && IsNewer( + 'src\pl\plpython\spiexceptions.h', + 'src\include\backend\errcodes.txt')) { print "Generating spiexceptions.h...\n"; system( @@ -275,16 +290,21 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if (IsNewer('src\include\utils\errcodes.h','src\backend\utils\errcodes.txt')) + if (IsNewer( + 'src\include\utils\errcodes.h', + 'src\backend\utils\errcodes.txt')) { print "Generating errcodes.h...\n"; system( 'perl src\backend\utils\generate-errcodes.pl src\backend\utils\errcodes.txt > src\backend\utils\errcodes.h' ); - copyFile('src\backend\utils\errcodes.h','src\include\utils\errcodes.h'); + copyFile('src\backend\utils\errcodes.h', + 'src\include\utils\errcodes.h'); } - if (IsNewer('src\pl\plpgsql\src\plerrcodes.h','src\backend\utils\errcodes.txt')) + if (IsNewer( + 'src\pl\plpgsql\src\plerrcodes.h', + 'src\backend\utils\errcodes.txt')) { print "Generating plerrcodes.h...\n"; system( @@ -292,12 +312,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if ( - IsNewer( + if (IsNewer( 'src\backend\utils\sort\qsort_tuple.c', - 'src\backend\utils\sort\gen_qsort_tuple.pl' - ) - ) + 'src\backend\utils\sort\gen_qsort_tuple.pl')) { print "Generating qsort_tuple.c...\n"; system( @@ -305,14 +322,18 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY ); } - if (IsNewer('src\interfaces\libpq\libpq.rc','src\interfaces\libpq\libpq.rc.in')) + if (IsNewer( + 'src\interfaces\libpq\libpq.rc', + 'src\interfaces\libpq\libpq.rc.in')) { print "Generating libpq.rc...\n"; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = + localtime(time); my $d = ($year - 100) . "$yday"; - open(I,'<', 'src\interfaces\libpq\libpq.rc.in') + open(I, '<', 'src\interfaces\libpq\libpq.rc.in') || confess "Could not open libpq.rc.in"; - open(O,'>', 'src\interfaces\libpq\libpq.rc') || confess "Could not open libpq.rc"; + open(O, '>', 'src\interfaces\libpq\libpq.rc') + || confess "Could not open libpq.rc"; while (<I>) { s/(VERSION.*),0/$1,$d/; @@ -322,7 +343,7 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY close(O); } - if (IsNewer('src\bin\psql\sql_help.h','src\bin\psql\create_help.pl')) + if (IsNewer('src\bin\psql\sql_help.h', 'src\bin\psql\create_help.pl')) { print "Generating sql_help.h...\n"; chdir('src\bin\psql'); @@ -330,7 +351,9 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY chdir('..\..\..'); } - if (IsNewer('src\interfaces\ecpg\preproc\preproc.y','src\backend\parser\gram.y')) + if (IsNewer( + 'src\interfaces\ecpg\preproc\preproc.y', + 'src\backend\parser\gram.y')) { print "Generating preproc.y...\n"; chdir('src\interfaces\ecpg\preproc'); @@ -338,15 +361,12 @@ s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY chdir('..\..\..\..'); } - if ( - IsNewer( + if (IsNewer( 'src\interfaces\ecpg\include\ecpg_config.h', - 'src\interfaces\ecpg\include\ecpg_config.h.in' - ) - ) + 'src\interfaces\ecpg\include\ecpg_config.h.in')) { print "Generating ecpg_config.h...\n"; - open(O,'>','src\interfaces\ecpg\include\ecpg_config.h') + open(O, '>', 'src\interfaces\ecpg\include\ecpg_config.h') || confess "Could not open ecpg_config.h"; print O <<EOF; #if (_MSC_VER > 1200) @@ -362,9 +382,9 @@ EOF unless (-f "src\\port\\pg_config_paths.h") { print "Generating pg_config_paths.h...\n"; - open(O,'>', 'src\port\pg_config_paths.h') + open(O, '>', 'src\port\pg_config_paths.h') || confess "Could not open pg_config_paths.h"; - print O <<EOF; + print O <<EOF; #define PGBINDIR "/bin" #define PGSHAREDIR "/share" #define SYSCONFDIR "/etc" @@ -389,7 +409,9 @@ EOF foreach my $bki (@allbki) { next if $bki eq ""; - if (IsNewer('src/backend/catalog/postgres.bki', "src/include/catalog/$bki")) + if (IsNewer( + 'src/backend/catalog/postgres.bki', + "src/include/catalog/$bki")) { print "Generating postgres.bki and schemapg.h...\n"; chdir('src\backend\catalog'); @@ -398,13 +420,15 @@ EOF "perl genbki.pl -I../../../src/include/catalog --set-version=$self->{majorver} $bki_srcs" ); chdir('..\..\..'); - copyFile('src\backend\catalog\schemapg.h', + copyFile( + 'src\backend\catalog\schemapg.h', 'src\include\catalog\schemapg.h'); last; } } - open(O, ">doc/src/sgml/version.sgml") || croak "Could not write to version.sgml\n"; + open(O, ">doc/src/sgml/version.sgml") + || croak "Could not write to version.sgml\n"; print O <<EOF; <!ENTITY version "$self->{strver}"> <!ENTITY majorversion "$self->{majorver}"> @@ -414,13 +438,13 @@ EOF sub GenerateDefFile { - my ($self, $deffile, $txtfile, $libname) = @_; + my ($self, $deffile, $txtfile, $libname) = @_; - if (IsNewer($deffile,$txtfile)) + if (IsNewer($deffile, $txtfile)) { print "Generating $deffile...\n"; - open(I,$txtfile) || confess("Could not open $txtfile\n"); - open(O,">$deffile") || confess("Could not open $deffile\n"); + open(I, $txtfile) || confess("Could not open $txtfile\n"); + open(O, ">$deffile") || confess("Could not open $deffile\n"); print O "LIBRARY $libname\nEXPORTS\n"; while (<I>) { @@ -438,8 +462,9 @@ sub AddProject { my ($self, $name, $type, $folder, $initialdir) = @_; - my $proj = VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); - push @{$self->{projects}->{$folder}}, $proj; + my $proj = + VSObjectFactory::CreateProject($self->{vcver}, $name, $type, $self); + push @{ $self->{projects}->{$folder} }, $proj; $proj->AddDir($initialdir) if ($initialdir); if ($self->{options}->{zlib}) { @@ -449,8 +474,10 @@ sub AddProject if ($self->{options}->{openssl}) { $proj->AddIncludeDir($self->{options}->{openssl} . '\include'); - $proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); - $proj->AddLibrary($self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); + $proj->AddLibrary( + $self->{options}->{openssl} . '\lib\VC\ssleay32.lib', 1); + $proj->AddLibrary( + $self->{options}->{openssl} . '\lib\VC\libeay32.lib', 1); } if ($self->{options}->{nls}) { @@ -461,8 +488,10 @@ sub AddProject { $proj->AddIncludeDir($self->{options}->{krb5} . '\inc\krb5'); $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\krb5_32.lib'); - $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\comerr32.lib'); - $proj->AddLibrary($self->{options}->{krb5} . '\lib\i386\gssapi32.lib'); + $proj->AddLibrary( + $self->{options}->{krb5} . '\lib\i386\comerr32.lib'); + $proj->AddLibrary( + $self->{options}->{krb5} . '\lib\i386\gssapi32.lib'); } if ($self->{options}->{iconv}) { @@ -488,23 +517,23 @@ sub Save my %flduid; $self->GenerateFiles(); - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { $proj->Save(); } } - open(SLN,">pgsql.sln") || croak "Could not write to pgsql.sln\n"; + open(SLN, ">pgsql.sln") || croak "Could not write to pgsql.sln\n"; print SLN <<EOF; Microsoft Visual Studio Solution File, Format Version $self->{solutionFileVersion} # $self->{visualStudioName} EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN <<EOF; Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "$proj->{name}", "$proj->{name}$proj->{filenameExtension}", "$proj->{guid}" @@ -530,9 +559,9 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN <<EOF; $proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform} @@ -551,10 +580,10 @@ EOF GlobalSection(NestedProjects) = preSolution EOF - foreach my $fld (keys %{$self->{projects}}) + foreach my $fld (keys %{ $self->{projects} }) { next if ($fld eq ""); - foreach my $proj (@{$self->{projects}->{$fld}}) + foreach my $proj (@{ $self->{projects}->{$fld} }) { print SLN "\t\t$proj->{guid} = $flduid{$fld}\n"; } @@ -573,18 +602,19 @@ sub GetFakeConfigure my $cfg = '--enable-thread-safety'; $cfg .= ' --enable-cassert' if ($self->{options}->{asserts}); - $cfg .= ' --enable-integer-datetimes' if ($self->{options}->{integer_datetimes}); + $cfg .= ' --enable-integer-datetimes' + if ($self->{options}->{integer_datetimes}); $cfg .= ' --enable-nls' if ($self->{options}->{nls}); - $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); + $cfg .= ' --with-ldap' if ($self->{options}->{ldap}); $cfg .= ' --without-zlib' unless ($self->{options}->{zlib}); - $cfg .= ' --with-openssl' if ($self->{options}->{ssl}); + $cfg .= ' --with-openssl' if ($self->{options}->{ssl}); $cfg .= ' --with-ossp-uuid' if ($self->{options}->{uuid}); - $cfg .= ' --with-libxml' if ($self->{options}->{xml}); - $cfg .= ' --with-libxslt' if ($self->{options}->{xslt}); - $cfg .= ' --with-krb5' if ($self->{options}->{krb5}); - $cfg .= ' --with-tcl' if ($self->{options}->{tcl}); - $cfg .= ' --with-perl' if ($self->{options}->{perl}); - $cfg .= ' --with-python' if ($self->{options}->{python}); + $cfg .= ' --with-libxml' if ($self->{options}->{xml}); + $cfg .= ' --with-libxslt' if ($self->{options}->{xslt}); + $cfg .= ' --with-krb5' if ($self->{options}->{krb5}); + $cfg .= ' --with-tcl' if ($self->{options}->{tcl}); + $cfg .= ' --with-perl' if ($self->{options}->{perl}); + $cfg .= ' --with-python' if ($self->{options}->{python}); return $cfg; } @@ -602,12 +632,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '9.00'; - $self->{vcver} = '8.00'; - $self->{visualStudioName} = 'Visual Studio 2005'; + $self->{vcver} = '8.00'; + $self->{visualStudioName} = 'Visual Studio 2005'; return $self; } @@ -625,12 +655,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '10.00'; - $self->{vcver} = '9.00'; - $self->{visualStudioName} = 'Visual Studio 2008'; + $self->{vcver} = '9.00'; + $self->{visualStudioName} = 'Visual Studio 2008'; return $self; } @@ -649,12 +679,12 @@ use base qw(Solution); sub new { my $classname = shift; - my $self = $classname->SUPER::_new(@_); + my $self = $classname->SUPER::_new(@_); bless($self, $classname); $self->{solutionFileVersion} = '11.00'; - $self->{vcver} = '10.00'; - $self->{visualStudioName} = 'Visual Studio 2010'; + $self->{vcver} = '10.00'; + $self->{visualStudioName} = 'Visual Studio 2010'; return $self; } |