@@ -601,8 +601,6 @@ class BuildScriptInvocation(object):
601
601
"--host-target" , args .host_target ,
602
602
"--stdlib-deployment-targets" ,
603
603
" " .join (args .stdlib_deployment_targets ),
604
- "--host-cc" , toolchain .cc ,
605
- "--host-cxx" , toolchain .cxx ,
606
604
"--darwin-xcrun-toolchain" , args .darwin_xcrun_toolchain ,
607
605
"--darwin-deployment-version-osx=%s" % (
608
606
args .darwin_deployment_version_osx ),
@@ -613,6 +611,8 @@ class BuildScriptInvocation(object):
613
611
"--darwin-deployment-version-watchos=%s" % (
614
612
args .darwin_deployment_version_watchos ),
615
613
"--cmake" , toolchain .cmake ,
614
+ "--cmake-c-compiler" , toolchain .cc ,
615
+ "--cmake-cxx-compiler" , toolchain .cxx ,
616
616
"--cmark-build-type" , args .cmark_build_variant ,
617
617
"--llvm-build-type" , args .llvm_build_variant ,
618
618
"--swift-build-type" , args .swift_build_variant ,
@@ -682,6 +682,14 @@ class BuildScriptInvocation(object):
682
682
"--distcc" ,
683
683
"--distcc-pump=%s" % toolchain .distcc_pump
684
684
]
685
+ if args .swiftenv_path :
686
+ impl_args += [ "--swiftenv-path=%s" % args .swiftenv_path ]
687
+ if args .swiftenv_recreate :
688
+ impl_args += [ "--swiftenv-recreate" ]
689
+ if args .swiftenv_script :
690
+ impl_args += [ "--swiftenv-script=%s" % args .swiftenv_script ]
691
+ if args .swiftenv_make :
692
+ impl_args += [ "--swiftenv-make=%s" % args .swiftenv_make ]
685
693
if args .enable_asan :
686
694
impl_args += ["--enable-asan" ]
687
695
if args .enable_ubsan :
@@ -819,12 +827,6 @@ class BuildScriptInvocation(object):
819
827
"--toolchain-prefix" ,
820
828
swift_build_support .targets .darwin_toolchain_prefix (
821
829
args .install_prefix ),
822
- "--host-lipo" , toolchain .lipo ,
823
- ]
824
-
825
- if toolchain .libtool is not None :
826
- impl_args += [
827
- "--host-libtool" , toolchain .libtool ,
828
830
]
829
831
830
832
# If we have extra_swift_args, combine all of them together and then
@@ -1044,6 +1046,47 @@ def clean_delay():
1044
1046
print ('\b \b \b \b now.' )
1045
1047
1046
1048
1049
+ def handle_swiftenv_args (args ):
1050
+ # Find clang in swiftenv if present
1051
+ if args .swiftenv_path is None :
1052
+ if args .swiftenv_recreate :
1053
+ print (sys .argv [0 ], "error: using a swiftenv_recreate to make a swiftenv requires a destination in --swiftenv-path=" , file = sys .stderr )
1054
+ sys .exit (2 ) # 2 is the same as `argparse` error exit code.
1055
+
1056
+ if args .swiftenv_script is not None :
1057
+ print (sys .argv [0 ], "error: using a swiftenv_script to make a swiftenv requires a destination in --swiftenv-path=" , file = sys .stderr )
1058
+ sys .exit (2 ) # 2 is the same as `argparse` error exit code.
1059
+
1060
+ if args .swiftenv_make is not None :
1061
+ print (sys .argv [0 ], "error: using a swiftenv_make to make a swiftenv requires a destination in --swiftenv-path=" , file = sys .stderr )
1062
+ sys .exit (2 ) # 2 is the same as `argparse` error exit code.
1063
+
1064
+ if args .swiftenv_path is not None :
1065
+ # mkdir the swiftenv_path
1066
+ if not os .path .exists (args .swiftenv_path ):
1067
+ os .makedirs (args .swiftenv_path )
1068
+
1069
+ # Only use swiftenv_make/swiftenv_script if one is provided
1070
+ # utils/swiftenv-make is default
1071
+ if args .swiftenv_make is None :
1072
+ args .swiftenv_make = os .path .join (
1073
+ SWIFT_SOURCE_ROOT , "swift" , "utils" , "swiftenv-make" )
1074
+ else :
1075
+ args .swiftenv_make = os .path .abspath (args .swiftenv_make )
1076
+
1077
+ # utils/swiftenv-script is default
1078
+ if args .swiftenv_script is None :
1079
+ args .swiftenv_script = os .path .join (
1080
+ SWIFT_SOURCE_ROOT , "swift" , "utils" , "swiftenv-script" )
1081
+ else :
1082
+ args .swiftenv_script = os .path .abspath (args .swiftenv_script )
1083
+
1084
+ print ("args.swiftenv_path" , args .swiftenv_path )
1085
+ print ("args.swiftenv_recreate" , args .swiftenv_recreate )
1086
+ print ("args.swiftenv_make" , args .swiftenv_make )
1087
+ print ("args.swiftenv_script" , args .swiftenv_script )
1088
+
1089
+
1047
1090
# Main entry point for the preset mode.
1048
1091
def main_preset ():
1049
1092
parser = argparse .ArgumentParser (
@@ -1070,6 +1113,19 @@ def main_preset():
1070
1113
"--show-presets" ,
1071
1114
help = "list all presets and exit" ,
1072
1115
action = arguments .action .optional_bool )
1116
+ parser .add_argument (
1117
+ "--swiftenv-path" ,
1118
+ help = "the absolute path to a directory containing replacement compiler commands" )
1119
+ parser .add_argument (
1120
+ "--swiftenv-recreate" ,
1121
+ help = "a flag that, when present, will recreate the swiftenv" ,
1122
+ action = arguments .action .optional_bool )
1123
+ parser .add_argument (
1124
+ "--swiftenv-script" ,
1125
+ help = "the absolute path to a script that takes the place of toolchain commands, default uses utils/swiftenv-script" )
1126
+ parser .add_argument (
1127
+ "--swiftenv-make" ,
1128
+ help = "the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make" )
1073
1129
parser .add_argument (
1074
1130
"--distcc" ,
1075
1131
help = "use distcc" ,
@@ -1125,6 +1181,17 @@ def main_preset():
1125
1181
if args .build_jobs :
1126
1182
build_script_args += ["--jobs" , str (args .build_jobs )]
1127
1183
1184
+ handle_swiftenv_args (args )
1185
+
1186
+ if args .swiftenv_path is not None :
1187
+ build_script_args += ["--swiftenv-path" , str (args .swiftenv_path )]
1188
+ if args .swiftenv_recreate :
1189
+ build_script_args += ["--swiftenv-recreate" ]
1190
+ if args .swiftenv_make is not None :
1191
+ build_script_args += ["--swiftenv-make" , str (args .swiftenv_make )]
1192
+ if args .swiftenv_script is not None :
1193
+ build_script_args += ["--swiftenv-script" , str (args .swiftenv_script )]
1194
+
1128
1195
diagnostics .note (
1129
1196
"using preset '" + args .preset + "', which expands to \n \n " +
1130
1197
shell .quote_command (build_script_args ) + "\n " )
@@ -1981,27 +2048,31 @@ iterations with -O",
1981
2048
metavar = "PATH" )
1982
2049
1983
2050
parser .add_argument (
1984
- "--host-cc " ,
2051
+ "--cmake-c-compiler " ,
1985
2052
help = "the absolute path to CC, the 'clang' compiler for the host "
1986
2053
"platform. Default is auto detected." ,
1987
2054
type = arguments .type .executable ,
1988
2055
metavar = "PATH" )
1989
2056
parser .add_argument (
1990
- "--host -cxx" ,
2057
+ "--cmake -cxx-compiler " ,
1991
2058
help = "the absolute path to CXX, the 'clang++' compiler for the host "
1992
2059
"platform. Default is auto detected." ,
1993
2060
type = arguments .type .executable ,
1994
2061
metavar = "PATH" )
1995
2062
parser .add_argument (
1996
- "--host-lipo" ,
1997
- help = "the absolute path to lipo. Default is auto detected." ,
1998
- type = arguments .type .executable ,
1999
- metavar = "PATH" )
2063
+ "--swiftenv-path" ,
2064
+ help = "the absolute path to a directory containing replacement compiler commands" )
2000
2065
parser .add_argument (
2001
- "--host-libtool" ,
2002
- help = "the absolute path to libtool. Default is auto detected." ,
2003
- type = arguments .type .executable ,
2004
- metavar = "PATH" )
2066
+ "--swiftenv-recreate" ,
2067
+ help = "a flag that, when present, will recreate the swiftenv" ,
2068
+ default = "false" ,
2069
+ action = arguments .action .optional_bool )
2070
+ parser .add_argument (
2071
+ "--swiftenv-script" ,
2072
+ help = "the absolute path to a script that takes the place of toolchain commands" )
2073
+ parser .add_argument (
2074
+ "--swiftenv-make" ,
2075
+ help = "the absolute path to a script that will set up a swiftenv, default uses utils/swiftenv-make" )
2005
2076
parser .add_argument (
2006
2077
"--distcc" ,
2007
2078
help = "use distcc in pump mode" ,
@@ -2173,14 +2244,22 @@ iterations with -O",
2173
2244
# Prepare and validate toolchain
2174
2245
toolchain = host_toolchain (xcrun_toolchain = args .darwin_xcrun_toolchain )
2175
2246
2176
- if args .host_cc is not None :
2177
- toolchain .cc = args .host_cc
2178
- if args .host_cxx is not None :
2179
- toolchain .cxx = args .host_cxx
2180
- if args .host_lipo is not None :
2181
- toolchain .lipo = args .host_lipo
2182
- if args .host_libtool is not None :
2183
- toolchain .libtool = args .host_libtool
2247
+ # Abstracted swiftenv_args for --preset and not
2248
+ handle_swiftenv_args (args )
2249
+
2250
+ # Let args.cmake_c_compiler win over swiftenv's cc/cxx
2251
+ if args .cmake_c_compiler is None and args .swiftenv_path is not None :
2252
+ if os .path .exists (args .swiftenv_path + "/clang" ):
2253
+ args .cmake_c_compiler = args .swiftenv_path + "/clang"
2254
+ if args .cmake_cxx_compiler is None and args .swiftenv_path is not None :
2255
+ if os .path .exists (args .swiftenv_path + "/clang++" ):
2256
+ args .cmake_cxx_compiler = args .swiftenv_path + "/clang++"
2257
+
2258
+ if args .cmake_c_compiler is not None :
2259
+ toolchain .cc = args .cmake_c_compiler
2260
+ if args .cmake_cxx_compiler is not None :
2261
+ toolchain .cxx = args .cmake_cxx_compiler
2262
+
2184
2263
if args .cmake is not None :
2185
2264
toolchain .cmake = args .cmake
2186
2265
0 commit comments