@@ -28,6 +28,7 @@ import sys
2828from helpers import symlink_force , mkdir_p , call , call_output
2929
3030
31+
3132logging .basicConfig (
3233 stream = sys .stdout ,
3334 format = " | " .join ([
@@ -42,6 +43,8 @@ logging.basicConfig(
4243 ]),
4344 level = logging .INFO ,
4445)
46+
47+
4548g_macos_deployment_target = '12.0'
4649
4750g_shared_lib_prefix = "lib"
@@ -50,10 +53,11 @@ if platform.system() == 'Darwin':
5053else :
5154 g_shared_lib_suffix = ".so"
5255
56+
5357class BinaryNotFound (BaseException ):
5458
5559 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 } " )
5761
5862
5963def main ():
@@ -84,7 +88,7 @@ def main():
8488 parser_install .set_defaults (func = install )
8589 add_build_args (parser_install )
8690
87- logging .info ("sys.argv: %r" , sys .argv )
91+ logging .debug ("sys.argv: %r" , sys .argv )
8892 args = parser .parse_args ()
8993 # update the root logger level based on the verbose flag
9094 logging .getLogger ().setLevel (logging .DEBUG if args .verbose else logging .INFO )
@@ -232,7 +236,7 @@ def parse_global_args(args):
232236 args .source_root = os .path .join (args .project_root , "Sources" )
233237
234238 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" ])
236240 else :
237241 args .sysroot = None
238242
@@ -279,50 +283,39 @@ def parse_test_args(args):
279283
280284def get_swiftc_path (args ):
281285 """Returns the path to the Swift compiler."""
282- logging .debug ("Getting path to swiftc..." )
283286 if args .swiftc_path :
284287 swiftc_path = os .path .abspath (args .swiftc_path )
285- logging .debug ("path provided via command line argument. swiftc_path is %r" , swiftc_path )
286288 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" ))
289290 elif platform .system () == 'Darwin' :
290- logging .debug ("we are on darwin, so calling `xcrun --find swiftc`" )
291291 swiftc_path = call_output (
292292 ["xcrun" , "--find" , "swiftc" ],
293293 stderr = subprocess .PIPE ,
294- verbose = args .verbose ,
295294 )
296- logging .debug ("swiftc_path is set to %r" , swiftc_path )
297295 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" ])
300297
301298 if os .path .basename (swiftc_path ) == 'swift' :
302299 swiftc_path = swiftc_path + 'c'
303- logging .debug ("appending to path, it is now %r" , swiftc_path )
304300
305- logging .debug ("swiftc_path set to %r" , swiftc_path )
306301 if os .path .exists (swiftc_path ):
307- logging .debug ("swiftc_path exists.. returning..." )
308302 return swiftc_path
309303 logging .error ("unable to find swiftc at %s" , swiftc_path )
310304 raise BinaryNotFound (tool = "swiftc" , path = swiftc_path )
311305
306+
312307def get_tool_path (args , tool ):
313308 """Returns the path to the specified tool."""
314- logging .debug ("Searching for %s tool" , tool )
315309 path = getattr (args , tool + "_path" , None )
316310 if path is not None :
317311 return os .path .abspath (path )
318312 elif platform .system () == 'Darwin' :
319313 return call_output (
320314 ["xcrun" , "--find" , tool ],
321315 stderr = subprocess .PIPE ,
322- verbose = args .verbose ,
323316 )
324317 else :
325- return call_output (["which" , tool ], verbose = args . verbose )
318+ return call_output (["which" , tool ])
326319
327320def get_build_target (args , cross_compile = False ):
328321 """Returns the target-triple of the current machine or for cross-compilation."""
@@ -331,14 +324,10 @@ def get_build_target(args, cross_compile=False):
331324 if cross_compile :
332325 cross_compile_json = json .load (open (args .cross_compile_config ))
333326 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 ()
338328 args .target_info = json .loads (target_info_json )
339329 return args .target_info ["target" ]["unversionedTriple" if platform .system () == 'Darwin' else "triple" ]
340330 except subprocess .CalledProcessError as cpe :
341- logging .debug ("Command failed..." )
342331 # Temporary fallback for Darwin.
343332 if platform .system () == 'Darwin' :
344333 macOS_default = 'x86_64-apple-macosx'
@@ -357,7 +346,7 @@ def clean(args):
357346 logging .info ("Cleaning" )
358347 parse_global_args (args )
359348
360- call (["rm" , "-rf" , args .build_dir ], verbose = args . verbose )
349+ call (["rm" , "-rf" , args .build_dir ])
361350
362351def build (args ):
363352 """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
564553 logging .debug (' ' .join (cmd ))
565554
566555 mkdir_p (build_dir )
567- call (cmd , cwd = build_dir , verbose = True )
556+ call (cmd , cwd = build_dir )
568557
569558 # Build.
570559 ninja_cmd = [args .ninja_path ]
@@ -575,7 +564,7 @@ def build_with_cmake(args, cmake_args, ninja_args, source_path, build_dir, cmake
575564 if platform .system () == 'Darwin' :
576565 call (["sed" , "-i" , "" , "s/macosx10.10/macosx%s/" % (g_macos_deployment_target ), "build.ninja" ], cwd = build_dir )
577566
578- call (ninja_cmd + ninja_args , cwd = build_dir , verbose = args . verbose )
567+ call (ninja_cmd + ninja_args , cwd = build_dir )
579568
580569def build_llbuild (args ):
581570 """Builds LLBuild using CMake."""
@@ -586,7 +575,7 @@ def build_llbuild(args):
586575
587576 api_dir = os .path .join (args .build_dirs ["llbuild" ], ".cmake/api/v1/query" )
588577 mkdir_p (api_dir )
589- call (["touch" , "codemodel-v2" ], cwd = api_dir , verbose = args . verbose )
578+ call (["touch" , "codemodel-v2" ], cwd = api_dir )
590579
591580 flags = [
592581 "-DCMAKE_C_COMPILER:=%s" % (args .clang_path ),
@@ -719,7 +708,7 @@ def build_swiftpm_with_swiftpm(args, integrated_swift_driver):
719708
720709def call_swiftpm (args , cmd , cwd = None ):
721710 """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 )
723712 args .build_target = get_build_target (args , cross_compile = (True if args .cross_compile_config else False ))
724713
725714 logging .debug ("build target: %r" , args .build_target )
@@ -739,7 +728,7 @@ def call_swiftpm(args, cmd, cwd=None):
739728 full_cmd = get_swiftpm_env_cmd (args ) + cmd + get_swiftpm_flags (args )
740729 if cwd is None :
741730 cwd = args .project_root
742- call_output (full_cmd , cwd = cwd , stderr = True , verbose = True )
731+ call (full_cmd , cwd = cwd )
743732
744733# -----------------------------------------------------------
745734# Build-related helper functions
0 commit comments