-
Notifications
You must be signed in to change notification settings - Fork 5.4k
[components][finsh] 新增:MSH命令 options补全 #7304
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
|
|
||
| #ifdef RT_USING_FINSH | ||
| #include <finsh.h> | ||
| #include "msh.h" | ||
|
|
||
| #define LIST_FIND_OBJ_NR 8 | ||
|
|
||
|
|
@@ -894,68 +895,69 @@ long list_device(void) | |
| } | ||
| #endif /* RT_USING_DEVICE */ | ||
|
|
||
| #ifndef FINSH_OPTION_COMPLETION_ENABLED | ||
| int cmd_list(int argc, char **argv) | ||
| { | ||
| if(argc == 2) | ||
| if (argc == 2) | ||
| { | ||
| if(strcmp(argv[1], "thread") == 0) | ||
| if (strcmp(argv[1], "thread") == 0) | ||
| { | ||
| list_thread(); | ||
| } | ||
| else if(strcmp(argv[1], "timer") == 0) | ||
| else if (strcmp(argv[1], "timer") == 0) | ||
| { | ||
| list_timer(); | ||
| } | ||
| #ifdef RT_USING_SEMAPHORE | ||
| else if(strcmp(argv[1], "sem") == 0) | ||
| else if (strcmp(argv[1], "sem") == 0) | ||
| { | ||
| list_sem(); | ||
| } | ||
| #endif /* RT_USING_SEMAPHORE */ | ||
| #ifdef RT_USING_EVENT | ||
| else if(strcmp(argv[1], "event") == 0) | ||
| else if (strcmp(argv[1], "event") == 0) | ||
| { | ||
| list_event(); | ||
| } | ||
| #endif /* RT_USING_EVENT */ | ||
| #ifdef RT_USING_MUTEX | ||
| else if(strcmp(argv[1], "mutex") == 0) | ||
| else if (strcmp(argv[1], "mutex") == 0) | ||
| { | ||
| list_mutex(); | ||
| } | ||
| #endif /* RT_USING_MUTEX */ | ||
| #ifdef RT_USING_MAILBOX | ||
| else if(strcmp(argv[1], "mailbox") == 0) | ||
| else if (strcmp(argv[1], "mailbox") == 0) | ||
| { | ||
| list_mailbox(); | ||
| } | ||
| #endif /* RT_USING_MAILBOX */ | ||
| #ifdef RT_USING_MESSAGEQUEUE | ||
| else if(strcmp(argv[1], "msgqueue") == 0) | ||
| else if (strcmp(argv[1], "msgqueue") == 0) | ||
| { | ||
| list_msgqueue(); | ||
| } | ||
| #endif /* RT_USING_MESSAGEQUEUE */ | ||
| #ifdef RT_USING_MEMHEAP | ||
| else if(strcmp(argv[1], "memheap") == 0) | ||
| else if (strcmp(argv[1], "memheap") == 0) | ||
| { | ||
| list_memheap(); | ||
| } | ||
| #endif /* RT_USING_MEMHEAP */ | ||
| #ifdef RT_USING_MEMPOOL | ||
| else if(strcmp(argv[1], "mempool") == 0) | ||
| else if (strcmp(argv[1], "mempool") == 0) | ||
| { | ||
| list_mempool(); | ||
| } | ||
| #endif /* RT_USING_MEMPOOL */ | ||
| #ifdef RT_USING_DEVICE | ||
| else if(strcmp(argv[1], "device") == 0) | ||
| else if (strcmp(argv[1], "device") == 0) | ||
| { | ||
| list_device(); | ||
| } | ||
| #endif /* RT_USING_DEVICE */ | ||
| #ifdef RT_USING_DFS | ||
| else if(strcmp(argv[1], "fd") == 0) | ||
| else if (strcmp(argv[1], "fd") == 0) | ||
| { | ||
| extern int list_fd(void); | ||
| list_fd(); | ||
|
|
@@ -1006,4 +1008,94 @@ int cmd_list(int argc, char **argv) | |
| } | ||
| MSH_CMD_EXPORT_ALIAS(cmd_list, list, list objects); | ||
|
|
||
| #else | ||
| CMD_OPTIONS_STATEMENT(cmd_list) | ||
| int cmd_list(int argc, char **argv) | ||
| { | ||
| if (argc == 2) | ||
| { | ||
| switch (MSH_OPT_ID_GET(cmd_list)) | ||
| { | ||
| case RT_Object_Class_Thread: list_thread(); break; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 感觉这么改,有点复杂,还是感觉如何支持二级命令补全。比较方便
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个只是命令函数中的使用示例,补全和这部分代码没关系 |
||
| case RT_Object_Class_Timer: list_timer(); break; | ||
| #ifdef RT_USING_SEMAPHORE | ||
| case RT_Object_Class_Semaphore: list_sem(); break; | ||
| #endif /* RT_USING_SEMAPHORE */ | ||
| #ifdef RT_USING_EVENT | ||
| case RT_Object_Class_Event: list_event(); break; | ||
| #endif /* RT_USING_EVENT */ | ||
| #ifdef RT_USING_MUTEX | ||
| case RT_Object_Class_Mutex: list_mutex(); break; | ||
| #endif /* RT_USING_MUTEX */ | ||
| #ifdef RT_USING_MAILBOX | ||
| case RT_Object_Class_MailBox: list_mailbox(); break; | ||
| #endif /* RT_USING_MAILBOX */ | ||
| #ifdef RT_USING_MESSAGEQUEUE | ||
| case RT_Object_Class_MessageQueue: list_msgqueue(); break; | ||
| #endif /* RT_USING_MESSAGEQUEUE */ | ||
| #ifdef RT_USING_MEMHEAP | ||
| case RT_Object_Class_MemHeap: list_memheap(); break; | ||
| #endif /* RT_USING_MEMHEAP */ | ||
| #ifdef RT_USING_MEMPOOL | ||
| case RT_Object_Class_MemPool: list_mempool(); break; | ||
| #endif /* RT_USING_MEMPOOL */ | ||
| #ifdef RT_USING_DEVICE | ||
| case RT_Object_Class_Device: list_device(); break; | ||
| #endif /* RT_USING_DEVICE */ | ||
| #ifdef RT_USING_DFS | ||
| case 0x100: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 直接十六进制数字,什么情况哈
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可以考虑另外定义一组宏定义,例如 #define CMD_LIST_OPT_INDEX_THREAD 0
// ..... |
||
| { | ||
| extern int list_fd(void); | ||
| list_fd(); | ||
| break; | ||
| } | ||
| #endif /* RT_USING_DFS */ | ||
| default: | ||
| goto _usage; | ||
| break; | ||
| }; | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| _usage: | ||
| rt_kprintf("Usage: list [options]\n"); | ||
| rt_kprintf("[options]:\n"); | ||
| MSH_OPT_DUMP(cmd_list); | ||
| return 0; | ||
| } | ||
| CMD_OPTIONS_NODE_START(cmd_list) | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Thread, thread, list threads) | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Timer, timer, list timers) | ||
| #ifdef RT_USING_SEMAPHORE | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Semaphore, sem, list semaphores) | ||
| #endif /* RT_USING_SEMAPHORE */ | ||
| #ifdef RT_USING_EVENT | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Event, event, list events) | ||
| #endif /* RT_USING_EVENT */ | ||
| #ifdef RT_USING_MUTEX | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Mutex, mutex, list mutexs) | ||
| #endif /* RT_USING_MUTEX */ | ||
| #ifdef RT_USING_MAILBOX | ||
| CMD_OPTIONS_NODE(RT_Object_Class_MailBox, mailbox, list mailboxs) | ||
| #endif /* RT_USING_MAILBOX */ | ||
| #ifdef RT_USING_MESSAGEQUEUE | ||
| CMD_OPTIONS_NODE(RT_Object_Class_MessageQueue, msgqueue, list message queues) | ||
| #endif /* RT_USING_MESSAGEQUEUE */ | ||
| #ifdef RT_USING_MEMHEAP | ||
| CMD_OPTIONS_NODE(RT_Object_Class_MemHeap, memheap, list memory heaps) | ||
| #endif /* RT_USING_MEMHEAP */ | ||
| #ifdef RT_USING_MEMPOOL | ||
| CMD_OPTIONS_NODE(RT_Object_Class_MemPool, mempool, list memory pools) | ||
| #endif /* RT_USING_MEMPOOL */ | ||
| #ifdef RT_USING_DEVICE | ||
| CMD_OPTIONS_NODE(RT_Object_Class_Device, device, list devices) | ||
| #endif /* RT_USING_DEVICE */ | ||
| #ifdef RT_USING_DFS | ||
| CMD_OPTIONS_NODE(0x100, fd, list file descriptors) | ||
| #endif /* RT_USING_DFS */ | ||
| CMD_OPTIONS_NODE_END | ||
| MSH_CMD_EXPORT_ALIAS(cmd_list, list, list objects, optenable); | ||
| #endif /* FINSH_OPTION_COMPLETION_ENABLED */ | ||
|
|
||
| #endif /* RT_USING_FINSH */ | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
這個文件自動生成的,可以刪除。不需要修改。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改默认值的时候,最好还是确保所有 bsp 都改了吧。不过讲真,个人认为最好直接不要在 git 仓库存这种可以自动生成的文件。linux 就是这样做的。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这文件是存储的用户配置,比如一些选项打开或者没打开,必须要存的,linux 也有存的
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
首先这些文件是可以自动生成的 (kconfig 文件有默认配置值)。其次,维护负担问题,例如修改某个组件的kconfig ,那几乎所有 bsp 的 .config 文件都需要修改 (如果不改, 保持历史状态,存的意义何在?). 最直观的感受是这些 .config 文件都很相似。。。
linux 没存,

.config在linux默认是ignore的,最多只有一个xxx_defaultconfig文件, 用来存储某个 soc 的部分特殊配置. 然后ACH=XXX ... make xxx_defaultconfig自动生成完整的.config文件。