mirror of https://github.com/postgres/postgres
Brar Piening, reviewed by Craig Ringer.pull/1/head
parent
f132824c24
commit
63876d3bac
@ -0,0 +1,388 @@ |
||||
package MSBuildProject; |
||||
|
||||
# |
||||
# Package that encapsulates a MSBuild (Visual C++ 2010) project file |
||||
# |
||||
# src/tools/msvc/MSBuildProject.pm |
||||
# |
||||
|
||||
use Carp; |
||||
use strict; |
||||
use warnings; |
||||
use base qw(Project); |
||||
|
||||
sub _new |
||||
{ |
||||
my $classname = shift; |
||||
my $self = $classname->SUPER::_new(@_); |
||||
bless($self, $classname); |
||||
|
||||
$self->{filenameExtension} = '.vcxproj'; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
sub WriteHeader |
||||
{ |
||||
my ($self, $f) = @_; |
||||
|
||||
print $f <<EOF; |
||||
<?xml version="1.0" encoding="Windows-1252"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
EOF |
||||
$self->WriteConfigurationHeader($f, 'Debug'); |
||||
$self->WriteConfigurationHeader($f, 'Release'); |
||||
print $f <<EOF; |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<ProjectGuid>$self->{guid}</ProjectGuid> |
||||
</PropertyGroup> |
||||
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> |
||||
EOF |
||||
$self->WriteConfigurationPropertyGroup($f, 'Release',{ wholeopt=>'false' }); |
||||
$self->WriteConfigurationPropertyGroup($f, 'Debug',{ wholeopt=>'false' }); |
||||
print $f <<EOF; |
||||
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
EOF |
||||
$self->WritePropertySheetsPropertyGroup($f, 'Release'); |
||||
$self->WritePropertySheetsPropertyGroup($f, 'Debug'); |
||||
print $f <<EOF; |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<PropertyGroup> |
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> |
||||
EOF |
||||
$self->WriteAdditionalProperties($f, 'Debug'); |
||||
$self->WriteAdditionalProperties($f, 'Release'); |
||||
print $f <<EOF; |
||||
</PropertyGroup> |
||||
EOF |
||||
$self->WriteItemDefinitionGroup( |
||||
$f, 'Debug', |
||||
{ |
||||
defs=>'_DEBUG;DEBUG=1;', |
||||
opt=>'Disabled', |
||||
strpool=>'false', |
||||
runtime=>'MultiThreadedDebugDLL' |
||||
} |
||||
); |
||||
$self->WriteItemDefinitionGroup($f, 'Release', |
||||
{ defs=>'', opt=>'Full', strpool=>'true', runtime=>'MultiThreadedDLL' }); |
||||
} |
||||
|
||||
sub AddDefine |
||||
{ |
||||
my ($self, $def) = @_; |
||||
|
||||
$self->{defines} .= $def . ';'; |
||||
} |
||||
|
||||
sub WriteReferences |
||||
{ |
||||
my ($self, $f) = @_; |
||||
|
||||
my @references = @{$self->{references}}; |
||||
|
||||
if (scalar(@references)) |
||||
{ |
||||
print $f <<EOF; |
||||
<ItemGroup> |
||||
EOF |
||||
foreach my $ref (@references) |
||||
{ |
||||
print $f <<EOF; |
||||
<ProjectReference Include="$ref->{name}$ref->{filenameExtension}"> |
||||
<Project>$ref->{guid}</Project> |
||||
</ProjectReference> |
||||
EOF |
||||
} |
||||
print $f <<EOF; |
||||
</ItemGroup> |
||||
EOF |
||||
} |
||||
} |
||||
|
||||
sub WriteFiles |
||||
{ |
||||
my ($self, $f) = @_; |
||||
print $f <<EOF; |
||||
<ItemGroup> |
||||
EOF |
||||
my @grammarFiles = (); |
||||
my @resourceFiles = (); |
||||
my %uniquefiles; |
||||
foreach my $fileNameWithPath (sort keys %{ $self->{files} }) |
||||
{ |
||||
confess "Bad format filename '$fileNameWithPath'\n" |
||||
unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); |
||||
my $dir = $1; |
||||
my $fileName = $2; |
||||
if ($fileNameWithPath =~ /\.y$/ or $fileNameWithPath =~ /\.l$/) |
||||
{ |
||||
push @grammarFiles, $fileNameWithPath; |
||||
} |
||||
elsif ($fileNameWithPath =~ /\.rc$/) |
||||
{ |
||||
push @resourceFiles, $fileNameWithPath; |
||||
} |
||||
elsif (defined($uniquefiles{$fileName})) |
||||
{ |
||||
|
||||
# File already exists, so fake a new name |
||||
my $obj = $dir; |
||||
$obj =~ s/\\/_/g; |
||||
|
||||
print $f <<EOF; |
||||
<ClCompile Include="$fileNameWithPath"> |
||||
<ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">.\\debug\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName> |
||||
<ObjectFileName Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">.\\release\\$self->{name}\\${obj}_$fileName.obj</ObjectFileName> |
||||
</ClCompile> |
||||
EOF |
||||
} |
||||
else |
||||
{ |
||||
$uniquefiles{$fileName} = 1; |
||||
print $f <<EOF; |
||||
<ClCompile Include="$fileNameWithPath" /> |
||||
EOF |
||||
} |
||||
|
||||
} |
||||
print $f <<EOF; |
||||
</ItemGroup> |
||||
EOF |
||||
if (scalar(@grammarFiles)) |
||||
{ |
||||
print $f <<EOF; |
||||
<ItemGroup> |
||||
EOF |
||||
foreach my $grammarFile (@grammarFiles) |
||||
{ |
||||
(my $outputFile = $grammarFile) =~ s/\.(y|l)$/.c/; |
||||
if ($grammarFile =~ /\.y$/) |
||||
{ |
||||
$outputFile =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; |
||||
print $f <<EOF; |
||||
<CustomBuild Include="$grammarFile"> |
||||
<Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running bison on $grammarFile</Message> |
||||
<Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgbison.pl" "$grammarFile"</Command> |
||||
<AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs> |
||||
<Outputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">$outputFile;%(Outputs)</Outputs> |
||||
<Message Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">Running bison on $grammarFile</Message> |
||||
<Command Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">perl "src\\tools\\msvc\\pgbison.pl" "$grammarFile"</Command> |
||||
<AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs> |
||||
<Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs> |
||||
</CustomBuild> |
||||
EOF |
||||
} |
||||
else #if ($grammarFile =~ /\.l$/) |
||||
{ |
||||
print $f <<EOF; |
||||
<CustomBuild Include="$grammarFile"> |
||||
<Message Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">Running flex on $grammarFile</Message> |
||||
<Command Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">perl "src\\tools\\msvc\\pgflex.pl" "$grammarFile"</Command> |
||||
<AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs> |
||||
<Outputs Condition="'\$(Configuration)|\$(Platform)'=='Debug|$self->{platform}'">$outputFile;%(Outputs)</Outputs> |
||||
<Message Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">Running flex on $grammarFile</Message> |
||||
<Command Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">perl "src\\tools\\msvc\\pgflex.pl" "$grammarFile"</Command> |
||||
<AdditionalInputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">%(AdditionalInputs)</AdditionalInputs> |
||||
<Outputs Condition="'\$(Configuration)|\$(Platform)'=='Release|$self->{platform}'">$outputFile;%(Outputs)</Outputs> |
||||
</CustomBuild> |
||||
EOF |
||||
} |
||||
} |
||||
print $f <<EOF; |
||||
</ItemGroup> |
||||
EOF |
||||
} |
||||
if (scalar(@resourceFiles)) |
||||
{ |
||||
print $f <<EOF; |
||||
<ItemGroup> |
||||
EOF |
||||
foreach my $rcFile (@resourceFiles) |
||||
{ |
||||
print $f <<EOF; |
||||
<ResourceCompile Include="$rcFile" /> |
||||
EOF |
||||
} |
||||
print $f <<EOF; |
||||
</ItemGroup> |
||||
EOF |
||||
} |
||||
} |
||||
|
||||
sub WriteConfigurationHeader |
||||
{ |
||||
my ($self, $f, $cfgname) = @_; |
||||
print $f <<EOF; |
||||
<ProjectConfiguration Include="$cfgname|$self->{platform}"> |
||||
<Configuration>$cfgname</Configuration> |
||||
<Platform>$self->{platform}</Platform> |
||||
</ProjectConfiguration> |
||||
EOF |
||||
} |
||||
|
||||
sub WriteConfigurationPropertyGroup |
||||
{ |
||||
my ($self, $f, $cfgname, $p) = @_; |
||||
my $cfgtype = |
||||
($self->{type} eq "exe") |
||||
?'Application' |
||||
:($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); |
||||
|
||||
print $f <<EOF; |
||||
<PropertyGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="Configuration"> |
||||
<ConfigurationType>$cfgtype</ConfigurationType> |
||||
<UseOfMfc>false</UseOfMfc> |
||||
<CharacterSet>MultiByte</CharacterSet> |
||||
<WholeProgramOptimization>$p->{wholeopt}</WholeProgramOptimization> |
||||
</PropertyGroup> |
||||
EOF |
||||
} |
||||
|
||||
sub WritePropertySheetsPropertyGroup |
||||
{ |
||||
my ($self, $f, $cfgname) = @_; |
||||
print $f <<EOF; |
||||
<ImportGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'" Label="PropertySheets"> |
||||
<Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
EOF |
||||
} |
||||
|
||||
sub WriteAdditionalProperties |
||||
{ |
||||
my ($self, $f, $cfgname) = @_; |
||||
print $f <<EOF; |
||||
<OutDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</OutDir> |
||||
<IntDir Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">.\\$cfgname\\$self->{name}\\</IntDir> |
||||
<LinkIncremental Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'">false</LinkIncremental> |
||||
EOF |
||||
} |
||||
|
||||
sub WriteItemDefinitionGroup |
||||
{ |
||||
my ($self, $f, $cfgname, $p) = @_; |
||||
my $cfgtype = |
||||
($self->{type} eq "exe") |
||||
?'Application' |
||||
:($self->{type} eq "dll"?'DynamicLibrary':'StaticLibrary'); |
||||
my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ';'); |
||||
|
||||
my $targetmachine = $self->{platform} eq 'Win32' ? 'MachineX86' : 'MachineX64'; |
||||
|
||||
my $includes = $self->{includes}; |
||||
unless ($includes eq '' or $includes =~ /;$/) |
||||
{ |
||||
$includes .= ';'; |
||||
} |
||||
print $f <<EOF; |
||||
<ItemDefinitionGroup Condition="'\$(Configuration)|\$(Platform)'=='$cfgname|$self->{platform}'"> |
||||
<ClCompile> |
||||
<Optimization>$p->{opt}</Optimization> |
||||
<AdditionalIncludeDirectories>$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$includes\%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}\%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<StringPooling>$p->{strpool}</StringPooling> |
||||
<RuntimeLibrary>$p->{runtime}</RuntimeLibrary> |
||||
<DisableSpecificWarnings>$self->{disablewarnings};\%(DisableSpecificWarnings)</DisableSpecificWarnings> |
||||
<AdditionalOptions>/MP \%(AdditionalOptions)</AdditionalOptions> |
||||
<AssemblerOutput> |
||||
</AssemblerOutput> |
||||
<AssemblerListingLocation>.\\$cfgname\\$self->{name}\\</AssemblerListingLocation> |
||||
<ObjectFileName>.\\$cfgname\\$self->{name}\\</ObjectFileName> |
||||
<ProgramDataBaseFileName>.\\$cfgname\\$self->{name}\\</ProgramDataBaseFileName> |
||||
<BrowseInformation>false</BrowseInformation> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<SuppressStartupBanner>true</SuppressStartupBanner> |
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> |
||||
<CompileAs>Default</CompileAs> |
||||
</ClCompile> |
||||
<Link> |
||||
<OutputFile>.\\$cfgname\\$self->{name}\\$self->{name}.$self->{type}</OutputFile> |
||||
<AdditionalDependencies>$libs;\%(AdditionalDependencies)</AdditionalDependencies> |
||||
<SuppressStartupBanner>true</SuppressStartupBanner> |
||||
<AdditionalLibraryDirectories>\%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
<IgnoreSpecificDefaultLibraries>libc;\%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> |
||||
<StackReserveSize>4194304</StackReserveSize> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<ProgramDatabaseFile>.\\$cfgname\\$self->{name}\\$self->{name}.pdb</ProgramDatabaseFile> |
||||
<GenerateMapFile>false</GenerateMapFile> |
||||
<MapFileName>.\\$cfgname\\$self->{name}\\$self->{name}.map</MapFileName> |
||||
<SubSystem>Console</SubSystem> |
||||
<TargetMachine>$targetmachine</TargetMachine> |
||||
EOF |
||||
if ($self->{disablelinkerwarnings}) |
||||
{ |
||||
print $f |
||||
" <AdditionalOptions>/ignore:$self->{disablelinkerwarnings} \%(AdditionalOptions)</AdditionalOptions>\n"; |
||||
} |
||||
if ($self->{implib}) |
||||
{ |
||||
my $l = $self->{implib}; |
||||
$l =~ s/__CFGNAME__/$cfgname/g; |
||||
print $f " <ImportLibrary>$l</ImportLibrary>\n"; |
||||
} |
||||
if ($self->{def}) |
||||
{ |
||||
my $d = $self->{def}; |
||||
$d =~ s/__CFGNAME__/$cfgname/g; |
||||
print $f " <ModuleDefinitionFile>$d</ModuleDefinitionFile>\n"; |
||||
} |
||||
print $f <<EOF; |
||||
</Link> |
||||
<ResourceCompile> |
||||
<AdditionalIncludeDirectories>src\\include;\%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
</ResourceCompile> |
||||
EOF |
||||
if ($self->{builddef}) |
||||
{ |
||||
print $f <<EOF; |
||||
<PreLinkEvent> |
||||
<Message>Generate DEF file</Message> |
||||
<Command>perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}</Command> |
||||
</PreLinkEvent> |
||||
EOF |
||||
} |
||||
print $f <<EOF; |
||||
</ItemDefinitionGroup> |
||||
EOF |
||||
} |
||||
|
||||
sub Footer |
||||
{ |
||||
my ($self, $f) = @_; |
||||
$self->WriteReferences($f); |
||||
|
||||
print $f <<EOF; |
||||
<Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
</ImportGroup> |
||||
</Project> |
||||
EOF |
||||
} |
||||
|
||||
package VC2010Project; |
||||
|
||||
# |
||||
# Package that encapsulates a Visual C++ 2010 project file |
||||
# |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use base qw(MSBuildProject); |
||||
|
||||
sub new |
||||
{ |
||||
my $classname = shift; |
||||
my $self = $classname->SUPER::_new(@_); |
||||
bless($self, $classname); |
||||
|
||||
$self->{vcver} = '10.00'; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
1; |
@ -0,0 +1,267 @@ |
||||
package VCBuildProject; |
||||
|
||||
# |
||||
# Package that encapsulates a VCBuild (Visual C++ 2005/2008) project file |
||||
# |
||||
# src/tools/msvc/VCBuildProject.pm |
||||
# |
||||
|
||||
use Carp; |
||||
use strict; |
||||
use warnings; |
||||
use base qw(Project); |
||||
|
||||
sub _new |
||||
{ |
||||
my $classname = shift; |
||||
my $self = $classname->SUPER::_new(@_); |
||||
bless($self, $classname); |
||||
|
||||
$self->{filenameExtension} = '.vcproj'; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
sub WriteHeader |
||||
{ |
||||
my ($self, $f) = @_; |
||||
|
||||
print $f <<EOF; |
||||
<?xml version="1.0" encoding="Windows-1252"?> |
||||
<VisualStudioProject ProjectType="Visual C++" Version="$self->{vcver}" Name="$self->{name}" ProjectGUID="$self->{guid}"> |
||||
<Platforms><Platform Name="$self->{platform}"/></Platforms> |
||||
<Configurations> |
||||
EOF |
||||
$self->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; |
||||
</Configurations> |
||||
EOF |
||||
$self->WriteReferences($f); |
||||
} |
||||
|
||||
sub WriteFiles |
||||
{ |
||||
my ($self, $f) = @_; |
||||
print $f <<EOF; |
||||
<Files> |
||||
EOF |
||||
my @dirstack = (); |
||||
my %uniquefiles; |
||||
foreach my $fileNameWithPath (sort keys %{ $self->{files} }) |
||||
{ |
||||
confess "Bad format filename '$fileNameWithPath'\n" |
||||
unless ($fileNameWithPath =~ /^(.*)\\([^\\]+)\.[r]?[cyl]$/); |
||||
my $dir = $1; |
||||
my $file = $2; |
||||
|
||||
# Walk backwards down the directory stack and close any dirs we're done with |
||||
while ($#dirstack >= 0) |
||||
{ |
||||
if (join('\\',@dirstack) eq substr($dir, 0, length(join('\\',@dirstack)))) |
||||
{ |
||||
last if (length($dir) == length(join('\\',@dirstack))); |
||||
last if (substr($dir, length(join('\\',@dirstack)),1) eq '\\'); |
||||
} |
||||
print $f ' ' x $#dirstack . " </Filter>\n"; |
||||
pop @dirstack; |
||||
} |
||||
|
||||
# Now walk forwards and create whatever directories are needed |
||||
while (join('\\',@dirstack) ne $dir) |
||||
{ |
||||
my $left = substr($dir, length(join('\\',@dirstack))); |
||||
$left =~ s/^\\//; |
||||
my @pieces = split /\\/, $left; |
||||
push @dirstack, $pieces[0]; |
||||
print $f ' ' x $#dirstack . " <Filter Name=\"$pieces[0]\" Filter=\"\">\n"; |
||||
} |
||||
|
||||
print $f ' ' x $#dirstack . " <File RelativePath=\"$fileNameWithPath\""; |
||||
if ($fileNameWithPath =~ /\.y$/) |
||||
{ |
||||
my $of = $fileNameWithPath; |
||||
$of =~ s/\.y$/.c/; |
||||
$of =~ s{^src\\pl\\plpgsql\\src\\gram.c$}{src\\pl\\plpgsql\\src\\pl_gram.c}; |
||||
print $f '>' |
||||
. $self->GenerateCustomTool('Running bison on ' . $fileNameWithPath, |
||||
"perl src\\tools\\msvc\\pgbison.pl $fileNameWithPath", $of) |
||||
. '</File>' . "\n"; |
||||
} |
||||
elsif ($fileNameWithPath =~ /\.l$/) |
||||
{ |
||||
my $of = $fileNameWithPath; |
||||
$of =~ s/\.l$/.c/; |
||||
print $f '>' |
||||
. $self->GenerateCustomTool('Running flex on ' . $fileNameWithPath, |
||||
"perl src\\tools\\msvc\\pgflex.pl $fileNameWithPath", $of) |
||||
. '</File>' . "\n"; |
||||
} |
||||
elsif (defined($uniquefiles{$file})) |
||||
{ |
||||
|
||||
# File already exists, so fake a new name |
||||
my $obj = $dir; |
||||
$obj =~ s/\\/_/g; |
||||
print $f |
||||
"><FileConfiguration Name=\"Debug|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\debug\\$self->{name}\\$obj" |
||||
. "_$file.obj\" /></FileConfiguration><FileConfiguration Name=\"Release|$self->{platform}\"><Tool Name=\"VCCLCompilerTool\" ObjectFile=\".\\release\\$self->{name}\\$obj" |
||||
. "_$file.obj\" /></FileConfiguration></File>\n"; |
||||
} |
||||
else |
||||
{ |
||||
$uniquefiles{$file} = 1; |
||||
print $f " />\n"; |
||||
} |
||||
} |
||||
while ($#dirstack >= 0) |
||||
{ |
||||
print $f ' ' x $#dirstack . " </Filter>\n"; |
||||
pop @dirstack; |
||||
} |
||||
print $f <<EOF; |
||||
</Files> |
||||
EOF |
||||
} |
||||
|
||||
sub Footer |
||||
{ |
||||
my ($self, $f) = @_; |
||||
|
||||
print $f <<EOF; |
||||
<Globals/> |
||||
</VisualStudioProject> |
||||
EOF |
||||
} |
||||
|
||||
sub WriteConfiguration |
||||
{ |
||||
my ($self, $f, $cfgname, $p) = @_; |
||||
my $cfgtype = ($self->{type} eq "exe")?1:($self->{type} eq "dll"?2:4); |
||||
my $libs = $self->GetAdditionalLinkerDependencies($cfgname, ' '); |
||||
|
||||
my $targetmachine = $self->{platform} eq 'Win32' ? 1 : 17; |
||||
|
||||
print $f <<EOF; |
||||
<Configuration Name="$cfgname|$self->{platform}" OutputDirectory=".\\$cfgname\\$self->{name}" IntermediateDirectory=".\\$cfgname\\$self->{name}" |
||||
ConfigurationType="$cfgtype" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="FALSE" CharacterSet="2" WholeProgramOptimization="$p->{wholeopt}"> |
||||
<Tool Name="VCCLCompilerTool" Optimization="$p->{opt}" |
||||
AdditionalIncludeDirectories="$self->{prefixincludes}src/include;src/include/port/win32;src/include/port/win32_msvc;$self->{includes}" |
||||
PreprocessorDefinitions="WIN32;_WINDOWS;__WINDOWS__;__WIN32__;EXEC_BACKEND;WIN32_STACK_RLIMIT=4194304;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE$self->{defines}$p->{defs}" |
||||
StringPooling="$p->{strpool}" |
||||
RuntimeLibrary="$p->{runtime}" DisableSpecificWarnings="$self->{disablewarnings}" |
||||
AdditionalOptions="/MP" |
||||
EOF |
||||
print $f <<EOF; |
||||
AssemblerOutput="0" AssemblerListingLocation=".\\$cfgname\\$self->{name}\\" ObjectFile=".\\$cfgname\\$self->{name}\\" |
||||
ProgramDataBaseFileName=".\\$cfgname\\$self->{name}\\" BrowseInformation="0" |
||||
WarningLevel="3" SuppressStartupBanner="TRUE" DebugInformationFormat="3" CompileAs="0"/> |
||||
<Tool Name="VCLinkerTool" OutputFile=".\\$cfgname\\$self->{name}\\$self->{name}.$self->{type}" |
||||
AdditionalDependencies="$libs" |
||||
LinkIncremental="0" SuppressStartupBanner="TRUE" AdditionalLibraryDirectories="" IgnoreDefaultLibraryNames="libc" |
||||
StackReserveSize="4194304" DisableSpecificWarnings="$self->{disablewarnings}" |
||||
GenerateDebugInformation="TRUE" ProgramDatabaseFile=".\\$cfgname\\$self->{name}\\$self->{name}.pdb" |
||||
GenerateMapFile="FALSE" MapFileName=".\\$cfgname\\$self->{name}\\$self->{name}.map" |
||||
SubSystem="1" TargetMachine="$targetmachine" |
||||
EOF |
||||
if ($self->{disablelinkerwarnings}) |
||||
{ |
||||
print $f "\t\tAdditionalOptions=\"/ignore:$self->{disablelinkerwarnings}\"\n"; |
||||
} |
||||
if ($self->{implib}) |
||||
{ |
||||
my $l = $self->{implib}; |
||||
$l =~ s/__CFGNAME__/$cfgname/g; |
||||
print $f "\t\tImportLibrary=\"$l\"\n"; |
||||
} |
||||
if ($self->{def}) |
||||
{ |
||||
my $d = $self->{def}; |
||||
$d =~ s/__CFGNAME__/$cfgname/g; |
||||
print $f "\t\tModuleDefinitionFile=\"$d\"\n"; |
||||
} |
||||
|
||||
print $f "\t/>\n"; |
||||
print $f |
||||
"\t<Tool Name=\"VCLibrarianTool\" OutputFile=\".\\$cfgname\\$self->{name}\\$self->{name}.lib\" IgnoreDefaultLibraryNames=\"libc\" />\n"; |
||||
print $f |
||||
"\t<Tool Name=\"VCResourceCompilerTool\" AdditionalIncludeDirectories=\"src\\include\" />\n"; |
||||
if ($self->{builddef}) |
||||
{ |
||||
print $f |
||||
"\t<Tool Name=\"VCPreLinkEventTool\" Description=\"Generate DEF file\" CommandLine=\"perl src\\tools\\msvc\\gendef.pl $cfgname\\$self->{name} $self->{platform}\" />\n"; |
||||
} |
||||
print $f <<EOF; |
||||
</Configuration> |
||||
EOF |
||||
} |
||||
|
||||
sub WriteReferences |
||||
{ |
||||
my ($self, $f) = @_; |
||||
print $f " <References>\n"; |
||||
foreach my $ref (@{$self->{references}}) |
||||
{ |
||||
print $f |
||||
" <ProjectReference ReferencedProjectIdentifier=\"$ref->{guid}\" Name=\"$ref->{name}\" />\n"; |
||||
} |
||||
print $f " </References>\n"; |
||||
} |
||||
|
||||
sub GenerateCustomTool |
||||
{ |
||||
my ($self, $desc, $tool, $output, $cfg) = @_; |
||||
if (!defined($cfg)) |
||||
{ |
||||
return $self->GenerateCustomTool($desc, $tool, $output, 'Debug') |
||||
.$self->GenerateCustomTool($desc, $tool, $output, 'Release'); |
||||
} |
||||
return |
||||
"<FileConfiguration Name=\"$cfg|$self->{platform}\"><Tool Name=\"VCCustomBuildTool\" Description=\"$desc\" CommandLine=\"$tool\" AdditionalDependencies=\"\" Outputs=\"$output\" /></FileConfiguration>"; |
||||
} |
||||
|
||||
package VC2005Project; |
||||
|
||||
# |
||||
# Package that encapsulates a Visual C++ 2005 project file |
||||
# |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use base qw(VCBuildProject); |
||||
|
||||
sub new |
||||
{ |
||||
my $classname = shift; |
||||
my $self = $classname->SUPER::_new(@_); |
||||
bless($self, $classname); |
||||
|
||||
$self->{vcver} = '8.00'; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
package VC2008Project; |
||||
|
||||
# |
||||
# Package that encapsulates a Visual C++ 2008 project file |
||||
# |
||||
|
||||
use strict; |
||||
use warnings; |
||||
use base qw(VCBuildProject); |
||||
|
||||
sub new |
||||
{ |
||||
my $classname = shift; |
||||
my $self = $classname->SUPER::_new(@_); |
||||
bless($self, $classname); |
||||
|
||||
$self->{vcver} = '9.00'; |
||||
|
||||
return $self; |
||||
} |
||||
|
||||
1; |
@ -0,0 +1,122 @@ |
||||
package VSObjectFactory; |
||||
|
||||
# |
||||
# Package that creates Visual Studio wrapper objects for msvc build |
||||
# |
||||
# src/tools/msvc/VSObjectFactory.pm |
||||
# |
||||
|
||||
use Carp; |
||||
use strict; |
||||
use warnings; |
||||
|
||||
use Exporter; |
||||
use Project; |
||||
use Solution; |
||||
use VCBuildProject; |
||||
use MSBuildProject; |
||||
|
||||
our (@ISA, @EXPORT); |
||||
@ISA = qw(Exporter); |
||||
@EXPORT = qw(CreateSolution CreateProject DetermineVisualStudioVersion); |
||||
|
||||
sub CreateSolution |
||||
{ |
||||
my $visualStudioVersion = shift; |
||||
|
||||
if (!defined($visualStudioVersion)) |
||||
{ |
||||
$visualStudioVersion = DetermineVisualStudioVersion(); |
||||
} |
||||
|
||||
if ($visualStudioVersion eq '8.00') |
||||
{ |
||||
return new VS2005Solution(@_); |
||||
} |
||||
elsif ($visualStudioVersion eq '9.00') |
||||
{ |
||||
return new VS2008Solution(@_); |
||||
} |
||||
elsif ($visualStudioVersion eq '10.00') |
||||
{ |
||||
return new VS2010Solution(@_); |
||||
} |
||||
else |
||||
{ |
||||
croak "The requested Visual Studio version is not supported."; |
||||
} |
||||
} |
||||
|
||||
sub CreateProject |
||||
{ |
||||
my $visualStudioVersion = shift; |
||||
|
||||
if (!defined($visualStudioVersion)) |
||||
{ |
||||
$visualStudioVersion = DetermineVisualStudioVersion(); |
||||
} |
||||
|
||||
if ($visualStudioVersion eq '8.00') |
||||
{ |
||||
return new VC2005Project(@_); |
||||
} |
||||
elsif ($visualStudioVersion eq '9.00') |
||||
{ |
||||
return new VC2008Project(@_); |
||||
} |
||||
elsif ($visualStudioVersion eq '10.00') |
||||
{ |
||||
return new VC2010Project(@_); |
||||
} |
||||
else |
||||
{ |
||||
croak "The requested Visual Studio version is not supported."; |
||||
} |
||||
} |
||||
|
||||
sub DetermineVisualStudioVersion |
||||
{ |
||||
my $nmakeVersion = shift; |
||||
|
||||
if (!defined($nmakeVersion)) |
||||
{ |
||||
|
||||
# Determine version of nmake command, to set proper verison of visual studio |
||||
# we use nmake as it has existed for a long time and still exists in visual studio 2010 |
||||
open(P,"nmake /? 2>&1 |") |
||||
|| croak "Unable to determine Visual Studio version: The nmake command wasn't found."; |
||||
while(<P>) |
||||
{ |
||||
chomp; |
||||
if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/) |
||||
{ |
||||
return _GetVisualStudioVersion($1, $2); |
||||
} |
||||
} |
||||
close(P); |
||||
} |
||||
elsif($nmakeVersion =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/) |
||||
{ |
||||
return _GetVisualStudioVersion($1, $2); |
||||
} |
||||
croak "Unable to determine Visual Studio version: The nmake version could not be determined."; |
||||
} |
||||
|
||||
sub _GetVisualStudioVersion |
||||
{ |
||||
my($major, $minor) = @_; |
||||
if ($major > 10) |
||||
{ |
||||
carp |
||||
"The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead."; |
||||
return '10.00'; |
||||
} |
||||
elsif ($major < 6) |
||||
{ |
||||
croak |
||||
"Unable to determine Visual Studio version: Visual Studio versions before 6.0 aren't supported."; |
||||
} |
||||
return "$major.$minor"; |
||||
} |
||||
|
||||
1; |
Loading…
Reference in new issue