Under certain obscure circumstances (incomplete SDKs), xcodebuild can
successfully work with the SDK and print its version number, but will
still exit with a non-zero code. This change works around the issue by
ignoring the exit code.
- This improves the error messages when commands fail (or don't exist) to show
a one-line summary of the issue instead of the Python backtrace, and matches
what was being done by the matching function in `SwiftBuildSupport`.
- This uses more Clang/Swift-style diagnostics, and adds a convenient wrapper
`fatal()` which happens to match what almost all clients of the previous
`print_with_argv0` wanted to do (i.e., fail with a fatal error).
- As part of this, I also tried to make the diagnostics more consistent and use
"diagnostic style" casing/punctuation.
- Part of SR-237.
This might not be the most principled way to do it (not too familiar
with this idiom of nested python modules named the same as their only
components), but it seems to have worked.
When running build-script, I get the output below:
utils/build-script --preset=drew --preset-file=../presets.ini --preset-file=utils/build-presets.ini installable_package="`pwd`/../osx-caffeinated-$tag.tar.gz" install_destdir="`pwd`/../install" install_symroot="`pwd`/../install_symroot" symbols_package="`pwd`/../osx-caffeinated-symbols-$tag.tar.gz" darwin_toolchain_bundle_identifier="net.caffei.swift.$tag" darwin_toolchain_display_name="caffeinated-$tag" install_toolchain_dir="/Library/Developer/Toolchains/caffeinated-$tag.xctoolchain" darwin_toolchain_xctoolchain_name="caffeinated-$tag.xctoolchain" darwin_toolchain_version="caffeinated-$tag" darwin_toolchain_alias="caffeinated-$tag" darwin_toolchain_display_name_short="caffeinated-$tag"
utils/build-script: using preset 'drew', which expands to utils/build-script --ios --tvos --watchos --lldb --llbuild --swiftpm --release-debuginfo --build-subdir=buildbot_osx --ios --tvos --watchos --test --validation-test --long-test --assertions --no-swift-stdlib-assertions -- --lldb-no-debugserver --lldb-use-system-debugserver --lldb-build-type=Release --verbose-build --build-ninja --build-swift-static-stdlib --build-swift-stdlib-unittest-extra --compiler-vendor=apple '--swift-sdks=OSX;IOS;IOS_SIMULATOR;TVOS;TVOS_SIMULATOR;WATCHOS;WATCHOS_SIMULATOR' --install-swift --install-lldb --install-llbuild --install-swiftpm --install-destdir=/Users/drew/Code/swift-osx/swift/../install --darwin-install-extract-symbols --install-symroot=/Users/drew/Code/swift-osx/swift/../install_symroot --install-prefix=/Library/Developer/Toolchains/caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.xctoolchain/usr --test-installable-package --reconfigure --installable-package=/Users/drew/Code/swift-osx/swift/../osx-caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.tar.gz --swift-enable-ast-verifier=0 '--swift-install-components=compiler;clang-builtin-headers;stdlib;sdk-overlay;license;sourcekit-xpc-service' '--llvm-install-components=libclang;libclang-headers' --installable-package=/Users/drew/Code/swift-osx/swift/../osx-caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.tar.gz --symbols-package=/Users/drew/Code/swift-osx/swift/../osx-caffeinated-symbols-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.tar.gz --darwin-toolchain-bundle-identifier=net.caffei.swift.swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a --darwin-toolchain-display-name=caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a --darwin-toolchain-display-name-short=caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a --darwin-toolchain-name=caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a.xctoolchain --darwin-toolchain-version=caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a --darwin-toolchain-alias=caffeinated-swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a --skip-test-ios --skip-test-tvos --skip-test-watchos
Traceback (most recent call last):
File "utils/build-script", line 1339, in <module>
sys.exit(main())
File "utils/build-script", line 1335, in main
return main_normal()
File "utils/build-script", line 824, in main_normal
args = migration.parse_args(parser, sys.argv[1:])
File "utils/swift_build_support/swift_build_support/migration.py", line 34, in parse_args
arg for arg in argv if arg != '--')
File "/Library/Python/2.7/site-packages/argparse.py", line 1735, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/Library/Python/2.7/site-packages/argparse.py", line 1941, in _parse_known_args
start_index = consume_optional(start_index)
File "/Library/Python/2.7/site-packages/argparse.py", line 1873, in consume_optional
args = arg_strings[start:stop]
TypeError: 'generator' object has no attribute '__getitem__'
utils/build-script: command terminated with a non-zero exit status 1, aborting
This seems to be because the migrator script passes a generator where one was not expected.
Construct a list instead.