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

Commitd30292b

Browse files
committed
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 thecommand 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.
1 parent9c7dd35 commitd30292b

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

‎src/tools/msvc/Solution.pm

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,9 @@ sub DeterminePlatform
7171
my$self =shift;
7272

7373
# Examine CL help output to determine if we are in 32 or 64-bit mode.
74-
$self->{platform} ='Win32';
75-
open(P,"cl /? 2>&1 |") ||die"cl command not found";
76-
while (<P>)
77-
{
78-
if (/^\/favor:<.+AMD64/)
79-
{
80-
$self->{platform} ='x64';
81-
last;
82-
}
83-
}
84-
close(P);
74+
my$output =`cl /? 2>&1`;
75+
$? >> 8 == 0ordie"cl command not found";
76+
$self->{platform} = ($output =~/^\/favor:<.+AMD64/m) ?'x64' :'Win32';
8577
print"Detected hardware platform:$self->{platform}\n";
8678
}
8779

‎src/tools/msvc/VSObjectFactory.pm

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,16 @@ sub CreateProject
9292

9393
subDetermineVisualStudioVersion
9494
{
95-
my$nmakeVersion =shift;
96-
97-
if (!defined($nmakeVersion))
98-
{
99-
100-
# Determine version of nmake command, to set proper version of visual studio
101-
# we use nmake as it has existed for a long time and still exists in current visual studio versions
102-
open(P,"nmake /? 2>&1 |")
103-
|| croak
104-
"Unable to determine Visual Studio version: The nmake command wasn't found.";
105-
while (<P>)
106-
{
107-
chomp;
108-
if (/(\d+)\.(\d+)\.\d+(\.\d+)?$/)
109-
{
110-
return _GetVisualStudioVersion($1,$2);
111-
}
112-
}
113-
close(P);
114-
}
115-
elsif ($nmakeVersion =~/(\d+)\.(\d+)\.\d+(\.\d+)?$/)
95+
# To determine version of Visual Studio we use nmake as it has
96+
# existed for a long time and still exists in current Visual
97+
# Studio versions.
98+
my$output =`nmake /? 2>&1`;
99+
$? >> 8 == 0or croak"Unable to determine Visual Studio version: The nmake command wasn't found.";
100+
if ($output =~/(\d+)\.(\d+)\.\d+(\.\d+)?$/m)
116101
{
117102
return _GetVisualStudioVersion($1,$2);
118103
}
104+
119105
croak
120106
"Unable to determine Visual Studio version: The nmake version could not be determined.";
121107
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp