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

TODO: choice语法块中不可再包含if语法块 #1564

Closed
mysterywolf opened this issue Feb 6, 2023 · 1 comment
Closed

TODO: choice语法块中不可再包含if语法块 #1564

mysterywolf opened this issue Feb 6, 2023 · 1 comment

Comments

@mysterywolf
Copy link
Member

mysterywolf commented Feb 6, 2023

1.软件包对 RT-Thread 版本的判断使用如下方法:
在进行 RT-Thread 版本限制的时候,要注意此软件包或软件包版本是否真的在此 RT-Thread 版本不可用,还是由于 bsp 的问题
RT_VER_NUM 这个宏是在Kconfig中定义并在rtconfig.h中自动生成的
在.c/.h文件下采用如下方法(不要使用<rtthread.h>里定义的版本宏来判断)

#if RT_VER_NUM >= 0x50000
。。。
#else
。。。
#endif /*RT_VER_NUM >= 0x50000*/
@mysterywolf
Copy link
Member Author

mysterywolf commented Mar 5, 2023

2.针对Kconfig文件下,需要注意choice选择块内,不可再包含if块,否则在Kconfig-C版本前端中无法正确识别(python前端可以正确识别),如下为错误示范:

choice
    prompt "version"
    help
        Select the pahomqtt version
    if RT_VER_NUM >= 0x40100
        config PKG_USING_PAHOMQTT_LATEST
            bool "latest"
    endif

    if RT_VER_NUM < 0x40100
        config PKG_USING_PAHOMQTT_V110
            bool "v1.1.0"
    endif

endchoice

以下为正确示范,采用depends on关键字指定版本依赖,可选,如果使用全部RT-Thread版本则不需要加depends on:

    choice
        prompt "version"
        help
            Select the pahomqtt version

        config PKG_USING_PAHOMQTT_LATEST
            bool "latest"
            depends on RT_VER_NUM >= 0x40100

        config PKG_USING_PAHOMQTT_V110
            bool "v1.1.0"
            depends on RT_VER_NUM < 0x40100

    endchoice

默认版本可以不用特意用default关键字指定,按照版本从高到低排序即可,choice语法块会自动选择满足要求的最高版本。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant