@@ -31,13 +31,13 @@ from SwiftBuildSupport import (
31
31
check_call ,
32
32
get_all_preset_names ,
33
33
get_preset_options ,
34
- print_with_argv0 ,
35
34
) # noqa (E402 module level import not at top of file)
36
35
37
36
sys .path .append (os .path .join (os .path .dirname (__file__ ), 'swift_build_support' ))
38
37
39
38
# E402 means module level import not at top of file
40
39
from swift_build_support import arguments # noqa (E402)
40
+ from swift_build_support import diagnostics # noqa (E402)
41
41
from swift_build_support .toolchain import host_toolchain # noqa (E402)
42
42
import swift_build_support .debug # noqa (E402)
43
43
from swift_build_support import migration # noqa (E402)
@@ -102,8 +102,7 @@ def main_preset():
102
102
return 0
103
103
104
104
if not args .preset :
105
- print_with_argv0 ("Missing --preset option" )
106
- return 1
105
+ diagnostics .fatal ("missing --preset option" )
107
106
108
107
args .preset_substitutions = {}
109
108
@@ -121,7 +120,7 @@ def main_preset():
121
120
if args .distcc :
122
121
build_script_args += ["--distcc" ]
123
122
124
- print_with_argv0 (
123
+ diagnostics . note (
125
124
"using preset '" + args .preset + "', which expands to \n \n " +
126
125
shell .quote_command (build_script_args ) + "\n " )
127
126
@@ -995,27 +994,22 @@ details of the setups of other systems or automated environments.""")
995
994
toolchain .cmake = args .cmake
996
995
997
996
if toolchain .cc is None or toolchain .cxx is None :
998
- print_with_argv0 (
999
- "Can't find clang. Please install clang-3.5 or a later version." )
1000
- return 1
997
+ diagnostics .fatal (
998
+ "can't find clang (please install clang-3.5 or a later version)" )
1001
999
1002
1000
if toolchain .cmake is None :
1003
- print_with_argv0 ("Can't find CMake. Please install CMake." )
1004
- return 1
1001
+ diagnostics .fatal ("can't find CMake (please install CMake)" )
1005
1002
1006
1003
if args .distcc :
1007
1004
if toolchain .distcc is None :
1008
- print_with_argv0 (
1009
- "Can't find distcc. Please install distcc" )
1010
- return 1
1005
+ diagnostics .fatal (
1006
+ "can't find distcc (please install distcc)" )
1011
1007
if toolchain .distcc_pump is None :
1012
- print_with_argv0 (
1013
- "Can't find distcc-pump. Please install distcc-pump" )
1014
- return 1
1008
+ diagnostics .fatal (
1009
+ "can't find distcc-pump (please install distcc-pump)" )
1015
1010
1016
1011
if args .host_target is None or args .stdlib_deployment_targets is None :
1017
- print_with_argv0 ("Unknown operating system." )
1018
- return 1
1012
+ diagnostics .fatal ("unknown operating system" )
1019
1013
1020
1014
if args .symbols_package :
1021
1015
if not os .path .isabs (args .symbols_package ):
@@ -1024,10 +1018,9 @@ details of the setups of other systems or automated environments.""")
1024
1018
'(was \' {}\' )' .format (args .symbols_package ))
1025
1019
return 1
1026
1020
if not args .install_symroot :
1027
- print_with_argv0 (
1021
+ diagnostics . fatal (
1028
1022
"--install-symroot is required when specifying "
1029
1023
"--symbols-package." )
1030
- return 1
1031
1024
1032
1025
if args .android :
1033
1026
if args .android_ndk is None or \
@@ -1036,12 +1029,11 @@ details of the setups of other systems or automated environments.""")
1036
1029
args .android_icu_uc_include is None or \
1037
1030
args .android_icu_i18n is None or \
1038
1031
args .android_icu_i18n_include is None :
1039
- print_with_argv0 ("When building for Android, --android-ndk, "
1040
- "--android-ndk-version, --android-icu-uc, "
1041
- "--android-icu-uc-include, --android-icu-i18n, "
1042
- "and --android-icu-i18n-include must be "
1043
- "specified." )
1044
- return 1
1032
+ diagnostics .fatal ("when building for Android, --android-ndk, "
1033
+ "--android-ndk-version, --android-icu-uc, "
1034
+ "--android-icu-uc-include, --android-icu-i18n, "
1035
+ "and --android-icu-i18n-include must be "
1036
+ "specified" )
1045
1037
1046
1038
# Build cmark if any cmark-related options were specified.
1047
1039
if (args .cmark_build_variant is not None ):
@@ -1213,9 +1205,8 @@ details of the setups of other systems or automated environments.""")
1213
1205
1214
1206
if args .build_ninja :
1215
1207
if not os .path .exists (workspace .source_dir ("ninja" )):
1216
- print_with_argv0 ("Can't find source directory for ninja "
1217
- "(tried %s)" % (workspace .source_dir ("ninja" )))
1218
- return 1
1208
+ diagnostics .fatal ("can't find source directory for ninja "
1209
+ "(tried %s)" % (workspace .source_dir ("ninja" )))
1219
1210
1220
1211
os .umask (0o022 )
1221
1212
@@ -1464,17 +1455,15 @@ details of the setups of other systems or automated environments.""")
1464
1455
1465
1456
def main ():
1466
1457
if not SWIFT_SOURCE_ROOT :
1467
- print_with_argv0 (
1468
- "Could not infer source root directory. " +
1469
- "Forgot to set $SWIFT_SOURCE_ROOT environment variable?" )
1470
- return 1
1458
+ diagnostics .fatal (
1459
+ "could not infer source root directory " +
1460
+ "(forgot to set $SWIFT_SOURCE_ROOT environment variable?)" )
1471
1461
1472
1462
if not os .path .isdir (SWIFT_SOURCE_ROOT ):
1473
- print_with_argv0 (
1474
- "Source root directory \' " + SWIFT_SOURCE_ROOT +
1475
- "\' does not exist. " +
1476
- "Forgot to set $SWIFT_SOURCE_ROOT environment variable?" )
1477
- return 1
1463
+ diagnostics .fatal (
1464
+ "source root directory \' " + SWIFT_SOURCE_ROOT +
1465
+ "\' does not exist " +
1466
+ "(forgot to set $SWIFT_SOURCE_ROOT environment variable?)" )
1478
1467
1479
1468
# Determine if we are invoked in the preset mode and dispatch accordingly.
1480
1469
if any ([(opt .startswith ("--preset" ) or opt == "--show-presets" )
0 commit comments