@@ -28,6 +28,7 @@ import sys
28
28
from helpers import symlink_force , mkdir_p , call , call_output
29
29
30
30
31
+
31
32
logging .basicConfig (
32
33
stream = sys .stdout ,
33
34
format = " | " .join ([
@@ -42,6 +43,8 @@ logging.basicConfig(
42
43
]),
43
44
level = logging .INFO ,
44
45
)
46
+
47
+
45
48
g_macos_deployment_target = '12.0'
46
49
47
50
g_shared_lib_prefix = "lib"
@@ -50,10 +53,11 @@ if platform.system() == 'Darwin':
50
53
else :
51
54
g_shared_lib_suffix = ".so"
52
55
56
+
53
57
class BinaryNotFound (BaseException ):
54
58
55
59
def __init__ (self , * , tool : str , path : pathlib .Path ):
56
- super ().__init__ ("Unable to find {tool} source directory at {path}" )
60
+ super ().__init__ (f "Unable to find { tool } source directory at { path } " )
57
61
58
62
59
63
def main ():
@@ -84,7 +88,7 @@ def main():
84
88
parser_install .set_defaults (func = install )
85
89
add_build_args (parser_install )
86
90
87
- logging .info ("sys.argv: %r" , sys .argv )
91
+ logging .debug ("sys.argv: %r" , sys .argv )
88
92
args = parser .parse_args ()
89
93
# update the root logger level based on the verbose flag
90
94
logging .getLogger ().setLevel (logging .DEBUG if args .verbose else logging .INFO )
@@ -232,7 +236,7 @@ def parse_global_args(args):
232
236
args .source_root = os .path .join (args .project_root , "Sources" )
233
237
234
238
if platform .system () == 'Darwin' :
235
- args .sysroot = call_output (["xcrun" , "--sdk" , "macosx" , "--show-sdk-path" ], verbose = args . verbose )
239
+ args .sysroot = call_output (["xcrun" , "--sdk" , "macosx" , "--show-sdk-path" ])
236
240
else :
237
241
args .sysroot = None
238
242
@@ -279,50 +283,39 @@ def parse_test_args(args):
279
283
280
284
def get_swiftc_path (args ):
281
285
"""Returns the path to the Swift compiler."""
282
- logging .debug ("Getting path to swiftc..." )
283
286
if args .swiftc_path :
284
287
swiftc_path = os .path .abspath (args .swiftc_path )
285
- logging .debug ("path provided via command line argument. swiftc_path is %r" , swiftc_path )
286
288
elif os .getenv ("SWIFT_EXEC" ):
287
- swiftc_path = os .getenv ("SWIFT_EXEC" )
288
- logging .debug ("SWIFT_EXEC env set. swiftc_path set to %r" , swiftc_path )
289
+ swiftc_path = os .path .realpath (os .getenv ("SWIFT_EXEC" ))
289
290
elif platform .system () == 'Darwin' :
290
- logging .debug ("we are on darwin, so calling `xcrun --find swiftc`" )
291
291
swiftc_path = call_output (
292
292
["xcrun" , "--find" , "swiftc" ],
293
293
stderr = subprocess .PIPE ,
294
- verbose = args .verbose ,
295
294
)
296
- logging .debug ("swiftc_path is set to %r" , swiftc_path )
297
295
else :
298
- swiftc_path = call_output (["which" , "swiftc" ], verbose = args .verbose )
299
- logging .debug ("calling 'which swiftc'. path is %r" , swiftc_path )
296
+ swiftc_path = call_output (["which" , "swiftc" ])
300
297
301
298
if os .path .basename (swiftc_path ) == 'swift' :
302
299
swiftc_path = swiftc_path + 'c'
303
- logging .debug ("appending to path, it is now %r" , swiftc_path )
304
300
305
- logging .debug ("swiftc_path set to %r" , swiftc_path )
306
301
if os .path .exists (swiftc_path ):
307
- logging .debug ("swiftc_path exists.. returning..." )
308
302
return swiftc_path
309
303
logging .error ("unable to find swiftc at %s" , swiftc_path )
310
304
raise BinaryNotFound (tool = "swiftc" , path = swiftc_path )
311
305
306
+
312
307
def get_tool_path (args , tool ):
313
308
"""Returns the path to the specified tool."""
314
- logging .debug ("Searching for %s tool" , tool )
315
309
path = getattr (args , tool + "_path" , None )
316
310
if path is not None :
317
311
return os .path .abspath (path )
318
312
elif platform .system () == 'Darwin' :
319
313
return call_output (
320
314
["xcrun" , "--find" , tool ],
321
315
stderr = subprocess .PIPE ,
322
- verbose = args .verbose ,
323
316
)
324
317
else :
325
- return call_output (["which" , tool ], verbose = args . verbose )
318
+ return call_output (["which" , tool ])
326
319
327
320
def get_build_target (args , cross_compile = False ):
328
321
"""Returns the target-triple of the current machine or for cross-compilation."""
@@ -331,14 +324,10 @@ def get_build_target(args, cross_compile=False):
331
324
if cross_compile :
332
325
cross_compile_json = json .load (open (args .cross_compile_config ))
333
326
command += ['-target' , cross_compile_json ["target" ]]
334
- logging .debug ("Running command >>> %r" , command )
335
- target_info_json = subprocess .check_output (command ,
336
- stderr = subprocess .PIPE , universal_newlines = True , env = os .environ ).strip ()
337
- logging .debug ("Command returned: %r" , target_info_json )
327
+ target_info_json = call_output (cmd = command , env = os .environ , stderr = subprocess .PIPE ).strip ()
338
328
args .target_info = json .loads (target_info_json )
339
329
return args .target_info ["target" ]["unversionedTriple" if platform .system () == 'Darwin' else "triple" ]
340
330
except subprocess .CalledProcessError as cpe :
341
- logging .debug ("Command failed..." )
342
331
# Temporary fallback for Darwin.
343
332
if platform .system () == 'Darwin' :
344
333
macOS_default = 'x86_64-apple-macosx'
@@ -357,7 +346,7 @@ def clean(args):
357
346
logging .info ("Cleaning" )
358
347
parse_global_args (args )
359
348
360
- call (["rm" , "-rf" , args .build_dir ], verbose = args . verbose )
349
+ call (["rm" , "-rf" , args .build_dir ])
361
350
362
351
def build (args ):
363
352
"""Builds SwiftPM using a two-step process: first using CMake, then with itself."""
@@ -564,7 +553,7 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
564
553
logging .debug (' ' .join (cmd ))
565
554
566
555
mkdir_p (build_dir )
567
- call (cmd , cwd = build_dir , verbose = True )
556
+ call (cmd , cwd = build_dir )
568
557
569
558
# Build.
570
559
ninja_cmd = [args .ninja_path ]
@@ -575,7 +564,7 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
575
564
if platform .system () == 'Darwin' :
576
565
call (["sed" , "-i" , "" , "s/macosx10.10/macosx%s/" % (g_macos_deployment_target ), "build.ninja" ], cwd = build_dir )
577
566
578
- call (ninja_cmd + ninja_args , cwd = build_dir , verbose = args . verbose )
567
+ call (ninja_cmd + ninja_args , cwd = build_dir )
579
568
580
569
def build_llbuild (args ):
581
570
"""Builds LLBuild using CMake."""
@@ -586,7 +575,7 @@ def build_llbuild(args):
586
575
587
576
api_dir = os .path .join (args .build_dirs ["llbuild" ], ".cmake/api/v1/query" )
588
577
mkdir_p (api_dir )
589
- call (["touch" , "codemodel-v2" ], cwd = api_dir , verbose = args . verbose )
578
+ call (["touch" , "codemodel-v2" ], cwd = api_dir )
590
579
591
580
flags = [
592
581
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
@@ -719,7 +708,7 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
719
708
720
709
def call_swiftpm (args , cmd , cwd = None ):
721
710
"""Calls a SwiftPM binary with the necessary environment variables and flags."""
722
- logging .info ("function args: %r, cmd: %r, cwd: %r" , args , cmd , cwd )
711
+ logging .debug ("function %s args: %r, cmd: %r, cwd: %r" , call_swiftpm . __qualname__ , args , cmd , cwd )
723
712
args .build_target = get_build_target (args , cross_compile = (True if args .cross_compile_config else False ))
724
713
725
714
logging .debug ("build target: %r" , args .build_target )
@@ -739,7 +728,7 @@ def call_swiftpm(args, cmd, cwd=None):
739
728
full_cmd = get_swiftpm_env_cmd (args ) + cmd + get_swiftpm_flags (args )
740
729
if cwd is None :
741
730
cwd = args .project_root
742
- call_output (full_cmd , cwd = cwd , stderr = True , verbose = True )
731
+ call (full_cmd , cwd = cwd )
743
732
744
733
# -----------------------------------------------------------
745
734
# Build-related helper functions
0 commit comments