3232
3333from . import _argparse , _call_process
3434
35+ log = logging .getLogger (__name__ )
36+
3537# ==============================================================================
3638
3739
@@ -267,7 +269,7 @@ def resolve_build_directory(self, build_dir_list=None, *, automatic_discovery=Tr
267269 build_dir_list = [] if build_dir_list is None else [Path (path ) for path in build_dir_list ]
268270 for build_dir in build_dir_list :
269271 if build_dir .exists () and Path (build_dir , 'CMakeCache.txt' ).exists ():
270- logging .debug (
272+ log .debug (
271273 'Located valid build directory with CMakeCache.txt at: %s' ,
272274 str (build_dir ),
273275 )
@@ -278,20 +280,20 @@ def resolve_build_directory(self, build_dir_list=None, *, automatic_discovery=Tr
278280 if automatic_discovery :
279281 for path in sorted (self .source_dir .glob ('*' )):
280282 if path .is_dir () and (path / 'CMakeCache.txt' ).exists ():
281- logging .info ('Automatic build dir discovery resulted in: %s' , str (path ))
283+ log .info ('Automatic build dir discovery resulted in: %s' , str (path ))
282284 self .build_dir = path
283285 return
284286
285287 if self .no_cmake_configure :
286- logging .info ('Unable to locate a valid build directory. Will not be creating one' )
288+ log .info ('Unable to locate a valid build directory. Will not be creating one' )
287289 self .build_dir = None
288290 return
289291
290292 if not build_dir_list :
291293 self .build_dir = self .source_dir / self .DEFAULT_BUILD_DIR
292294 else :
293295 self .build_dir = Path (build_dir_list [0 ]).resolve ()
294- logging .info (
296+ log .info (
295297 'Unable to locate a valid build directory. Will be creating one at %s' ,
296298 str (self .build_dir ),
297299 )
@@ -379,11 +381,11 @@ def configure(self, command, *, clean_build=False):
379381 clean_build (bool): Clean build directory before calling CMake configure
380382 """
381383 if self .no_cmake_configure :
382- logging .debug ('Not calling CMake configure' )
384+ log .debug ('Not calling CMake configure' )
383385 return
384386
385387 if self .source_dir is None :
386- logging .error ('No source dir was for CMake! Did you call `setup_cmake_args()`?' )
388+ log .error ('No source dir was for CMake! Did you call `setup_cmake_args()`?' )
387389 sys .exit (1 )
388390
389391 cmake_configure_lock_file = Path (self .build_dir , '_cmake_configure_lock' )
@@ -396,7 +398,7 @@ def configure(self, command, *, clean_build=False):
396398 try :
397399 with cmake_configure_try_lock .acquire (blocking = False ): # noqa: SIM117
398400 with cmake_configure_lock .write_lock ():
399- logging .debug (
401+ log .debug (
400402 'Command %s with id %s is running CMake configure' ,
401403 command ,
402404 os .getpid (),
@@ -408,23 +410,23 @@ def configure(self, command, *, clean_build=False):
408410 ),
409411 clean_build = clean_build ,
410412 )
411- logging .debug (
413+ log .debug (
412414 'Command %s with id %s is done running CMake configure' ,
413415 command ,
414416 os .getpid (),
415417 )
416418 except filelock .Timeout :
417- logging .debug (
419+ log .debug (
418420 'Command %s with id %s is not running CMake configure and waiting' ,
419421 command ,
420422 os .getpid (),
421423 )
422424 with cmake_configure_lock .read_lock ():
423- logging .debug ('Command %s with id %s is done waiting' , command , os .getpid ())
425+ log .debug ('Command %s with id %s is done waiting' , command , os .getpid ())
424426 returncode = 0
425427
426428 if returncode != 0 :
427- logging .error ('CMake configure step failed. See output for more information.' )
429+ log .error ('CMake configure step failed. See output for more information.' )
428430 sys .exit (returncode )
429431
430432 if self .cmake_trace_log is not None :
@@ -439,12 +441,14 @@ def _call_cmake(self, extra_args=None):
439441 [* command , str (self .source_dir ), * self .cmake_args , * extra_args ],
440442 cwd = str (self .build_dir ),
441443 )
442- result .stdout = '\n ' .join ([
443- f'Running CMake with: { [* command , str (self .source_dir ), * self .cmake_args ]} ' ,
444- f' from within { self .build_dir } ' ,
445- result .stdout ,
446- '' ,
447- ])
444+ result .stdout = '\n ' .join (
445+ [
446+ f'Running CMake with: { [* command , str (self .source_dir ), * self .cmake_args ]} ' ,
447+ f' from within { self .build_dir } ' ,
448+ result .stdout ,
449+ '' ,
450+ ]
451+ )
448452
449453 return result
450454
@@ -461,11 +465,13 @@ def _configure(self, lock_files, clean_build):
461465
462466 extra_args = []
463467 if self .cmake_trace_log :
464- extra_args .extend ([
465- '--trace-expand' ,
466- '--trace-format=json-v1' ,
467- f'--trace-redirect={ self .cmake_trace_log } ' ,
468- ])
468+ extra_args .extend (
469+ [
470+ '--trace-expand' ,
471+ '--trace-format=json-v1' ,
472+ f'--trace-redirect={ self .cmake_trace_log } ' ,
473+ ]
474+ )
469475
470476 result = self ._call_cmake (extra_args = extra_args )
471477
@@ -480,16 +486,16 @@ def _configure(self, lock_files, clean_build):
480486 return result .returncode
481487
482488 def _parse_cmake_trace_log (self ):
483- logging .info ('attempting to parse CMake trace log to detect calls to configure_file()' )
489+ log .info ('attempting to parse CMake trace log to detect calls to configure_file()' )
484490 self .cmake_configured_files = []
485491
486492 if not self .cmake_trace_log :
487- logging .info ('no trace log provided, aborting.' )
493+ log .info ('no trace log provided, aborting.' )
488494 return
489495
490496 result = self ._call_cmake (extra_args = ['-N' , '-LA' ])
491497 if result .returncode != 0 :
492- logging .error ('failed to retrieve CMake cache variables' )
498+ log .error ('failed to retrieve CMake cache variables' )
493499 return
494500
495501 cmake_cache_variables = {}
@@ -524,7 +530,7 @@ def _is_relevant_configure_file_call(json_data):
524530 input_file , configured_file = (Path (arg ) for arg in configure_file_call ['args' ][:2 ])
525531 if not configured_file .is_absolute ():
526532 configured_file = self .build_dir / configured_file
527- logging .debug (
533+ log .debug (
528534 'detected call to configure_file(%s %s [...])' ,
529535 str (input_file ),
530536 str (configured_file ),
0 commit comments