美文网首页
kconfig 实例1: 基于 python 的 kconfig

kconfig 实例1: 基于 python 的 kconfig

作者: wjundong | 来源:发表于2022-07-26 17:20 被阅读0次

kconfig 实例1: 基于 python 的 kconfig 系统

安装

pip install kconfiglib

使用

  • kconfig.py

    #!/usr/bin/env python
    # -*- coding: UTF-8 -*-
    
    import os, sys
    from kconfiglib import Kconfig
    from menuconfig import menuconfig
    
    def mconf_set_env():
        """
        Set Kconfig Env
        """
        os.environ["MENUCONFIG_STYLE"] = "default selection=fg:white,bg:blue"
        os.environ["KCONFIG_CONFIG"] = os.path.join(".config")
        os.environ["KCONFIG_CONFIG_HEADER"] = "# Generated by My Kconfig Demo"
        os.environ["KCONFIG_AUTOHEADER"] = os.path.join("config.h")
        os.environ["CONFIG_"] = ""
    
    def mconfig(argv):
        mconf_set_env()
        kconf = Kconfig(filename="./config.in")
        menuconfig(kconf)
        kconf.write_autoconf()
    
    if __name__ == "__main__":
        mconfig(sys.argv)
    
    
  • config.in

    mainmenu "My Kconfig Demo"
    
    menu "Debug"
    config CONFIG_DEBUG
        bool "Enable debug"
        default n
        help
            Will print debug information if enable.
    
    config CONFIG_DEBUG_UART
        bool "Enable UART debug"
        default n
        depends on CONFIG_DEBUG
    
    endmenu
    
  • Makefile

    menuconfig:
        python kconfig.py
    
    

演示

$ ls -a
Makefile config.in  kconfig.py
$ make menuconfig
python kconfig.py
Loaded configuration '.config'
Configuration saved to '.config'
$ ls -a
Makefile config.in  kconfig.py .config config.h

执行 make menuconfig 后多出 .config config.h

相关文章

  • kconfig 实例1: 基于 python 的 kconfig

    kconfig 实例1: 基于 python 的 kconfig 系统 安装 使用 kconfig.py#!/us...

  • 内核Kconfig

    Documentation/kbuild/kconfig-language.txt 主目录下的Kconfig文件,...

  • Kconfig 总结

    config XXXX 或者 menuconfig XXXX 表示一个配置节点的开始, XXXX 是将要形成的宏定...

  • 平台整编报错

    高通平台编译报错: LEX scripts/kconfig/lexer.lex.c/bin/sh: 1: ...

  • 注册platform device

    1修改 vim drivers/char/Kconfig ,添加HELLO_CTL 2修改 vim arch/ar...

  • 编译高通代码报错解决fatal error: openssl/b

    1 最近编译高通代码一直报错 scripts/kconfig/conf --silentoldconfig Kc...

  • Kconfig仿写

    一、查看已经配置好的内核 注意CONFIG_LEDS_CTL=y ,下一步在CONFIG_LEDS_CTL之前添加...

  • Kconfig学习记录

    运行 make menuconfig 等时,配置工具首先分析与体系结构对应的/arch/xxx/Kconfig 文...

  • Formal Semantics of the Kconfig

    某天翻译的,希望更多的人了解,让世界更美好。 背后的形式语义看起来复杂,不过实际用起来是比较简单的。 可以在大型软...

  • kconfig语法整理

    配置文件kconfig语法 配置文件描述了菜单选项,每行都是以一关键字开头(除了帮助信息),下一个关键字结束此菜单...

网友评论

      本文标题:kconfig 实例1: 基于 python 的 kconfig

      本文链接:https://www.haomeiwen.com/subject/itbzirtx.html