@@ -81,7 +81,7 @@ sub AddReference {
8181
8282while (my $ref =shift ) {
8383push @{$self -> {references }},$ref ;
84- $self -> AddLibrary(" debug \\ " .$ref -> {name } ." \\ " .$ref -> {name } ." .lib" ) if ( $ref -> { type } eq " exe " );
84+ $self -> AddLibrary(" __CFGNAME__ \\ " .$ref -> {name } ." \\ " .$ref -> {name } ." .lib" );
8585}
8686}
8787
@@ -113,8 +113,8 @@ sub FullExportDLL {
113113my ($self ,$libname ) =@_ ;
114114
115115$self -> {builddef } = 1;
116- $self -> {def } =" .\\ debug \\ $self ->{name}\\ $self ->{name}.def" ;
117- $self -> {implib } =" debug \\ $self ->{name}\\ $libname " ;
116+ $self -> {def } =" .\\ __CFGNAME__ \\ $self ->{name}\\ $self ->{name}.def" ;
117+ $self -> {implib } =" __CFGNAME__ \\ $self ->{name}\\ $libname " ;
118118}
119119
120120sub UseDef {
@@ -286,19 +286,19 @@ EOF
286286my $of =$f ;
287287$of =~s /\. y$/ .c/ ;
288288$of =~s { ^src\\ pl\\ plpgsql\\ src\\ gram.c$} { src\\ pl\\ plpgsql\\ src\\ pl_gram.c} ;
289- print F' ><FileConfiguration Name="Debug|Win32"><Tool Name="VCCustomBuildTool" Description=" Running bison on' .$f . ' " CommandLine="vcbuild\ pgbison.bat' .$f . ' " AdditionalDependencies="" Outputs=" ' . $of .' " /></FileConfiguration> </File>' ." \n " ;
289+ print F' >' . GenerateCustomTool( ' Running bison on' .$f , ' src\tools\msvc\ pgbison.bat' .$f , $of ) .' </File>' ." \n " ;
290290}
291291elsif ($f =~/ \. l$ / ) {
292292my $of =$f ;
293293$of =~s /\. l$/ .c/ ;
294294$of =~s { ^src\\ pl\\ plpgsql\\ src\\ scan.c$} { src\\ pl\\ plpgsql\\ src\\ pl_scan.c} ;
295- print F" ><FileConfiguration Name= \" Debug|Win32 \" ><Tool Name= \" VCCustomBuildTool \" Description= \" Running flex on$f \" CommandLine= \" vcbuild \ \ pgflex.bat$f \" AdditionalDependencies= \"\" Outputs= \" $of \" /></FileConfiguration></ File>\n " ;
295+ print F' > ' . GenerateCustomTool( ' Running flex on' . $f , ' src\tools\msvc \pgflex.bat' . $f , $of ) . ' </ File>' . " \n " ;
296296}
297297elsif (defined ($uniquefiles {$file })) {
298298# File already exists, so fake a new name
299299my $obj =$dir ;
300300$obj =~s /\\ / _/ g ;
301- print F" ><FileConfiguration Name=\" Debug|Win32\" ><Tool Name=\" VCCLCompilerTool\" ObjectFile=\" .\\ debug\\ $self ->{name}\\ $obj " ." _$file .obj\" /></FileConfiguration></File>\n " ;
301+ print F" ><FileConfiguration Name=\" Debug|Win32\" ><Tool Name=\" VCCLCompilerTool\" ObjectFile=\" .\\ debug\\ $self ->{name}\\ $obj " ." _$file .obj\" /></FileConfiguration><FileConfiguration Name= \" Release|Win32 \" ><Tool Name= \" VCCLCompilerTool \" ObjectFile= \" . \\ release \\ $self ->{name} \\ $obj " . " _ $file .obj \" /></FileConfiguration>< /File>\n " ;
302302}
303303else {
304304$uniquefiles {$file } = 1;
313313close (F);
314314}
315315
316+ sub GenerateCustomTool {
317+ my ($desc ,$tool ,$output ,$cfg ) =@_ ;
318+ if (!defined ($cfg )) {
319+ return GenerateCustomTool($desc ,$tool ,$output ,' Debug' ) .
320+ GenerateCustomTool($desc ,$tool ,$output ,' Release' );
321+ }
322+ return " <FileConfiguration Name=\" $cfg |Win32\" ><Tool Name=\" VCCustomBuildTool\" Description=\" $desc \" CommandLine=\" $tool \" AdditionalDependencies=\"\" Outputs=\" $output \" /></FileConfiguration>" ;
323+ }
324+
316325sub WriteReferences {
317326my ($self ,$f ) =@_ ;
318327print $f " <References>\n " ;
@@ -325,48 +334,65 @@ sub WriteReferences {
325334sub WriteHeader {
326335my ($self ,$f ) =@_ ;
327336
328- my $cfgtype = ($self -> {type }eq " exe" )?1:($self -> {type }eq " dll" ?2:4);
329-
330337print $f <<EOF ;
331338<?xml version="1.0" encoding="Windows-1252"?>
332339<VisualStudioProject ProjectType="Visual C++" Version="8.00" Name="$self ->{name}" ProjectGUID="$self ->{guid}">
333340 <Platforms><Platform Name="Win32"/></Platforms>
334341 <Configurations>
335- <Configuration Name="Debug|Win32" OutputDirectory=".\\ Debug\\ $self ->{name}" IntermediateDirectory=".\\ Debug\\ $self ->{name}"
336- ConfigurationType="$cfgtype " UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2">
337- <Tool Name="VCCLCompilerTool" Optimization="0"
342+ EOF
343+ $self -> WriteConfiguration($f ,' Debug' , {defs => ' _DEBUG;DEBUG=1;' ,wholeopt => 0 ,opt => 0,strpool => ' false' ,runtime => 3 });
344+ $self -> WriteConfiguration($f ,' Release' , {defs => ' ' ,wholeopt => 0,opt => 3,strpool => ' true' ,runtime => 2 });
345+ print $f <<EOF ;
346+ </Configurations>
347+ EOF
348+ }
349+
350+ sub WriteConfiguration
351+ {
352+ my ($self ,$f ,$cfgname ,$p ) =@_ ;
353+ my $cfgtype = ($self -> {type }eq " exe" )?1:($self -> {type }eq " dll" ?2:4);
354+ my $libs =$self -> {libraries };
355+ $libs =~s / __CFGNAME__/ $cfgname / g ;
356+ print $f <<EOF ;
357+ <Configuration Name="$cfgname |Win32" OutputDirectory=".\\ $cfgname \\ $self ->{name}" IntermediateDirectory=".\\ $cfgname \\ $self ->{name}"
358+ ConfigurationType="$cfgtype " UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p ->{wholeopt}">
359+ <Tool Name="VCCLCompilerTool" Optimization="$p ->{opt}"
338360AdditionalIncludeDirectories="src/include;src/include/port/win32;src/include/port/win32_msvc;$self ->{solution}->{options}->{pthread};$self ->{includes}"
339- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;__WINDOWS__;DEBUG=1;__WIN32__;EXEC_BACKEND;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self ->{defines}"
340- RuntimeLibrary="3" DisableSpecificWarnings="$self ->{disablewarnings}"
361+ PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self ->{defines}$p ->{defs}"
362+ StringPooling="$p ->{strpool}"
363+ RuntimeLibrary="$p ->{runtime}" DisableSpecificWarnings="$self ->{disablewarnings}"
341364EOF
342365print $f <<EOF ;
343- AssemblerOutput="0" AssemblerListingLocation=".\\ debug \\ $self ->{name}\\ " ObjectFile=".\\ debug \\ $self ->{name}\\ "
344- ProgramDataBaseFileName=".\\ debug \\ $self ->{name}\\ " BrowseInformation="0"
366+ AssemblerOutput="0" AssemblerListingLocation=".\\ $cfgname \\ $self ->{name}\\ " ObjectFile=".\\ $cfgname \\ $self ->{name}\\ "
367+ ProgramDataBaseFileName=".\\ $cfgname \\ $self ->{name}\\ " BrowseInformation="0"
345368WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/>
346- <Tool Name="VCLinkerTool" OutputFile=".\\ debug \\ $self ->{name}\\ $self ->{name}.$self ->{type}"
347- AdditionalDependencies="$self ->{libraries} "
369+ <Tool Name="VCLinkerTool" OutputFile=".\\ $cfgname \\ $self ->{name}\\ $self ->{name}.$self ->{type}"
370+ AdditionalDependencies="$libs "
348371LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
349372StackReserveSize="4194304" DisableSpecificWarnings="$self ->{disablewarnings}"
350- GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\ debug \\ $self ->{name}\\ $self ->{name}.pdb"
351- GenerateMapFile="FALSE" MapFileName=".\\ debug \\ $self ->{name}\\ $self ->{name}.map"
373+ GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\ $cfgname \\ $self ->{name}\\ $self ->{name}.pdb"
374+ GenerateMapFile="FALSE" MapFileName=".\\ $cfgname \\ $self ->{name}\\ $self ->{name}.map"
352375SubSystem="1" TargetMachine="1"
353376EOF
354377if ($self -> {implib }) {
355- print $f " \t\t ImportLibrary=\" $self ->{implib}\"\n " ;
378+ my $l =$self -> {implib };
379+ $l =~s / __CFGNAME__/ $cfgname / g ;
380+ print $f " \t\t ImportLibrary=\" $l \"\n " ;
356381}
357382if ($self -> {def }) {
358- print $f " \t\t ModuleDefinitionFile=\" $self ->{def}\"\n " ;
383+ my $d =$self -> {def };
384+ $d =~s / __CFGNAME__/ $cfgname / g ;
385+ print $f " \t\t ModuleDefinitionFile=\" $d \"\n " ;
359386}
360387
361388print $f " \t />\n " ;
362- print $f " \t <Tool Name=\" VCLibrarianTool\" OutputFile=\" .\\ Debug \\ $self ->{name}\\ $self ->{name}.lib\" IgnoreDefaultLibraryNames=\" libc\" />\n " ;
389+ print $f " \t <Tool Name=\" VCLibrarianTool\" OutputFile=\" .\\ $cfgname \\ $self ->{name}\\ $self ->{name}.lib\" IgnoreDefaultLibraryNames=\" libc\" />\n " ;
363390print $f " \t <Tool Name=\" VCResourceCompilerTool\" AdditionalIncludeDirectories=\" src\\ include\" />\n " ;
364391if ($self -> {builddef }) {
365- print $f " \t <Tool Name=\" VCPreLinkEventTool\" Description=\" Generate DEF file\" CommandLine=\" perlvcbuild \\ gendef.pldebug \\ $self ->{name}\" />\n " ;
392+ print $f " \t <Tool Name=\" VCPreLinkEventTool\" Description=\" Generate DEF file\" CommandLine=\" perlsrc \\ tools \\ msvc \\ gendef.pl$cfgname \\ $self ->{name}\" />\n " ;
366393}
367394print $f <<EOF ;
368395 </Configuration>
369- </Configurations>
370396EOF
371397}
372398