• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# encoding=utf-8
2# ============================================================================
3# @brief    Show the menuconfig of LiteOS
4
5# Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED.
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#     http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17# ============================================================================
18import os, sys
19from kconfiglib import Kconfig
20from menuconfig import menuconfig
21
22def mconf_set_env(style, conf, header):
23    """
24    Set Kconfig Env
25    """
26    os.environ["MENUCONFIG_STYLE"] = style
27    os.environ["KCONFIG_CONFIG"] = conf
28    os.environ["KCONFIG_CONFIG_HEADER"] = header
29    os.environ["KCONFIG_AUTOHEADER"] = os.path.join("targets", "menuconfig.h")
30    os.environ["CONFIG_"] = ""
31    os.environ["KCONFIG_ARCH_PATH"] = "arch"
32    os.environ["KCONFIG_KERNEL_PATH"] = "kernel"
33
34def mconfig(config):
35    kconfig = os.path.join("build", "menuconfig", "config.in")
36    display_style = "default selection=fg:white,bg:blue"
37    target_conf = config
38    header = "# Generated by LiteOS Kconfig Tool"
39    mconf_set_env(display_style, target_conf, header)
40    kconf = Kconfig(filename=kconfig)
41    menuconfig(kconf)   # menuconfig
42    kconf.write_autoconf()
43
44if __name__ == "__main__":
45    if len(sys.argv) != 2:
46        print("Parameters invalid! You should type like this: python(3) show_menuconfig.py ws63")
47        exit(1)
48
49    os.chdir("Huawei_LiteOS")
50    mconfig("tools/build/config/" + sys.argv[1] + ".config")