my $self = shift;
# Examine CL help output to determine if we are in 32 or 64-bit mode.
- $self->{platform} = 'Win32';
- open(P, "cl /? 2>&1 |") || die "cl command not found";
- while (<P>)
- {
- if (/^\/favor:<.+AMD64/)
- {
- $self->{platform} = 'x64';
- last;
- }
- }
- close(P);
+ my $output = `cl /? 2>&1`;
+ $? >> 8 == 0 or die "cl command not found";
+ $self->{platform} = ($output =~ /^\/favor:<.+AMD64/m) ? 'x64' : 'Win32';
print "Detected hardware platform: $self->{platform}\n";
}
sub DetermineVisualStudioVersion
{
- my $nmakeVersion = shift;
-
- if (!defined($nmakeVersion))
- {
-
-# 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 current visual studio versions
- 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+)?$/)
+ # To determine version of Visual Studio we use nmake as it has
+ # existed for a long time and still exists in current Visual
+ # Studio versions.
+ my $output = `nmake /? 2>&1`;
+ $? >> 8 == 0 or croak "Unable to determine Visual Studio version: The nmake command wasn't found.";
+ if ($output =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/m)
{
return _GetVisualStudioVersion($1, $2);
}
+
croak
"Unable to determine Visual Studio version: The nmake version could not be determined.";
}