mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-06 11:20:32 +00:00
scripts: introduce .config/config.h generators
This patch introduces some scripts that takes a Kconfig script and generates .config or config.h. These scripts are general and can be used by the hypervisor, dm, tools, etc. as long as proper make targets are added. Note: Kconfiglib by Ulf Magnusson is ISC licensed. v4 -> v5: * Add minimalconfig which creates a defconfig by minimizing a given .config. v3 -> v4: * silentoldconfig now properly generate a .config if an old one does not exist. v2 -> v3: * Add license info and the permission notice of Kconfiglib. * Mention the input Kconfig in the script descriptions. v1 -> v2: * Drop kconfiglib.py. The getting started guide will be updated accordingly and dependency checks will be added to Makefile in the following patches. Signed-off-by: Junjie Mao <junjie.mao@intel.com> Reviewed-by: Kevin Tian <kevin.tian@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
This commit is contained in:
39
scripts/kconfig/defconfig.py
Normal file
39
scripts/kconfig/defconfig.py
Normal file
@@ -0,0 +1,39 @@
|
||||
# Copyright (C) 2018 Intel Corporation.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# This script takes a Kconfig and a defconfig file, and expands it to a .config
|
||||
# with all default values listed explicitly.
|
||||
|
||||
import sys, os
|
||||
|
||||
# Kconfiglib: Copyright (c) 2011-2018, Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
# Refer to scripts/kconfig/LICENSE.kconfiglib for the permission notice.
|
||||
import kconfiglib
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <defconfig> <path to .config>\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
defconfig_path = sys.argv[2]
|
||||
if not os.path.isfile(defconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % defconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
sys.stdout.write("Default configuration based on %s.\n" % defconfig_path)
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
kconfig.load_config(defconfig_path)
|
||||
kconfig.write_config(sys.argv[3])
|
||||
sys.stdout.write("Configuration written to %s.\n" % sys.argv[3])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user