@@ -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,11 @@ 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
327
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 )
328
+ stderr = subprocess .PIPE , universal_newlines = True ).strip ()
338
329
args .target_info = json .loads (target_info_json )
339
330
return args .target_info ["target" ]["unversionedTriple" if platform .system () == 'Darwin' else "triple" ]
340
331
except subprocess .CalledProcessError as cpe :
341
- logging .debug ("Command failed..." )
342
332
# Temporary fallback for Darwin.
343
333
if platform .system () == 'Darwin' :
344
334
macOS_default = 'x86_64-apple-macosx'
@@ -357,7 +347,7 @@ def clean(args):
357
347
logging .info ("Cleaning" )
358
348
parse_global_args (args )
359
349
360
- call (["rm" , "-rf" , args .build_dir ], verbose = args . verbose )
350
+ call (["rm" , "-rf" , args .build_dir ])
361
351
362
352
def build (args ):
363
353
"""Builds SwiftPM using a two-step process: first using CMake, then with itself."""
@@ -564,7 +554,7 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
564
554
logging .debug (' ' .join (cmd ))
565
555
566
556
mkdir_p (build_dir )
567
- call (cmd , cwd = build_dir , verbose = True )
557
+ call (cmd , cwd = build_dir )
568
558
569
559
# Build.
570
560
ninja_cmd = [args .ninja_path ]
@@ -575,7 +565,7 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
575
565
if platform .system () == 'Darwin' :
576
566
call (["sed" , "-i" , "" , "s/macosx10.10/macosx%s/" % (g_macos_deployment_target ), "build.ninja" ], cwd = build_dir )
577
567
578
- call (ninja_cmd + ninja_args , cwd = build_dir , verbose = args . verbose )
568
+ call (ninja_cmd + ninja_args , cwd = build_dir )
579
569
580
570
def build_llbuild (args ):
581
571
"""Builds LLBuild using CMake."""
@@ -586,7 +576,7 @@ def build_llbuild(args):
586
576
587
577
api_dir = os .path .join (args .build_dirs ["llbuild" ], ".cmake/api/v1/query" )
588
578
mkdir_p (api_dir )
589
- call (["touch" , "codemodel-v2" ], cwd = api_dir , verbose = args . verbose )
579
+ call (["touch" , "codemodel-v2" ], cwd = api_dir )
590
580
591
581
flags = [
592
582
"-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
@@ -627,7 +617,7 @@ def add_rpath_for_cmake_build(args, rpath):
627
617
swift_build = os .path .join (args .bootstrap_dir , "bin/swift-bootstrap" )
628
618
add_rpath_cmd = ["install_name_tool" , "-add_rpath" , rpath , swift_build ]
629
619
logging .info (' ' .join (add_rpath_cmd ))
630
- subprocess .call (add_rpath_cmd , stderr = subprocess .PIPE , env = os . environ )
620
+ subprocess .call (add_rpath_cmd , stderr = subprocess .PIPE )
631
621
632
622
def get_swift_backdeploy_library_paths (args ):
633
623
if platform .system () == 'Darwin' :
@@ -719,7 +709,7 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
719
709
720
710
def call_swiftpm (args , cmd , cwd = None ):
721
711
"""Calls a SwiftPM binary with the necessary environment variables and flags."""
722
- logging .info ("function args: %r, cmd: %r, cwd: %r" , args , cmd , cwd )
712
+ logging .debug ("function %s args: %r, cmd: %r, cwd: %r" , call_swiftpm . __qualname__ , args , cmd , cwd )
723
713
args .build_target = get_build_target (args , cross_compile = (True if args .cross_compile_config else False ))
724
714
725
715
logging .debug ("build target: %r" , args .build_target )
@@ -728,8 +718,9 @@ def call_swiftpm(args, cmd, cwd=None):
728
718
args .platform_path = re .search (r"(lib/swift/([^/]+))$" , path )
729
719
if args .platform_path :
730
720
break
731
- else :
732
- # this gets called if the for loop does not break
721
+ # else:
722
+ # # this gets called if the for loop does not break
723
+ if not args .platform_path :
733
724
logging .error (
734
725
"the command `%s -print-target-info` didn't return a valid runtime library path" ,
735
726
args .swiftc_path
@@ -739,7 +730,7 @@ def call_swiftpm(args, cmd, cwd=None):
739
730
full_cmd = get_swiftpm_env_cmd (args ) + cmd + get_swiftpm_flags (args )
740
731
if cwd is None :
741
732
cwd = args .project_root
742
- call_output (full_cmd , cwd = cwd , stderr = True , verbose = True )
733
+ call (full_cmd , cwd = cwd )
743
734
744
735
# -----------------------------------------------------------
745
736
# Build-related helper functions
0 commit comments