@@ -81,7 +81,7 @@ sub AddReference {
81
81
82
82
while (my $ref =shift ) {
83
83
push @{$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" );
85
85
}
86
86
}
87
87
@@ -113,8 +113,8 @@ sub FullExportDLL {
113
113
my ($self ,$libname ) =@_ ;
114
114
115
115
$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 " ;
118
118
}
119
119
120
120
sub UseDef {
@@ -286,19 +286,19 @@ EOF
286
286
my $of =$f ;
287
287
$of =~s /\. y$/ .c/ ;
288
288
$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 " ;
290
290
}
291
291
elsif ($f =~/ \. l$ / ) {
292
292
my $of =$f ;
293
293
$of =~s /\. l$/ .c/ ;
294
294
$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 " ;
296
296
}
297
297
elsif (defined ($uniquefiles {$file })) {
298
298
# File already exists, so fake a new name
299
299
my $obj =$dir ;
300
300
$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 " ;
302
302
}
303
303
else {
304
304
$uniquefiles {$file } = 1;
313
313
close (F);
314
314
}
315
315
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
+
316
325
sub WriteReferences {
317
326
my ($self ,$f ) =@_ ;
318
327
print $f " <References>\n " ;
@@ -325,48 +334,65 @@ sub WriteReferences {
325
334
sub WriteHeader {
326
335
my ($self ,$f ) =@_ ;
327
336
328
- my $cfgtype = ($self -> {type }eq " exe" )?1:($self -> {type }eq " dll" ?2:4);
329
-
330
337
print $f <<EOF ;
331
338
<?xml version="1.0" encoding="Windows-1252"?>
332
339
<VisualStudioProject ProjectType="Visual C++" Version="8.00" Name="$self ->{name}" ProjectGUID="$self ->{guid}">
333
340
<Platforms><Platform Name="Win32"/></Platforms>
334
341
<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}"
338
360
AdditionalIncludeDirectories="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}"
341
364
EOF
342
365
print $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"
345
368
WarningLevel="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 "
348
371
LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
349
372
StackReserveSize="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"
352
375
SubSystem="1" TargetMachine="1"
353
376
EOF
354
377
if ($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 " ;
356
381
}
357
382
if ($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 " ;
359
386
}
360
387
361
388
print $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 " ;
363
390
print $f " \t <Tool Name=\" VCResourceCompilerTool\" AdditionalIncludeDirectories=\" src\\ include\" />\n " ;
364
391
if ($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 " ;
366
393
}
367
394
print $f <<EOF ;
368
395
</Configuration>
369
- </Configurations>
370
396
EOF
371
397
}
372
398