@@ -27,7 +27,6 @@ from build_swift.build_swift import presets
2727import six
2828
2929from swift_build_support .swift_build_support import (
30- debug ,
3130 diagnostics ,
3231 products ,
3332 shell ,
@@ -71,6 +70,25 @@ class JSONDumper(json.JSONEncoder):
7170 return six .text_type (o )
7271
7372
73+ def print_xcodebuild_versions (file = sys .stdout ):
74+ """
75+ Print the host machine's `xcodebuild` version, as well as version
76+ information for all available SDKs.
77+ """
78+ version = shell .capture (
79+ ['xcodebuild' , '-version' ], dry_run = False , echo = False ).rstrip ()
80+ # Allow non-zero exit codes. Under certain obscure circumstances
81+ # xcodebuild can exit with a non-zero exit code even when the SDK is
82+ # usable.
83+ sdks = shell .capture (
84+ ['xcodebuild' , '-version' , '-sdk' ], dry_run = False , echo = False ,
85+ allow_non_zero_exit = True ).rstrip ()
86+ fmt = '{version}\n \n --- SDK versions ---\n {sdks}\n '
87+
88+ print (fmt .format (version = version , sdks = sdks ), file = file )
89+ file .flush ()
90+
91+
7492class BuildScriptInvocation (object ):
7593
7694 """Represent a single build script invocation."""
@@ -1149,7 +1167,7 @@ def main_normal():
11491167
11501168 # Show SDKs, if requested.
11511169 if args .show_sdks :
1152- debug . print_xcodebuild_versions ()
1170+ print_xcodebuild_versions ()
11531171
11541172 if args .dump_config :
11551173 print (JSONDumper ().encode (invocation ))
0 commit comments