From 3a52936d6cae0b35a4bd486017c7c7a88ae0b415 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Sun, 21 Jan 2018 17:59:08 +0000 Subject: [PATCH] gyp: don't print xcodebuild not found errors As node-gyp rebuild doesn't seem to need xcodebuild, we don't need to be printing the error every time GYP is run. PR-URL: https://github.com/nodejs/node-gyp/pull/1370 Fixes: https://github.com/nodejs/node-gyp/issues/569 Refs: https://github.com/nodejs/node-gyp/pull/1057 Refs: https://chromium-review.googlesource.com/c/492046/ --- gyp/pylib/gyp/xcode_emulation.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gyp/pylib/gyp/xcode_emulation.py b/gyp/pylib/gyp/xcode_emulation.py index b06bdc4e8b..2aca1c762d 100644 --- a/gyp/pylib/gyp/xcode_emulation.py +++ b/gyp/pylib/gyp/xcode_emulation.py @@ -429,7 +429,7 @@ def _GetSdkVersionInfoItem(self, sdk, infoitem): # Since the CLT has no SDK paths anyway, returning None is the # most sensible route and should still do the right thing. try: - return GetStdout(['xcodebuild', '-version', '-sdk', sdk, infoitem]) + return GetStdoutQuiet(['xcodebuild', '-version', '-sdk', sdk, infoitem]) except: pass @@ -1251,7 +1251,7 @@ def XcodeVersion(): if XCODE_VERSION_CACHE: return XCODE_VERSION_CACHE try: - version_list = GetStdout(['xcodebuild', '-version']).splitlines() + version_list = GetStdoutQuiet(['xcodebuild', '-version']).splitlines() # In some circumstances xcodebuild exits 0 but doesn't return # the right results; for example, a user on 10.7 or 10.8 with # a bogus path set via xcode-select @@ -1301,6 +1301,17 @@ def CLTVersion(): continue +def GetStdoutQuiet(cmdlist): + """Returns the content of standard output returned by invoking |cmdlist|. + Ignores the stderr. + Raises |GypError| if the command return with a non-zero return code.""" + job = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + out = job.communicate()[0] + if job.returncode != 0: + raise GypError('Error %d running %s' % (job.returncode, cmdlist[0])) + return out.rstrip('\n') + + def GetStdout(cmdlist): """Returns the content of standard output returned by invoking |cmdlist|. Raises |GypError| if the command return with a non-zero return code."""