@@ -266,7 +266,10 @@ def parse_build_args(args):
266
266
args .build_dir ,
267
267
get_build_target (args ,cross_compile = True ))
268
268
else :
269
- args .target_dir = os .path .join (args .build_dir , get_build_target (args ))
269
+ if platform .system () == 'FreeBSD' :
270
+ args .target_dir = os .path .join (args .build_dir , get_unversioned_build_target (args ))
271
+ else :
272
+ args .target_dir = os .path .join (args .build_dir , get_build_target (args ))
270
273
args .bootstrap_dir = os .path .join (args .target_dir , "bootstrap" )
271
274
args .conf = 'release' if args .release else 'debug'
272
275
args .bin_dir = os .path .join (args .target_dir , args .conf )
@@ -348,6 +351,30 @@ def get_build_target(args, cross_compile=False):
348
351
logging .error ("get build targets: %s" , str (cpe ))
349
352
raise cpe
350
353
354
+ def get_unversioned_build_target (args , cross_compile = False ):
355
+ """Returns the target-triple of the current machine or for cross-compilation."""
356
+ try :
357
+ command = [args .swiftc_path , '-print-target-info' ]
358
+ if cross_compile :
359
+ cross_compile_json = json .load (open (args .cross_compile_config ))
360
+ command += ['-target' , cross_compile_json ["target" ]]
361
+ logging .debug ("Running command >>> %r" , command )
362
+ target_info_json = subprocess .check_output (command ,
363
+ stderr = subprocess .PIPE , universal_newlines = True , env = os .environ ).strip ()
364
+ logging .debug ("Command returned: %r" , target_info_json )
365
+ args .target_info = json .loads (target_info_json )
366
+ return args .target_info ["target" ]["unversionedTriple" ]
367
+ except subprocess .CalledProcessError as cpe :
368
+ logging .debug ("Command failed..." )
369
+ # Temporary fallback for Darwin.
370
+ if platform .system () == 'Darwin' :
371
+ macOS_default = 'x86_64-apple-macosx'
372
+ logging .debug ("we are on Darwin. defaulting to %r" , macOS_default )
373
+ return macOS_default
374
+ else :
375
+ logging .error ("get build targets: %s" , str (cpe ))
376
+ raise cpe
377
+
351
378
# -----------------------------------------------------------
352
379
# Actions
353
380
# -----------------------------------------------------------
0 commit comments