diff --git a/.gitignore b/.gitignore index 94487b9..80deb57 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ *.pyc +*.o +kconfig-frontends/.sconsign.dblite +kconfig-frontends/kconfig-mconf diff --git a/building.py b/building.py index ae7960f..a1ba79d 100644 --- a/building.py +++ b/building.py @@ -143,13 +143,14 @@ def GenCconfigFile(env, BuildOptions): # add HAVE_CCONFIG_H definition env.AppendUnique(CPPDEFINES = ['HAVE_CCONFIG_H']) -def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [], rtt_cfg = 'rtconfig.h'): +def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [], rtt_cfg = 'rtconfig.h', rtt_tools = ''): import rtconfig global BuildOptions global Projects global Env global Rtt_Root + global Rtt_Tool # ===== Add option to SCons ===== AddOption('--dist', @@ -241,7 +242,12 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ # set BSP_ROOT in ENV Env['BSP_ROOT'] = Dir('#').abspath - sys.path = sys.path + [os.path.join(Rtt_Root, 'tools')] + if rtt_tools == '': + Rtt_Tool = os.path.join(Rtt_Root, '..', 'rtt_tools') + else: + Rtt_Tool = rtt_tools + + sys.path = sys.path + [Rtt_Tool] # {target_name:(CROSS_TOOL, PLATFORM)} tgt_dict = {'mdk':('keil', 'armcc'), @@ -379,7 +385,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ help = 'make menuconfig for RT-Thread BSP') if GetOption('menuconfig'): from menuconfig import menuconfig - menuconfig(Rtt_Root) + menuconfig(Rtt_Tool, rtt_cfg) exit(0) AddOption('--pyconfig', @@ -396,18 +402,18 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ if GetOption('pyconfig_silent'): from menuconfig import guiconfig_silent - guiconfig_silent(Rtt_Root) + guiconfig_silent(Rtt_Tool, rtt_cfg) exit(0) elif GetOption('pyconfig'): from menuconfig import guiconfig - guiconfig(Rtt_Root) + guiconfig(Rtt_Tool, rtt_cfg) exit(0) configfn = GetOption('useconfig') if configfn: from menuconfig import mk_rtconfig - mk_rtconfig(configfn) + mk_rtconfig(configfn, rtt_cfg) exit(0) diff --git a/menuconfig.py b/menuconfig.py index 33df014..aab0dac 100644 --- a/menuconfig.py +++ b/menuconfig.py @@ -40,14 +40,14 @@ def is_pkg_special_config(config_str): return True return False -def mk_rtconfig(filename): +def mk_rtconfig(filename, cfg_head = 'rtconfig.h'): try: config = open(filename, 'r') except: print('open config:%s failed' % filename) return - rtconfig = open('rtconfig.h', 'w') + rtconfig = open(cfg_head, 'w') rtconfig.write('#ifndef RT_CONFIG_H__\n') rtconfig.write('#define RT_CONFIG_H__\n\n') @@ -233,12 +233,12 @@ def exclude_utestcases(RTT_ROOT): f.write(line) # menuconfig for Linux -def menuconfig(RTT_ROOT): +def menuconfig(RTT_TOOLS, cfg_head): # Exclude utestcases - exclude_utestcases(RTT_ROOT) + exclude_utestcases(RTT_TOOLS) - kconfig_dir = os.path.join(RTT_ROOT, 'tools', 'kconfig-frontends') + kconfig_dir = os.path.join(RTT_TOOLS, 'kconfig-frontends') os.system('scons -C ' + kconfig_dir) touch_env() @@ -249,7 +249,7 @@ def menuconfig(RTT_ROOT): fn = '.config' fn_old = '.config.old' - kconfig_cmd = os.path.join(RTT_ROOT, 'tools', 'kconfig-frontends', 'kconfig-mconf') + kconfig_cmd = os.path.join(RTT_TOOLS, 'kconfig-frontends', 'kconfig-mconf') os.system(kconfig_cmd + ' Kconfig') if os.path.isfile(fn): @@ -263,14 +263,14 @@ def menuconfig(RTT_ROOT): # make rtconfig.h if diff_eq == False: shutil.copyfile(fn, fn_old) - mk_rtconfig(fn) + mk_rtconfig(fn, cfg_head) # guiconfig for windows and linux -def guiconfig(RTT_ROOT): +def guiconfig(RTT_TOOLS, cfg_head): import pyguiconfig # Exclude utestcases - exclude_utestcases(RTT_ROOT) + exclude_utestcases(RTT_TOOLS) if sys.platform != 'win32': touch_env() @@ -296,15 +296,15 @@ def guiconfig(RTT_ROOT): # make rtconfig.h if diff_eq == False: shutil.copyfile(fn, fn_old) - mk_rtconfig(fn) + mk_rtconfig(fn, cfg_head) # guiconfig for windows and linux -def guiconfig_silent(RTT_ROOT): +def guiconfig_silent(RTT_TOOLS, cfg_head): import defconfig # Exclude utestcases - exclude_utestcases(RTT_ROOT) + exclude_utestcases(RTT_TOOLS) if sys.platform != 'win32': touch_env() @@ -319,4 +319,4 @@ def guiconfig_silent(RTT_ROOT): defconfig.main() # silent mode, force to make rtconfig.h - mk_rtconfig(fn) + mk_rtconfig(fn, cfg_head)