[tools] add logging as Env['log']
Add logging as Env['log']: - the default level is INFO; - when using `scons --verbose`, the level will be change to debug level. - Add more debug information for cc detection.
This commit is contained in:
parent
2ab5827704
commit
2946e4a316
@ -23,6 +23,7 @@
|
|||||||
# 2015-07-25 Bernard Add LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES for
|
# 2015-07-25 Bernard Add LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES for
|
||||||
# group definition.
|
# group definition.
|
||||||
# 2024-04-21 Bernard Add toolchain detection in sdk packages
|
# 2024-04-21 Bernard Add toolchain detection in sdk packages
|
||||||
|
# 2025-01-05 Bernard Add logging as Env['log']
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -31,6 +32,7 @@ import utils
|
|||||||
import operator
|
import operator
|
||||||
import rtconfig
|
import rtconfig
|
||||||
import platform
|
import platform
|
||||||
|
import logging
|
||||||
|
|
||||||
from SCons.Script import *
|
from SCons.Script import *
|
||||||
from utils import _make_path_relative
|
from utils import _make_path_relative
|
||||||
@ -130,6 +132,14 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
AddOptions()
|
AddOptions()
|
||||||
|
|
||||||
Env = env
|
Env = env
|
||||||
|
|
||||||
|
# prepare logging and set log
|
||||||
|
logging.basicConfig(level=logging.INFO, format="%(message)s")
|
||||||
|
logger = logging.getLogger('rt-scons')
|
||||||
|
if GetOption('verbose'):
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
Env['log'] = logger
|
||||||
|
|
||||||
Rtt_Root = os.path.abspath(root_directory)
|
Rtt_Root = os.path.abspath(root_directory)
|
||||||
|
|
||||||
# make an absolute root directory
|
# make an absolute root directory
|
||||||
@ -189,6 +199,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
|
|
||||||
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
|
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
|
||||||
if not utils.CmdExists(os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)):
|
if not utils.CmdExists(os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)):
|
||||||
|
Env['log'].debug('To detect CC because CC path in rtconfig.py is invalid:')
|
||||||
|
Env['log'].debug(' rtconfig.py cc ->' + os.path.join(rtconfig.EXEC_PATH, rtconfig.CC))
|
||||||
if 'RTT_EXEC_PATH' in os.environ:
|
if 'RTT_EXEC_PATH' in os.environ:
|
||||||
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
|
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
|
||||||
del os.environ['RTT_EXEC_PATH']
|
del os.environ['RTT_EXEC_PATH']
|
||||||
@ -202,11 +214,14 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
|||||||
exec_path = os.path.join(exec_path, 'bin')
|
exec_path = os.path.join(exec_path, 'bin')
|
||||||
|
|
||||||
if os.path.exists(exec_path):
|
if os.path.exists(exec_path):
|
||||||
print('set CC to ' + exec_path)
|
Env['log'].debug('set CC to ' + exec_path)
|
||||||
rtconfig.EXEC_PATH = exec_path
|
rtconfig.EXEC_PATH = exec_path
|
||||||
os.environ['RTT_EXEC_PATH'] = exec_path
|
os.environ['RTT_EXEC_PATH'] = exec_path
|
||||||
|
else:
|
||||||
|
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# detect failed, ignore
|
# detect failed, ignore
|
||||||
|
Env['log'].debug(e)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
exec_path = GetOption('exec-path')
|
exec_path = GetOption('exec-path')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user