diff --git a/utils/build-script b/utils/build-script index 2d0a03169a680..436fb357bac59 100755 --- a/utils/build-script +++ b/utils/build-script @@ -27,7 +27,6 @@ from build_swift.build_swift import presets import six from swift_build_support.swift_build_support import ( - debug, diagnostics, products, shell, @@ -71,6 +70,25 @@ class JSONDumper(json.JSONEncoder): return six.text_type(o) +def print_xcodebuild_versions(file=sys.stdout): + """ + Print the host machine's `xcodebuild` version, as well as version + information for all available SDKs. + """ + version = shell.capture( + ['xcodebuild', '-version'], dry_run=False, echo=False).rstrip() + # Allow non-zero exit codes. Under certain obscure circumstances + # xcodebuild can exit with a non-zero exit code even when the SDK is + # usable. + sdks = shell.capture( + ['xcodebuild', '-version', '-sdk'], dry_run=False, echo=False, + allow_non_zero_exit=True).rstrip() + fmt = '{version}\n\n--- SDK versions ---\n{sdks}\n' + + print(fmt.format(version=version, sdks=sdks), file=file) + file.flush() + + class BuildScriptInvocation(object): """Represent a single build script invocation.""" @@ -1116,7 +1134,7 @@ def main_normal(): # Show SDKs, if requested. if args.show_sdks: - debug.print_xcodebuild_versions() + print_xcodebuild_versions() if args.dump_config: print(JSONDumper().encode(invocation)) diff --git a/utils/swift_build_support/swift_build_support/debug.py b/utils/swift_build_support/swift_build_support/debug.py deleted file mode 100644 index e4369b97d1902..0000000000000 --- a/utils/swift_build_support/swift_build_support/debug.py +++ /dev/null @@ -1,46 +0,0 @@ -# swift_build_support/debug.py - Print information on the build -*- python -*- -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -# -# ---------------------------------------------------------------------------- -# -# Convenient functions for printing out information on the build process. -# -# ---------------------------------------------------------------------------- - -from __future__ import absolute_import -from __future__ import print_function - -import sys - -from . import shell - - -def print_xcodebuild_versions(file=sys.stdout): - """ - Print the host machine's `xcodebuild` version, as well as version - information for all available SDKs. - """ - version = shell.capture( - ['xcodebuild', '-version'], dry_run=False, echo=False).rstrip() - # Allow non-zero exit codes. Under certain obscure circumstances - # xcodebuild can exit with a non-zero exit code even when the SDK is - # usable. - sdks = shell.capture( - ['xcodebuild', '-version', '-sdk'], dry_run=False, echo=False, - allow_non_zero_exit=True).rstrip() - fmt = """\ -{version} - ---- SDK versions --- -{sdks} - -""" - print(fmt.format(version=version, sdks=sdks), file=file) - file.flush() diff --git a/utils/swift_build_support/tests/test_debug.py b/utils/swift_build_support/tests/test_debug.py deleted file mode 100644 index 954db17146730..0000000000000 --- a/utils/swift_build_support/tests/test_debug.py +++ /dev/null @@ -1,41 +0,0 @@ -# test_debug.py - Unit tests for swift_build_support.debug -*- python -*- -# -# This source file is part of the Swift.org open source project -# -# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors -# Licensed under Apache License v2.0 with Runtime Library Exception -# -# See https://swift.org/LICENSE.txt for license information -# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors - -import platform -import unittest -try: - # py2 - from StringIO import StringIO -except ImportError: - # py3 - from io import StringIO - -from swift_build_support import debug - - -class PrintXcodebuildVersionsTestCase(unittest.TestCase): - def setUp(self): - if platform.system() != 'Darwin': - self.skipTest('print_xcodebuild_version() tests should only be ' - 'run on OS X') - self._out = StringIO() - - def test_outputs_xcode_version(self): - debug.print_xcodebuild_versions(file=self._out) - actual = self._out.getvalue().splitlines() - self.assertTrue(actual[0].startswith('Xcode ')) - self.assertTrue(actual[1].startswith('Build version ')) - self.assertEqual(actual[3], '--- SDK versions ---') - # You can't test beyond this because each developer's machines may have - # a different set of SDKs installed. - - -if __name__ == '__main__': - unittest.main()