summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2021-09-02 10:03:03 +0800
committerGitHub <[email protected]>2021-09-02 10:03:03 +0800
commitc89e7e43eddade839c62d4cfc45606a03e7aab31 (patch)
treef9453504e7a740011cbf376d3cc0bc6148024980 /components
parent42d90b9430c651c94ea7b022d321524b32a124e4 (diff)
parent1997113fbca8894dcaad75a6fa4e7b42396a4031 (diff)
Merge pull request #4976 from mysterywolf/finsh_kconfig
[finsh] finsh组件可以选择是否包含内置命令
Diffstat (limited to 'components')
-rw-r--r--components/finsh/Kconfig102
-rw-r--r--components/finsh/SConscript6
-rw-r--r--components/finsh/msh.c22
3 files changed, 71 insertions, 59 deletions
diff --git a/components/finsh/Kconfig b/components/finsh/Kconfig
index 637b1a30c1..cf4e673c75 100644
--- a/components/finsh/Kconfig
+++ b/components/finsh/Kconfig
@@ -11,61 +11,69 @@ config RT_USING_MSH
if RT_USING_MSH
-config FINSH_THREAD_NAME
- string "The msh thread name"
- default "tshell"
-config FINSH_USING_HISTORY
- bool "Enable command history feature"
- default y
-if FINSH_USING_HISTORY
-config FINSH_HISTORY_LINES
- int "The command history line number"
- default 5
-endif
+ config FINSH_THREAD_NAME
+ string "The msh thread name"
+ default "tshell"
-config FINSH_USING_SYMTAB
- bool "Using symbol table for commands"
- default y
+ config FINSH_THREAD_PRIORITY
+ int "The priority level value of thread"
+ default 20
-config FINSH_USING_DESCRIPTION
- bool "Keeping description in symbol table"
- default y
+ config FINSH_THREAD_STACK_SIZE
+ int "The stack size for thread"
+ default 4096
-config FINSH_ECHO_DISABLE_DEFAULT
- bool "Disable the echo mode in default"
- default n
-
-config FINSH_THREAD_PRIORITY
- int "The priority level value of thread"
- default 20
+ config FINSH_USING_HISTORY
+ bool "Enable command history feature"
+ default y
-config FINSH_THREAD_STACK_SIZE
- int "The stack size for thread"
- default 4096
+ if FINSH_USING_HISTORY
+ config FINSH_HISTORY_LINES
+ int "The command history line number"
+ default 5
+ endif
-config FINSH_CMD_SIZE
- int "The command line size for shell"
- default 80
+ config FINSH_USING_SYMTAB
+ bool "Using symbol table for commands"
+ default y
-config FINSH_USING_AUTH
- bool "shell support authentication"
- default n
+ config FINSH_CMD_SIZE
+ int "The command line size for shell"
+ default 80
-if FINSH_USING_AUTH
-config FINSH_DEFAULT_PASSWORD
- string "The default password for shell authentication"
- default "rtthread"
-config FINSH_PASSWORD_MIN
- int "The password min length"
- default 6
-config FINSH_PASSWORD_MAX
- int "The password max length"
- default RT_NAME_MAX
-endif
+ config MSH_USING_BUILT_IN_COMMANDS
+ bool "Enable built-in commands, such as list_thread"
+ default y
+
+ config FINSH_USING_DESCRIPTION
+ bool "Keeping description in symbol table"
+ default y
+
+ config FINSH_ECHO_DISABLE_DEFAULT
+ bool "Disable the echo mode in default"
+ default n
+
+ config FINSH_USING_AUTH
+ bool "shell support authentication"
+ default n
+
+ if FINSH_USING_AUTH
+ config FINSH_DEFAULT_PASSWORD
+ string "The default password for shell authentication"
+ default "rtthread"
+
+ config FINSH_PASSWORD_MIN
+ int "The password min length"
+ default 6
+
+ config FINSH_PASSWORD_MAX
+ int "The password max length"
+ default RT_NAME_MAX
+ endif
-config FINSH_ARG_MAX
- int "The number of arguments for a shell command"
- default 10
+ config FINSH_ARG_MAX
+ int "The number of arguments for a shell command"
+ default 10
endif
diff --git a/components/finsh/SConscript b/components/finsh/SConscript
index 1a6d7c8fc7..28fe02bac5 100644
--- a/components/finsh/SConscript
+++ b/components/finsh/SConscript
@@ -3,15 +3,17 @@ from building import *
cwd = GetCurrentDir()
src = Split('''
shell.c
-cmd.c
msh.c
''')
+if GetDepend('MSH_USING_BUILT_IN_COMMANDS'):
+ src += ['cmd.c']
+
if GetDepend('RT_USING_DFS'):
src += ['msh_file.c']
CPPPATH = [cwd]
-group = DefineGroup('msh', src, depend = ['RT_USING_FINSH'], CPPPATH = CPPPATH)
+group = DefineGroup('Finsh', src, depend = ['RT_USING_FINSH'], CPPPATH = CPPPATH)
Return('group')
diff --git a/components/finsh/msh.c b/components/finsh/msh.c
index 899a6567b1..86985c561c 100644
--- a/components/finsh/msh.c
+++ b/components/finsh/msh.c
@@ -54,6 +54,7 @@ int msh_help(int argc, char **argv)
}
MSH_CMD_EXPORT_ALIAS(msh_help, help, RT - Thread shell help.);
+#ifdef MSH_USING_BUILT_IN_COMMANDS
int cmd_ps(int argc, char **argv)
{
extern long list_thread(void);
@@ -77,13 +78,14 @@ int cmd_free(int argc, char **argv)
#ifdef RT_USING_MEMHEAP_AS_HEAP
list_memheap();
-#else
+#else /* RT_USING_MEMHEAP_AS_HEAP */
list_mem();
#endif
return 0;
}
MSH_CMD_EXPORT_ALIAS(cmd_free, free, Show the memory usage in the system.);
-#endif
+#endif /* RT_USING_HEAP */
+#endif /* MSH_USING_BUILT_IN_COMMANDS */
static int msh_split(char *cmd, rt_size_t length, char *argv[FINSH_ARG_MAX])
{
@@ -270,7 +272,7 @@ int system(const char *command)
return ret;
}
RTM_EXPORT(system);
-#endif
+#endif /* defined(RT_USING_MODULE) && defined(RT_USING_DFS) */
static int _msh_exec_cmd(char *cmd, rt_size_t length, int *retp)
{
@@ -339,7 +341,7 @@ static int _msh_exec_lwp(char *cmd, rt_size_t length)
return 0;
}
-#endif
+#endif /* defined(RT_USING_LWP) && defined(RT_USING_DFS) */
int msh_exec(char *cmd, rt_size_t length)
{
@@ -376,15 +378,15 @@ int msh_exec(char *cmd, rt_size_t length)
{
return 0;
}
-#endif
+#endif /* RT_USING_MODULE */
#ifdef RT_USING_LWP
if (_msh_exec_lwp(cmd, length) == 0)
{
return 0;
}
-#endif
-#endif
+#endif /* RT_USING_LWP */
+#endif /* RT_USING_DFS */
/* truncate the cmd at the first space. */
{
@@ -534,7 +536,7 @@ void msh_auto_complete_path(char *path)
closedir(dir);
rt_free(full_path);
}
-#endif
+#endif /* RT_USING_DFS */
void msh_auto_complete(char *prefix)
{
@@ -575,9 +577,9 @@ void msh_auto_complete(char *prefix)
{
msh_auto_complete_path(ptr);
}
-#endif
+#endif /* RT_USING_MODULE */
}
-#endif
+#endif /* RT_USING_DFS */
/* checks in internal command */
{