Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83078e9

Browse files
committed
Several fixes for MSVC build scripts, from Magnus.
1 parentaab964b commit83078e9

File tree

4 files changed

+87
-46
lines changed

4 files changed

+87
-46
lines changed

‎src/tools/msvc/Project.pm

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ sub AddReference {
8181

8282
while (my$ref =shift) {
8383
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");
8585
}
8686
}
8787

@@ -113,8 +113,8 @@ sub FullExportDLL {
113113
my ($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

120120
subUseDef {
@@ -286,19 +286,19 @@ EOF
286286
my$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
}
291291
elsif ($f =~/\.l$/) {
292292
my$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
}
297297
elsif (defined($uniquefiles{$file})) {
298298
# File already exists, so fake a new name
299299
my$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
}
303303
else {
304304
$uniquefiles{$file} = 1;
@@ -313,6 +313,15 @@ EOF
313313
close(F);
314314
}
315315

316+
subGenerateCustomTool {
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+
316325
subWriteReferences {
317326
my ($self,$f) =@_;
318327
print$f" <References>\n";
@@ -325,48 +334,65 @@ sub WriteReferences {
325334
subWriteHeader {
326335
my ($self,$f) =@_;
327336

328-
my$cfgtype = ($self->{type}eq"exe")?1:($self->{type}eq"dll"?2:4);
329-
330337
print$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+
subWriteConfiguration
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}"
338360
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}"
341364
EOF
342365
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"
345368
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"
348371
LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc"
349372
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"
352375
SubSystem="1" TargetMachine="1"
353376
EOF
354377
if ($self->{implib}) {
355-
print$f"\t\tImportLibrary=\"$self->{implib}\"\n";
378+
my$l =$self->{implib};
379+
$l =~s/__CFGNAME__/$cfgname/g;
380+
print$f"\t\tImportLibrary=\"$l\"\n";
356381
}
357382
if ($self->{def}) {
358-
print$f"\t\tModuleDefinitionFile=\"$self->{def}\"\n";
383+
my$d =$self->{def};
384+
$d =~s/__CFGNAME__/$cfgname/g;
385+
print$f"\t\tModuleDefinitionFile=\"$d\"\n";
359386
}
360387

361388
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";
363390
print$f"\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n";
364391
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";
366393
}
367394
print$f<<EOF;
368395
</Configuration>
369-
</Configurations>
370396
EOF
371397
}
372398

‎src/tools/msvc/Solution.pm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ sub new {
2121
# Special case - if config.pl has changed, always return 1
2222
subIsNewer {
2323
my ($newfile,$oldfile) =@_;
24-
if ($oldfilene'vcbuild\config.pl') {
25-
return 1if IsNewer($newfile,'vcbuild\config.pl');
24+
if ($oldfilene'src\tools\msvc\config.pl') {
25+
return 1if IsNewer($newfile,'src\tools\msvc\config.pl');
2626
}
2727
return 1if (!(-e$newfile));
2828
my@nstat =stat($newfile);
@@ -177,6 +177,17 @@ sub GenerateFiles {
177177
chdir('..\..\..');
178178
}
179179

180+
if (IsNewer('src\interfaces\ecpg\include\ecpg_config.h','src\interfaces\ecpg\include\ecpg_config.h.in')) {
181+
print"Generating ecpg_config.h...\n";
182+
open(O,'>','src\interfaces\ecpg\include\ecpg_config.h') || confess"Could not open ecpg_config.h";
183+
print O<<EOF;
184+
#if (_MSC_VER > 1200)
185+
#define HAVE_LONG_LONG_INT_64
186+
#endif
187+
EOF
188+
close(O);
189+
}
190+
180191
unless (-f"src\\port\\pg_config_paths.h") {
181192
print"Generating pg_config_paths.h...\n";
182193
open(O,'>','src\port\pg_config_paths.h') || confess"Could not open pg_config_paths.h";
@@ -271,6 +282,7 @@ EOF
271282
print SLN<<EOF;
272283
$proj->{guid}.Debug|Win32.ActiveCfg = Debug|Win32
273284
$proj->{guid}.Debug|Win32.Build.0 = Debug|Win32
285+
$proj->{guid}.Release|Win32.ActiveCfg = Release|Win32
274286
$proj->{guid}.Release|Win32.Build.0 = Release|Win32
275287
EOF
276288
}

‎src/tools/msvc/build.bat

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
@echooff
2-
SETSTARTDIR=%CD%
3-
4-
perl mkvcbuild.pl
5-
iferrorlevel1goto :eof
6-
7-
ifexist ..\vcbuildifexist ..\srccd ..
8-
9-
if"%1"=="" msbuild pgsql.sln
10-
ifnot"%1"=="" vcbuild%1.vcproj
11-
12-
cd%STARTDIR%
1+
@echooff
2+
SETSTARTDIR=%CD%
3+
4+
perl mkvcbuild.pl
5+
iferrorlevel1goto :eof
6+
7+
ifexist ..\msvcifexist ..\..\..\srccd ..\..\..
8+
SETCONFIG=
9+
if"%1"==""setCONFIG=Debug
10+
if"%CONFIG%"==""if"%1"=="DEBUG"setCONFIG=Debug
11+
if"%CONFIG%"==""if"%1"=="RELEASE"setCONFIG=Release
12+
ifnot"%CONFIG%"==""shift
13+
if"%CONFIG%"==""setCONFIG=Debug
14+
15+
if"%1"=="" msbuild pgsql.sln /p:Configuration=%CONFIG%
16+
ifnot"%1"=="" vcbuild%1.vcproj%CONFIG%
17+
18+
cd%STARTDIR%

‎src/tools/msvc/mkvcbuild.pl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use Project;
66
use Solution;
77

8-
chdir('..')if (-d'..\vcbuild' &&-d'..\src');
9-
die'Must run from rootdirectoryorvcbuild directory'unless (-d'vcbuild' &&-d'src');
10-
die'Could not find config.pl'unless (-f'vcbuild/config.pl');
8+
chdir('..\..\..')if (-d'..\msvc' &&-d'..\..\..\src');
9+
die'Must run from root ormsvc directory'unless (-d'src\tools\msvc' &&-d'src');
10+
die'Could not find config.pl'unless (-f'src/tools/msvc/config.pl');
1111

1212
our$config;
13-
require'vcbuild/config.pl';
13+
require'src/tools/msvc/config.pl';
1414

1515
my$solution = new Solution($config);
1616

@@ -79,6 +79,7 @@
7979
$libpq->AddDefine('FRONTEND');
8080
$libpq->AddIncludeDir('src\port');
8181
$libpq->AddLibrary('wsock32.lib');
82+
$libpq->AddLibrary('wldap32.lib')if ($solution->{options}->{ldap});
8283
$libpq->UseDef('src\interfaces\libpq\libpqdll.def');
8384
$libpq->ReplaceFile('src\interfaces\libpq\libpqrc.c','src\interfaces\libpq\libpq.rc');
8485

@@ -188,8 +189,6 @@
188189
$proj->AddIncludeDir('src\bin\psql');
189190
$proj->AddReference($libpq,$libpgport);
190191
$proj->AddResourceFile('src\bin\scripts','PostgreSQL Utility');
191-
$proj->AddLibrary('debug\libpgport\libpgport.lib');
192-
$proj->AddLibrary('debug\libpq\libpq.lib');
193192
}
194193
$/ =$t;
195194

@@ -224,11 +223,9 @@ sub AddSimpleFrontend {
224223
$p->AddDir('src\bin\\' .$n);
225224
$p->AddDefine('FRONTEND');
226225
$p->AddReference($libpgport);
227-
$p->AddLibrary('debug\libpgport\libpgport.lib');
228226
if ($uselibpq) {
229227
$p->AddIncludeDir('src\interfaces\libpq');
230228
$p->AddReference($libpq);
231-
$p->AddLibrary('debug\libpq\libpq.lib');
232229
}
233230
return$p;
234231
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp