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

Commitf9c5d3e

Browse files
committed
Detect a 64-bit build environment on Windows, and generate the appropriate
project files.Based on the work of Tsutomu Yamada, but much refactored.
1 parent5069e95 commitf9c5d3e

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed

‎src/tools/msvc/Project.pm

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Project;
33
#
44
# Package that encapsulates a Visual C++ project file generation
55
#
6-
# $PostgreSQL: pgsql/src/tools/msvc/Project.pm,v 1.22 2009/12/23 13:27:04 mha Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Project.pm,v 1.23 2010/01/01 17:34:25 mha Exp $
77
#
88
use Carp;
99
use strict;
@@ -33,7 +33,8 @@ sub new
3333
solution=>$solution,
3434
disablewarnings=>'4018;4244;4273;4102;4090',
3535
disablelinkerwarnings=>'',
36-
vcver=>$solution->{vcver}
36+
vcver=>$solution->{vcver},
37+
platform=>$solution->{platform},
3738
};
3839

3940
bless$self;
@@ -391,7 +392,7 @@ EOF
391392
$of =~s/\.y$/.c/;
392393
$of =~s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c};
393394
print F'>'
394-
. GenerateCustomTool('Running bison on' .$f,
395+
.$self->GenerateCustomTool('Running bison on' .$f,
395396
'cmd /V:ON /c src\tools\msvc\pgbison.bat' .$f,$of)
396397
.'</File>' ."\n";
397398
}
@@ -400,7 +401,7 @@ EOF
400401
my$of =$f;
401402
$of =~s/\.l$/.c/;
402403
print F'>'
403-
. GenerateCustomTool('Running flex on' .$f,'src\tools\msvc\pgflex.bat' .$f,$of)
404+
.$self->GenerateCustomTool('Running flex on' .$f,'src\tools\msvc\pgflex.bat' .$f,$of)
404405
.'</File>' ."\n";
405406
}
406407
elsif (defined($uniquefiles{$file}))
@@ -410,8 +411,8 @@ EOF
410411
my$obj =$dir;
411412
$obj =~s/\\/_/g;
412413
print F
413-
"><FileConfiguration Name=\"Debug|Win32\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj"
414-
."_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|Win32\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj"
414+
"><FileConfiguration Name=\"Debug|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj"
415+
."_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj"
415416
."_$file.obj\" /></FileConfiguration></File>\n";
416417
}
417418
else
@@ -431,14 +432,14 @@ EOF
431432

432433
subGenerateCustomTool
433434
{
434-
my ($desc,$tool,$output,$cfg) =@_;
435+
my ($self,$desc,$tool,$output,$cfg) =@_;
435436
if (!defined($cfg))
436437
{
437-
return GenerateCustomTool($desc,$tool,$output,'Debug')
438-
.GenerateCustomTool($desc,$tool,$output,'Release');
438+
return$self->GenerateCustomTool($desc,$tool,$output,'Debug') .
439+
$self->GenerateCustomTool($desc,$tool,$output,'Release');
439440
}
440441
return
441-
"<FileConfiguration Name=\"$cfg|Win32\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>";
442+
"<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>";
442443
}
443444

444445
subWriteReferences
@@ -460,7 +461,7 @@ sub WriteHeader
460461
print$f<<EOF;
461462
<?xml version="1.0" encoding="Windows-1252"?>
462463
<VisualStudioProject ProjectType="Visual C++" Version="$self->{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}">
463-
<Platforms><Platform Name="Win32"/></Platforms>
464+
<Platforms><Platform Name="$self->{platform}"/></Platforms>
464465
<Configurations>
465466
EOF
466467
$self->WriteConfiguration($f,'Debug',
@@ -493,8 +494,9 @@ sub WriteConfiguration
493494
}
494495
$libs =~s/ $//;
495496
$libs =~s/__CFGNAME__/$cfgname/g;
497+
my$targetmachine =$self->{platform}eq'Win32' ? 1 : 17;
496498
print$f<<EOF;
497-
<Configuration Name="$cfgname|Win32" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"
499+
<Configuration Name="$cfgname|$self->{platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}"
498500
ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}">
499501
<Tool Name="VCCLCompilerTool" Optimization="$p->{opt}"
500502
AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}"
@@ -513,7 +515,7 @@ EOF
513515
StackReserveSize="4194304" DisableSpecificWarnings="$self->{disablewarnings}"
514516
GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\$cfgname\\$self->{name}\\$self->{name}.pdb"
515517
GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map"
516-
SubSystem="1" TargetMachine="1"
518+
SubSystem="1" TargetMachine="$targetmachine"
517519
EOF
518520
if ($self->{disablelinkerwarnings})
519521
{
@@ -540,7 +542,7 @@ EOF
540542
if ($self->{builddef})
541543
{
542544
print$f
543-
"\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl$cfgname\\$self->{name}\" />\n";
545+
"\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl$cfgname\\$self->{name}$self->{platform}\" />\n";
544546
}
545547
print$f<<EOF;
546548
</Configuration>

‎src/tools/msvc/Solution.pm

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package Solution;
33
#
44
# Package that encapsulates a Visual C++ solution file generation
55
#
6-
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.50 2009/12/30 12:26:41 mha Exp $
6+
# $PostgreSQL: pgsql/src/tools/msvc/Solution.pm,v 1.51 2010/01/01 17:34:25 mha Exp $
77
#
88
use Carp;
99
use strict;
@@ -21,6 +21,7 @@ sub new
2121
numver=>'',
2222
strver=>'',
2323
vcver=>undef,
24+
platform=>undef,
2425
};
2526
bless$self;
2627
# integer_datetimes is now the default
@@ -73,6 +74,19 @@ sub DetermineToolVersions
7374
elsif ($1 == 9) {$self->{vcver} ='9.00' }
7475
else {die"Unsupported version of Visual Studio:$1" }
7576
print"Detected Visual Studio version$self->{vcver}\n";
77+
78+
# Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has
79+
# 64-bit only parameters.
80+
$self->{platform} ='Win32';
81+
open(P,"cl /? 2>NUL|") ||die"cl command not found";
82+
while (<P>) {
83+
if (/^\/favor:</) {
84+
$self->{platform} ='x64';
85+
last;
86+
}
87+
}
88+
close(P);
89+
print"Detected hardware platform:$self->{platform}\n";
7690
}
7791

7892

@@ -109,6 +123,7 @@ sub copyFile
109123
subGenerateFiles
110124
{
111125
my$self =shift;
126+
my$bits =$self->{platform}eq'Win32' ? 32 : 64;
112127

113128
# Parse configure.in to get version numbers
114129
open(C,"configure.in") || confess("Could not open configure.in for reading\n");
@@ -144,8 +159,7 @@ sub GenerateFiles
144159
{
145160
s{PG_VERSION "[^"]+"}{PG_VERSION "$self->{strver}"};
146161
s{PG_VERSION_NUM\d+}{PG_VERSION_NUM$self->{numver}};
147-
# XXX: When we support 64-bit, need to remove this hardcoding
148-
s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL$self->{strver}, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ", 32-bit"};
162+
s{PG_VERSION_STR "[^"]+"}{__STRINGIFY(x) #x\n#define __STRINGIFY2(z) __STRINGIFY(z)\n#define PG_VERSION_STR "PostgreSQL$self->{strver}, compiled by Visual C++ build " __STRINGIFY2(_MSC_VER) ",$bits-bit"};
149163
print O;
150164
}
151165
print O"#define PG_MAJORVERSION\"$self->{majorver}\"\n";
@@ -446,8 +460,8 @@ EOF
446460
print SLN<<EOF;
447461
Global
448462
GlobalSection(SolutionConfigurationPlatforms) = preSolution
449-
Debug|Win32= Debug|Win32
450-
Release|Win32 = Release|Win32
463+
Debug|$self->{platform}= Debug|$self->{platform}
464+
Release|$self->{platform} = Release|$self->{platform}
451465
EndGlobalSection
452466
GlobalSection(ProjectConfigurationPlatforms) = postSolution
453467
EOF
@@ -457,10 +471,10 @@ EOF
457471
foreachmy$proj (@{$self->{projects}->{$fld}})
458472
{
459473
print SLN<<EOF;
460-
$proj->{guid}.Debug|Win32.ActiveCfg = Debug|Win32
461-
$proj->{guid}.Debug|Win32.Build.0 = Debug|Win32
462-
$proj->{guid}.Release|Win32.ActiveCfg = Release|Win32
463-
$proj->{guid}.Release|Win32.Build.0 = Release|Win32
474+
$proj->{guid}.Debug|$self->{platform}.ActiveCfg = Debug|$self->{platform}
475+
$proj->{guid}.Debug|$self->{platform}.Build.0 = Debug|$self->{platform}
476+
$proj->{guid}.Release|$self->{platform}.ActiveCfg = Release|$self->{platform}
477+
$proj->{guid}.Release|$self->{platform}.Build.0 = Release|$self->{platform}
464478
EOF
465479
}
466480
}

‎src/tools/msvc/gendef.pl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
#
33
# Script that generates a .DEF file for all objects in a directory
44
#
5-
# $PostgreSQL: pgsql/src/tools/msvc/gendef.pl,v 1.8 2008/01/31 16:30:24 adunstan Exp $
5+
# $PostgreSQL: pgsql/src/tools/msvc/gendef.pl,v 1.9 2010/01/01 17:34:25 mha Exp $
66
#
77

8-
die"Usage: gendef.pl <modulepath>\n"unless ($ARGV[0] =~/\\([^\\]+$)/);
8+
die"Usage: gendef.pl <modulepath> <platform>\n"unless
9+
(($ARGV[0] =~/\\([^\\]+$)/) && ($ARGV[1] =='Win32' ||$ARGV[1] =='x64'));
910
my$defname =uc$1;
11+
my$platform =$ARGV[1];
1012

1113
if (-f"$ARGV[0]/$defname.def")
1214
{
1315
print"Not re-generating$defname.DEF, file already exists.\n";
1416
exit(0);
1517
}
1618

17-
print"Generating$defname.DEF from directory$ARGV[0]\n";
19+
print"Generating$defname.DEF from directory$ARGV[0], platform$platform\n";
1820

1921
while (<$ARGV[0]/*.obj>)
2022
{
@@ -55,7 +57,7 @@
5557
{
5658
nextif ($feq$last);
5759
$last =$f;
58-
$f =~s/^_//;
60+
$f =~s/^_//unless ($platformeq"x64");# win64 has new format of exports
5961
$i++;
6062

6163
# print DEF " $f \@ $i\n"; # ordinaled exports?

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp