diff --git a/src/tools/msvc/Project.pm b/src/tools/msvc/Project.pm index 239a4737df..e90b98d4b3 100644 --- a/src/tools/msvc/Project.pm +++ b/src/tools/msvc/Project.pm @@ -81,7 +81,7 @@ sub AddReference { while (my $ref = shift) { push @{$self->{references}},$ref; - $self->AddLibrary("debug\\" . $ref->{name} . "\\" . $ref->{name} . ".lib") if ($ref->{type} eq "exe"); + $self->AddLibrary("__CFGNAME__\\" . $ref->{name} . "\\" . $ref->{name} . ".lib"); } } @@ -113,8 +113,8 @@ sub FullExportDLL { my ($self, $libname) = @_; $self->{builddef} = 1; - $self->{def} = ".\\debug\\$self->{name}\\$self->{name}.def"; - $self->{implib} = "debug\\$self->{name}\\$libname"; + $self->{def} = ".\\__CFGNAME__\\$self->{name}\\$self->{name}.def"; + $self->{implib} = "__CFGNAME__\\$self->{name}\\$libname"; } sub UseDef { @@ -286,19 +286,19 @@ EOF my $of = $f; $of =~ s/\.y$/.c/; $of =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; - print F '>' . "\n"; + print F '>' . GenerateCustomTool('Running bison on ' . $f, 'src\tools\msvc\pgbison.bat ' . $f, $of) . '' . "\n"; } elsif ($f =~ /\.l$/) { my $of = $f; $of =~ s/\.l$/.c/; $of =~ s{^src\\pl\\plpgsql\\src\\scan.c$}{src\\pl\\plpgsql\\src\\pl_scan.c}; - print F ">\n"; + print F '>' . GenerateCustomTool('Running flex on ' . $f, 'src\tools\msvc\pgflex.bat ' . $f,$of) . '' . "\n"; } elsif (defined($uniquefiles{$file})) { # File already exists, so fake a new name my $obj = $dir; $obj =~ s/\\/_/g; - print F ">{name}\\$obj" . "_$file.obj\" />\n"; + print F ">{name}\\$obj" . "_$file.obj\" />{name}\\$obj" . "_$file.obj\" />\n"; } else { $uniquefiles{$file} = 1; @@ -313,6 +313,15 @@ EOF close(F); } +sub GenerateCustomTool { + my ($desc, $tool, $output, $cfg) = @_; + if (!defined($cfg)) { + return GenerateCustomTool($desc, $tool, $output, 'Debug') . + GenerateCustomTool($desc, $tool, $output, 'Release'); + } + return ""; +} + sub WriteReferences { my ($self, $f) = @_; print $f " \n"; @@ -325,48 +334,65 @@ sub WriteReferences { sub WriteHeader { my ($self, $f) = @_; - my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4); - print $f < - - 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 +} + +sub WriteConfiguration +{ + my ($self, $f, $cfgname, $p) = @_; + my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4); + my $libs = $self->{libraries}; + $libs =~ s/__CFGNAME__/$cfgname/g; + print $f < + - {implib}) { - print $f "\t\tImportLibrary=\"$self->{implib}\"\n"; + my $l = $self->{implib}; + $l =~ s/__CFGNAME__/$cfgname/g; + print $f "\t\tImportLibrary=\"$l\"\n"; } if ($self->{def}) { - print $f "\t\tModuleDefinitionFile=\"$self->{def}\"\n"; + my $d = $self->{def}; + $d =~ s/__CFGNAME__/$cfgname/g; + print $f "\t\tModuleDefinitionFile=\"$d\"\n"; } print $f "\t/>\n"; - print $f "\t{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n"; + print $f "\t{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n"; print $f "\t\n"; if ($self->{builddef}) { - print $f "\t{name}\" />\n"; + print $f "\t{name}\" />\n"; } print $f < - EOF } diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 2b1357b09b..1373007501 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -21,8 +21,8 @@ sub new { # Special case - if config.pl has changed, always return 1 sub IsNewer { my ($newfile, $oldfile) = @_; - if ($oldfile ne 'vcbuild\config.pl') { - return 1 if IsNewer($newfile, 'vcbuild\config.pl'); + if ($oldfile ne 'src\tools\msvc\config.pl') { + return 1 if IsNewer($newfile, 'src\tools\msvc\config.pl'); } return 1 if (!(-e $newfile)); my @nstat = stat($newfile); @@ -177,6 +177,17 @@ sub GenerateFiles { 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 < 1200) +#define HAVE_LONG_LONG_INT_64 +#endif +EOF + 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"; @@ -271,6 +282,7 @@ EOF print SLN <{guid}.Debug|Win32.ActiveCfg = Debug|Win32 $proj->{guid}.Debug|Win32.Build.0 = Debug|Win32 + $proj->{guid}.Release|Win32.ActiveCfg = Release|Win32 $proj->{guid}.Release|Win32.Build.0 = Release|Win32 EOF } diff --git a/src/tools/msvc/build.bat b/src/tools/msvc/build.bat index 024819f98f..b2b89f0200 100755 --- a/src/tools/msvc/build.bat +++ b/src/tools/msvc/build.bat @@ -1,12 +1,18 @@ -@echo off -SET STARTDIR=%CD% - -perl mkvcbuild.pl -if errorlevel 1 goto :eof - -if exist ..\vcbuild if exist ..\src cd .. - -if "%1" == "" msbuild pgsql.sln -if not "%1" == "" vcbuild %1.vcproj - -cd %STARTDIR% +@echo off +SET STARTDIR=%CD% + +perl mkvcbuild.pl +if errorlevel 1 goto :eof + +if exist ..\msvc if exist ..\..\..\src cd ..\..\.. +SET CONFIG= +if "%1" == "" set CONFIG=Debug +if "%CONFIG%" == "" if "%1" == "DEBUG" set CONFIG=Debug +if "%CONFIG%" == "" if "%1" == "RELEASE" set CONFIG=Release +if not "%CONFIG%" == "" shift +if "%CONFIG%" == "" set CONFIG=Debug + +if "%1" == "" msbuild pgsql.sln /p:Configuration=%CONFIG% +if not "%1" == "" vcbuild %1.vcproj %CONFIG% + +cd %STARTDIR% diff --git a/src/tools/msvc/mkvcbuild.pl b/src/tools/msvc/mkvcbuild.pl index 3eac344df0..4020aa0d4c 100644 --- a/src/tools/msvc/mkvcbuild.pl +++ b/src/tools/msvc/mkvcbuild.pl @@ -5,12 +5,12 @@ use warnings; use Project; use Solution; -chdir('..') if (-d '..\vcbuild' && -d '..\src'); -die 'Must run from root directory or vcbuild directory' unless (-d 'vcbuild' && -d 'src'); -die 'Could not find config.pl' unless (-f 'vcbuild/config.pl'); +chdir('..\..\..') if (-d '..\msvc' && -d '..\..\..\src'); +die 'Must run from root or msvc directory' unless (-d 'src\tools\msvc' && -d 'src'); +die 'Could not find config.pl' unless (-f 'src/tools/msvc/config.pl'); our $config; -require 'vcbuild/config.pl'; +require 'src/tools/msvc/config.pl'; my $solution = new Solution($config); @@ -79,6 +79,7 @@ my $libpq = $solution->AddProject('libpq','dll','interfaces','src\interfaces\lib $libpq->AddDefine('FRONTEND'); $libpq->AddIncludeDir('src\port'); $libpq->AddLibrary('wsock32.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'); @@ -188,8 +189,6 @@ foreach my $prg (split /\s+/,$1) { $proj->AddIncludeDir('src\bin\psql'); $proj->AddReference($libpq,$libpgport); $proj->AddResourceFile('src\bin\scripts','PostgreSQL Utility'); - $proj->AddLibrary('debug\libpgport\libpgport.lib'); - $proj->AddLibrary('debug\libpq\libpq.lib'); } $/ = $t; @@ -224,11 +223,9 @@ sub AddSimpleFrontend { $p->AddDir('src\bin\\' . $n); $p->AddDefine('FRONTEND'); $p->AddReference($libpgport); - $p->AddLibrary('debug\libpgport\libpgport.lib'); if ($uselibpq) { $p->AddIncludeDir('src\interfaces\libpq'); $p->AddReference($libpq); - $p->AddLibrary('debug\libpq\libpq.lib'); } return $p; }