Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux/MacOS support #185

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 51 additions & 30 deletions cmds/cmd_menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
from vars import Import
from .cmd_package.cmd_package_utils import find_bool_macro_in_config, find_IAR_EXEC_PATH, find_MDK_EXEC_PATH

def build_kconfig_frontends(rtt_root):
kconfig_dir = os.path.join(rtt_root, 'tools', 'kconfig-frontends')
os.system('scons -C ' + kconfig_dir)

def is_pkg_special_config(config_str):
"""judge if it's CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER"""
Expand Down Expand Up @@ -135,7 +138,10 @@ def mk_rtconfig(filename):

def cmd(args):
env_root = Import('env_root')
os_version = platform.platform(True).split('-')[2][:3]
os.environ['PKGS_ROOT'] = Import("pkgs_root")
rtt_root = Import('rtt_root')
if platform.system() == "Windows":
os_version = platform.platform(True).split('-')[2][:3]
kconfig_win7_path = os.path.join(
env_root, 'tools', 'bin', 'kconfig-mconf_win7.exe')

Expand Down Expand Up @@ -172,40 +178,55 @@ def cmd(args):
elif args.menuconfig_g:
mk_rtconfig(fn)
elif args.menuconfig_silent:
if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig -n')
mk_rtconfig(fn)
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig -n')
else:
if platform.system() == "Windows":
if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig -n')
mk_rtconfig(fn)
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig -n')
else:
os.system('kconfig-mconf Kconfig -n')
else:
build_kconfig_frontends(rtt_root)
kconfig_cmd = os.path.join(rtt_root, 'tools', 'kconfig-frontends', 'kconfig-mconf')
os.system(kconfig_cmd + ' Kconfig -n')

elif args.menuconfig_setting:
env_kconfig_path = os.path.join(env_root, r'tools\scripts\cmds')
env_kconfig_path = os.path.join(env_root, 'tools', 'scripts', 'cmds')
beforepath = os.getcwd()
os.chdir(env_kconfig_path)

if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig')
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig')
else:
if platform.system() == "Windows":
if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig')
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig')
else:
os.system('kconfig-mconf Kconfig')
else:
build_kconfig_frontends(rtt_root)
kconfig_cmd = os.path.join(rtt_root, 'tools', 'kconfig-frontends', 'kconfig-mconf')
os.system(kconfig_cmd + ' Kconfig')

os.chdir(beforepath)

return

else:
if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig')
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig')
else:
if platform.system() == "Windows":
if float(os_version) >= 6.2:
os.system('kconfig-mconf Kconfig')
else:
if os.path.isfile(kconfig_win7_path):
os.system('kconfig-mconf_win7 Kconfig')
else:
os.system('kconfig-mconf Kconfig')
else:
build_kconfig_frontends(rtt_root)
kconfig_cmd = os.path.join(rtt_root, 'tools', 'kconfig-frontends', 'kconfig-mconf')
os.system(kconfig_cmd + ' Kconfig')

if os.path.isfile(fn):
mtime2 = os.path.getmtime(fn)
Expand All @@ -215,17 +236,17 @@ def cmd(args):
if mtime != mtime2:
mk_rtconfig(fn)

if platform.system() == "Windows":
env_kconfig_path = os.path.join(env_root, r'tools\scripts\cmds')
fn = os.path.join(env_kconfig_path, '.config')

if not os.path.isfile(fn):
return
env_kconfig_path = os.path.join(env_root, 'tools', 'scripts', 'cmds')
fn = os.path.join(env_kconfig_path, '.config')

if find_bool_macro_in_config(fn, 'SYS_AUTO_UPDATE_PKGS'):
os.system('pkgs --update')
print("==============================>The packages have been updated completely.")
if not os.path.isfile(fn):
return

if find_bool_macro_in_config(fn, 'SYS_AUTO_UPDATE_PKGS'):
os.system('pkgs --update')
print("==============================>The packages have been updated completely.")

if platform.system() == "Windows":
if find_bool_macro_in_config(fn, 'SYS_CREATE_MDK_IAR_PROJECT'):
mdk_path = find_MDK_EXEC_PATH()
iar_path = find_IAR_EXEC_PATH()
Expand Down
2 changes: 1 addition & 1 deletion cmds/cmd_package/cmd_package_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_mac_address():
def Information_statistics():
env_root = Import('env_root')
# get the .config file from env
env_kconfig_path = os.path.join(env_root, 'tools\scripts\cmds')
env_kconfig_path = os.path.join(env_root, 'tools', 'scripts', 'cmds')
env_config_file = os.path.join(env_kconfig_path, '.config')

if find_bool_macro_in_config(env_config_file, 'SYS_PKGS_USING_STATISTICS'):
Expand Down
8 changes: 8 additions & 0 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,24 @@ def get_bsp_root():

return bsp_root

def get_rtt_root(bsp_root):
rtt_root = os.getenv("RTT_ROOT")
if rtt_root is None:
rtt_root = os.path.join(bsp_root, '..', '..')
Copy link
Member

@mysterywolf mysterywolf Oct 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块可能不一定是向上反两级是rt-thread根目录,有些BSP有可能是三级。靠这种方法可能不可靠。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块可以问问熊大或者郭老师有没有什么更好的方法

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RTT_ROOT 在什么情况下会缺失?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我在macos跑一直是缺失的

return rtt_root


def export_environment_variable():
script_root = os.path.split(os.path.realpath(__file__))[0]
sys.path = sys.path + [os.path.join(script_root)]
bsp_root = get_bsp_root()
rtt_root = get_rtt_root(bsp_root)
env_root = get_env_root()
pkgs_root = get_package_root(env_root)

Export('env_root')
Export('bsp_root')
Export('rtt_root')
Export('pkgs_root')


Expand Down
1 change: 1 addition & 0 deletions menuconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python ~/.env/tools/scripts/env.py menuconfig $*
mysterywolf marked this conversation as resolved.
Show resolved Hide resolved