1#!/usr/bin/env python
2
3# SPDX-License-Identifier: BSD-3-Clause
4#
5# Copyright (c) 2019, Intel Corporation. All rights reserved.
6#
7# Author: Janusz Jankowski <janusz.jankowski@linux.intel.com>
8
9# Loads current config file and updates with values from another
10# config file. Configs that are not set in neither of files are set
11# to default value.
12#
13# Usage:
14#   overrideconfig.py KCONFIG_FILENAME CONFIG_OVERRIDE_FILE
15
16import os
17import sys
18
19import kconfiglib
20
21
22def main():
23    if len(sys.argv) < 3:
24        sys.exit("usage: {} KCONFIG_FILENAME CONFIG_OVERRIDE_FILE"
25	    .format(sys.argv[0]))
26
27    kconf = kconfiglib.Kconfig(sys.argv[1])
28    kconf.load_config()
29
30    kconf.disable_override_warnings()
31    kconf.disable_redun_warnings()
32
33    kconf.load_config(filename=sys.argv[2], replace=False)
34
35    kconf.enable_override_warnings()
36    kconf.enable_redun_warnings()
37
38    kconf.write_config()
39
40
41if __name__ == "__main__":
42    main()
43