Skip to content

Commit 2946e4a

Browse files
BernardXiongmysterywolf
authored andcommitted
[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.
1 parent 2ab5827 commit 2946e4a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tools/building.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# 2015-07-25 Bernard Add LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES for
2424
# group definition.
2525
# 2024-04-21 Bernard Add toolchain detection in sdk packages
26+
# 2025-01-05 Bernard Add logging as Env['log']
2627

2728
import os
2829
import sys
@@ -31,6 +32,7 @@
3132
import operator
3233
import rtconfig
3334
import platform
35+
import logging
3436

3537
from SCons.Script import *
3638
from utils import _make_path_relative
@@ -130,6 +132,14 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
130132
AddOptions()
131133

132134
Env = env
135+
136+
# prepare logging and set log
137+
logging.basicConfig(level=logging.INFO, format="%(message)s")
138+
logger = logging.getLogger('rt-scons')
139+
if GetOption('verbose'):
140+
logger.setLevel(logging.DEBUG)
141+
Env['log'] = logger
142+
133143
Rtt_Root = os.path.abspath(root_directory)
134144

135145
# make an absolute root directory
@@ -189,6 +199,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
189199

190200
# auto change the 'RTT_EXEC_PATH' when 'rtconfig.EXEC_PATH' get failed
191201
if not utils.CmdExists(os.path.join(rtconfig.EXEC_PATH, rtconfig.CC)):
202+
Env['log'].debug('To detect CC because CC path in rtconfig.py is invalid:')
203+
Env['log'].debug(' rtconfig.py cc ->' + os.path.join(rtconfig.EXEC_PATH, rtconfig.CC))
192204
if 'RTT_EXEC_PATH' in os.environ:
193205
# del the 'RTT_EXEC_PATH' and using the 'EXEC_PATH' setting on rtconfig.py
194206
del os.environ['RTT_EXEC_PATH']
@@ -202,11 +214,14 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
202214
exec_path = os.path.join(exec_path, 'bin')
203215

204216
if os.path.exists(exec_path):
205-
print('set CC to ' + exec_path)
217+
Env['log'].debug('set CC to ' + exec_path)
206218
rtconfig.EXEC_PATH = exec_path
207219
os.environ['RTT_EXEC_PATH'] = exec_path
220+
else:
221+
Env['log'].debug('No Toolchain found in path(%s).' % exec_path)
208222
except Exception as e:
209223
# detect failed, ignore
224+
Env['log'].debug(e)
210225
pass
211226

212227
exec_path = GetOption('exec-path')

0 commit comments

Comments
 (0)