Skip to content

Commit 1e9d3e6

Browse files
ryzokukentargos
authored andcommitted
gyp: muffle xcodebuild warnings
Muffle xcodebuild warnings by introducing an alternative quieter alternative to GetStdout, called GetStdoutQuiet, and call it selectively in particularly noisy xcodebuild commands. Co-authored-by: Gibson Fahnestock <[email protected]> PR-URL: #21999 Original-PR-URL: nodejs/node-gyp#1370 Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 6f31478 commit 1e9d3e6

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

tools/gyp/pylib/gyp/xcode_emulation.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def _GetSdkVersionInfoItem(self, sdk, infoitem):
495495
# Since the CLT has no SDK paths anyway, returning None is the
496496
# most sensible route and should still do the right thing.
497497
try:
498-
return GetStdout(['xcrun', '--sdk', sdk, infoitem])
498+
return GetStdoutQuiet(['xcrun', '--sdk', sdk, infoitem])
499499
except:
500500
pass
501501

@@ -1394,7 +1394,7 @@ def XcodeVersion():
13941394
if XCODE_VERSION_CACHE:
13951395
return XCODE_VERSION_CACHE
13961396
try:
1397-
version_list = GetStdout(['xcodebuild', '-version']).splitlines()
1397+
version_list = GetStdoutQuiet(['xcodebuild', '-version']).splitlines()
13981398
# In some circumstances xcodebuild exits 0 but doesn't return
13991399
# the right results; for example, a user on 10.7 or 10.8 with
14001400
# a bogus path set via xcode-select
@@ -1444,6 +1444,18 @@ def CLTVersion():
14441444
continue
14451445

14461446

1447+
def GetStdoutQuiet(cmdlist):
1448+
"""Returns the content of standard output returned by invoking |cmdlist|.
1449+
Ignores the stderr.
1450+
Raises |GypError| if the command return with a non-zero return code."""
1451+
job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE,
1452+
stderr=subprocess.PIPE)
1453+
out = job.communicate()[0]
1454+
if job.returncode != 0:
1455+
raise GypError('Error %d running %s' % (job.returncode, cmdlist[0]))
1456+
return out.rstrip('\n')
1457+
1458+
14471459
def GetStdout(cmdlist):
14481460
"""Returns the content of standard output returned by invoking |cmdlist|.
14491461
Raises |GypError| if the command return with a non-zero return code."""

0 commit comments

Comments
 (0)