forked from espressif/esp-idf
confgen: Create config file if missing
This commit is contained in:
committed by
Angus Gratton
parent
c671a0c3eb
commit
99a2359c5c
@@ -62,6 +62,7 @@ function(build_component_config)
|
|||||||
execute_process(COMMAND python ${IDF_PATH}/tools/kconfig_new/confgen.py
|
execute_process(COMMAND python ${IDF_PATH}/tools/kconfig_new/confgen.py
|
||||||
--kconfig ${ROOT_KCONFIG}
|
--kconfig ${ROOT_KCONFIG}
|
||||||
--config ${SDKCONFIG}
|
--config ${SDKCONFIG}
|
||||||
|
--create-config-if-missing
|
||||||
--env "COMPONENT_KCONFIGS=${kconfigs}"
|
--env "COMPONENT_KCONFIGS=${kconfigs}"
|
||||||
--env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
|
--env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
|
||||||
--output header ${SDKCONFIG_HEADER}
|
--output header ${SDKCONFIG_HEADER}
|
||||||
|
@@ -39,13 +39,18 @@ def main():
|
|||||||
nargs='?',
|
nargs='?',
|
||||||
default=None)
|
default=None)
|
||||||
|
|
||||||
|
parser.add_argument('--create-config-if-missing',
|
||||||
|
help='If set, a new config file will be saved if the old one is not found',
|
||||||
|
action='store_true')
|
||||||
|
|
||||||
parser.add_argument('--kconfig',
|
parser.add_argument('--kconfig',
|
||||||
help='KConfig file with config item definitions',
|
help='KConfig file with config item definitions',
|
||||||
required=True)
|
required=True)
|
||||||
|
|
||||||
parser.add_argument('--output', nargs=2, action='append',
|
parser.add_argument('--output', nargs=2, action='append',
|
||||||
help='Write output file (format and output filename)',
|
help='Write output file (format and output filename)',
|
||||||
metavar=('FORMAT', 'FILENAME'))
|
metavar=('FORMAT', 'FILENAME'),
|
||||||
|
default=[])
|
||||||
|
|
||||||
parser.add_argument('--env', action='append', default=[],
|
parser.add_argument('--env', action='append', default=[],
|
||||||
help='Environment to set when evaluating the config file', metavar='NAME=VAL')
|
help='Environment to set when evaluating the config file', metavar='NAME=VAL')
|
||||||
@@ -69,7 +74,13 @@ def main():
|
|||||||
config = kconfiglib.Kconfig(args.kconfig)
|
config = kconfiglib.Kconfig(args.kconfig)
|
||||||
|
|
||||||
if args.config is not None:
|
if args.config is not None:
|
||||||
|
if os.path.exists(args.config):
|
||||||
config.load_config(args.config)
|
config.load_config(args.config)
|
||||||
|
elif args.create_config_if_missing:
|
||||||
|
print("Creating config file %s..." % args.config)
|
||||||
|
config.write_config(args.config)
|
||||||
|
else:
|
||||||
|
raise RuntimeError("Config file not found: %s" % args.config)
|
||||||
|
|
||||||
for output_type, filename in args.output:
|
for output_type, filename in args.output:
|
||||||
temp_file = tempfile.mktemp(prefix="confgen_tmp")
|
temp_file = tempfile.mktemp(prefix="confgen_tmp")
|
||||||
@@ -146,5 +157,15 @@ OUTPUT_FORMATS = {
|
|||||||
"cmake" : write_cmake,
|
"cmake" : write_cmake,
|
||||||
"docs" : gen_kconfig_doc.write_docs }
|
"docs" : gen_kconfig_doc.write_docs }
|
||||||
|
|
||||||
|
class FatalError(RuntimeError):
|
||||||
|
"""
|
||||||
|
Class for runtime errors (not caused by bugs but by user input).
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
main()
|
main()
|
||||||
|
except FatalError as e:
|
||||||
|
print("A fatal error occurred: %s" % e)
|
||||||
|
sys.exit(2)
|
||||||
|
Reference in New Issue
Block a user