aboutsummaryrefslogtreecommitdiff
path: root/tools/config.py
blob: 11de99c8ee90a93b38e338d9c97b8922ae2c7926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python3

import os
import argparse
import subprocess

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("--kconfig", metavar="Kconfig", nargs="?", default="Kconfig", help="Top-level Kconfig file (default: Kconfig)")
    parser.add_argument("--dotconfig", metavar="dotconfig", nargs="?", default=".config", help=".config")
    parser.add_argument("--generate", metavar="config_header", nargs="?", default="config.h", help="Generate config file")

    args = parser.parse_args()

    # set srctree, otherwise includes don't work
    os.environ["srctree"] = os.path.dirname(os.path.realpath(args.kconfig))
    os.environ["KCONFIG_CONFIG"] = os.path.realpath(args.dotconfig)

    subprocess.run(["genconfig", os.path.realpath(args.kconfig), "--header-path=" + args.generate], check=True)