summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorAndrew Dunstan2013-02-06 19:52:29 +0000
committerAndrew Dunstan2013-02-06 19:52:29 +0000
commite1c1e2173248f39c1b15fca7b2a31ad7b5199ce7 (patch)
treedb58fc5d34d7812a88b144ce4f573fe74406e402 /src/tools
parent5a1cd89f8f4a0bc13c85810de47d48bb6386ea89 (diff)
Enable building with Microsoft Visual Studio 2012.
Backpatch to release 9.2 Brar Piening and Noah Misch, reviewed by Craig Ringer.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/msvc/MSBuildProject.pm44
-rw-r--r--src/tools/msvc/README9
-rw-r--r--src/tools/msvc/Solution.pm31
-rw-r--r--src/tools/msvc/VSObjectFactory.pm14
-rw-r--r--src/tools/msvc/build.pl2
-rw-r--r--src/tools/msvc/gendef.pl1
6 files changed, 88 insertions, 13 deletions
diff --git a/src/tools/msvc/MSBuildProject.pm b/src/tools/msvc/MSBuildProject.pm
index 2e3eab6599d..0cafd717a2b 100644
--- a/src/tools/msvc/MSBuildProject.pm
+++ b/src/tools/msvc/MSBuildProject.pm
@@ -1,7 +1,7 @@
package MSBuildProject;
#
-# Package that encapsulates a MSBuild (Visual C++ 2010) project file
+# Package that encapsulates a MSBuild project file (Visual C++ 2010 or greater)
#
# src/tools/msvc/MSBuildProject.pm
#
@@ -397,4 +397,46 @@ sub new
return $self;
}
+package VC2012Project;
+
+#
+# Package that encapsulates a Visual C++ 2012 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} = '11.00';
+
+ return $self;
+}
+
+# This override adds the <PlatformToolset> element
+# to the PropertyGroup labeled "Configuration"
+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>
+ <PlatformToolset>v110</PlatformToolset>
+ </PropertyGroup>
+EOF
+}
+
1;
diff --git a/src/tools/msvc/README b/src/tools/msvc/README
index 3b2939ad686..b61ddb87913 100644
--- a/src/tools/msvc/README
+++ b/src/tools/msvc/README
@@ -92,10 +92,11 @@ These configuration arguments are passed over to Mkvcbuild::mkvcbuild
(Mkvcbuild.pm) which creates the Visual Studio project and solution files.
It does this by using VSObjectFactory::CreateSolution to create an object
implementing the Solution interface (this could be either a VS2005Solution,
-a VS2008Solution or a VS2010Solution, all in Solution.pm, depending on the
-user's build environment) and adding objects implementing the corresponding
-Project interface (VC2005Project or VC2008Project from VCBuildProject.pm or
-VC2010Project from MSBuildProject.pm) to it.
+a VS2008Solution, a VS2010Solution or a VS2012Solution, all in Solution.pm,
+depending on the user's build environment) and adding objects implementing
+the corresponding Project interface (VC2005Project or VC2008Project from
+VCBuildProject.pm or VC2010Project or VC2012Project from MSBuildProject.pm)
+to it.
When Solution::Save is called, the implementations of Solution and Project
save their content in the appropriate format.
The final step of starting the appropriate build program (msbuild or vcbuild)
diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm
index 850a1dfabcf..e271ac8d9be 100644
--- a/src/tools/msvc/Solution.pm
+++ b/src/tools/msvc/Solution.pm
@@ -63,13 +63,12 @@ sub DeterminePlatform
{
my $self = shift;
- # Determine if we are in 32 or 64-bit mode. Do this by seeing if CL has
- # 64-bit only parameters.
+ # Examine CL help output to determine if we are in 32 or 64-bit mode.
$self->{platform} = 'Win32';
- open(P, "cl /? 2>NUL|") || die "cl command not found";
+ open(P, "cl /? 2>&1 |") || die "cl command not found";
while (<P>)
{
- if (/^\/favor:</)
+ if (/^\/favor:<.+AMD64/)
{
$self->{platform} = 'x64';
last;
@@ -700,4 +699,28 @@ sub new
return $self;
}
+package VS2012Solution;
+
+#
+# Package that encapsulates a Visual Studio 2012 solution file
+#
+
+use Carp;
+use strict;
+use warnings;
+use base qw(Solution);
+
+sub new
+{
+ my $classname = shift;
+ my $self = $classname->SUPER::_new(@_);
+ bless($self, $classname);
+
+ $self->{solutionFileVersion} = '12.00';
+ $self->{vcver} = '11.00';
+ $self->{visualStudioName} = 'Visual Studio 2012';
+
+ return $self;
+}
+
1;
diff --git a/src/tools/msvc/VSObjectFactory.pm b/src/tools/msvc/VSObjectFactory.pm
index c3aa33ec24f..0fbf3faa0ed 100644
--- a/src/tools/msvc/VSObjectFactory.pm
+++ b/src/tools/msvc/VSObjectFactory.pm
@@ -41,6 +41,10 @@ sub CreateSolution
{
return new VS2010Solution(@_);
}
+ elsif ($visualStudioVersion eq '11.00')
+ {
+ return new VS2012Solution(@_);
+ }
else
{
croak "The requested Visual Studio version is not supported.";
@@ -68,6 +72,10 @@ sub CreateProject
{
return new VC2010Project(@_);
}
+ elsif ($visualStudioVersion eq '11.00')
+ {
+ return new VC2012Project(@_);
+ }
else
{
croak "The requested Visual Studio version is not supported.";
@@ -82,7 +90,7 @@ sub DetermineVisualStudioVersion
{
# Determine version of nmake command, to set proper version of visual studio
-# we use nmake as it has existed for a long time and still exists in visual studio 2010
+# we use nmake as it has existed for a long time and still exists in current visual studio versions
open(P, "nmake /? 2>&1 |")
|| croak
"Unable to determine Visual Studio version: The nmake command wasn't found.";
@@ -107,11 +115,11 @@ sub DetermineVisualStudioVersion
sub _GetVisualStudioVersion
{
my ($major, $minor) = @_;
- if ($major > 10)
+ if ($major > 11)
{
carp
"The determined version of Visual Studio is newer than the latest supported version. Returning the latest supported version instead.";
- return '10.00';
+ return '11.00';
}
elsif ($major < 6)
{
diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl
index 8979402d4c1..c947bbe318e 100644
--- a/src/tools/msvc/build.pl
+++ b/src/tools/msvc/build.pl
@@ -50,7 +50,7 @@ elsif ($ARGV[0] ne "RELEASE")
# ... and do it
-if ($buildwhat and $vcver eq '10.00')
+if ($buildwhat and $vcver >= 10.00)
{
system(
"msbuild $buildwhat.vcxproj /verbosity:detailed /p:Configuration=$bconf");
diff --git a/src/tools/msvc/gendef.pl b/src/tools/msvc/gendef.pl
index ab65c46cfae..8ef0422df9d 100644
--- a/src/tools/msvc/gendef.pl
+++ b/src/tools/msvc/gendef.pl
@@ -40,6 +40,7 @@ while (<$ARGV[0]/*.obj>)
next if $pieces[6] =~ /^\(/;
next if $pieces[6] =~ /^__real/;
next if $pieces[6] =~ /^__imp/;
+ next if $pieces[6] =~ /^__xmm/;
next if $pieces[6] =~ /NULL_THUNK_DATA$/;
next if $pieces[6] =~ /^__IMPORT_DESCRIPTOR/;
next if $pieces[6] =~ /^__NULL_IMPORT/;