mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Fix Perl coding error in msvc build system
Code like open(P, "cl /? 2>&1 |") || die "cl command not found"; does not actually catch any errors, because the exit status of the command before the pipe is ignored. The fix is to look at $?. This also gave the opportunity to clean up the logic of this code a bit.
This commit is contained in:
parent
9c7dd35019
commit
d30292b8c4
@ -71,17 +71,9 @@ sub DeterminePlatform
|
|||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
# Examine CL help output to determine if we are in 32 or 64-bit mode.
|
# Examine CL help output to determine if we are in 32 or 64-bit mode.
|
||||||
$self->{platform} = 'Win32';
|
my $output = `cl /? 2>&1`;
|
||||||
open(P, "cl /? 2>&1 |") || die "cl command not found";
|
$? >> 8 == 0 or die "cl command not found";
|
||||||
while (<P>)
|
$self->{platform} = ($output =~ /^\/favor:<.+AMD64/m) ? 'x64' : 'Win32';
|
||||||
{
|
|
||||||
if (/^\/favor:<.+AMD64/)
|
|
||||||
{
|
|
||||||
$self->{platform} = 'x64';
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(P);
|
|
||||||
print "Detected hardware platform: $self->{platform}\n";
|
print "Detected hardware platform: $self->{platform}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,30 +92,16 @@ sub CreateProject
|
|||||||
|
|
||||||
sub DetermineVisualStudioVersion
|
sub DetermineVisualStudioVersion
|
||||||
{
|
{
|
||||||
my $nmakeVersion = shift;
|
# To determine version of Visual Studio we use nmake as it has
|
||||||
|
# existed for a long time and still exists in current Visual
|
||||||
if (!defined($nmakeVersion))
|
# Studio versions.
|
||||||
{
|
my $output = `nmake /? 2>&1`;
|
||||||
|
$? >> 8 == 0 or croak "Unable to determine Visual Studio version: The nmake command wasn't found.";
|
||||||
# Determine version of nmake command, to set proper version of visual studio
|
if ($output =~ /(\d+)\.(\d+)\.\d+(\.\d+)?$/m)
|
||||||
# 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+)?$/)
|
|
||||||
{
|
{
|
||||||
return _GetVisualStudioVersion($1, $2);
|
return _GetVisualStudioVersion($1, $2);
|
||||||
}
|
}
|
||||||
|
|
||||||
croak
|
croak
|
||||||
"Unable to determine Visual Studio version: The nmake version could not be determined.";
|
"Unable to determine Visual Studio version: The nmake version could not be determined.";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user