# Sets up flash-related targets
function(idf_add_executable)
set(exe_target ${PROJECT_NAME}.elf)
-
- spaces2list(${MAIN_SRCS})
+
+ spaces2list(MAIN_SRCS)
add_executable(${exe_target} "${MAIN_SRCS}")
add_map_file(${exe_target})
+
endfunction(idf_add_executable)
endif()
endforeach(dir ${COMPONENT_PATHS})
+ if(EXISTS ${SDKCONFIG}.defaults)
+ set(defaults_arg --defaults "${SDKCONFIG}.defaults")
+ endif()
+
+ set(confgen_basecommand
+ ${PYTHON} ${IDF_PATH}/tools/kconfig_new/confgen.py
+ --kconfig ${ROOT_KCONFIG}
+ --config ${SDKCONFIG}
+ ${defaults_arg}
+ --create-config-if-missing
+ --env "COMPONENT_KCONFIGS=${kconfigs}"
+ --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}")
+
# Generate the menuconfig target (uses C-based mconf tool)
add_custom_target(menuconfig
DEPENDS mconf
+ COMMAND ${confgen_basecommand} --output config ${SDKCONFIG} # create any missing config file, with defaults if necessary
COMMAND ${CMAKE_COMMAND} -E env
"COMPONENT_KCONFIGS=${kconfigs}"
"COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
# makes sdkconfig.h and skdconfig.cmake
#
# This happens at cmake runtime not during the build
- execute_process(COMMAND python ${IDF_PATH}/tools/kconfig_new/confgen.py
- --kconfig ${ROOT_KCONFIG}
- --config ${SDKCONFIG}
- --create-config-if-missing
- --env "COMPONENT_KCONFIGS=${kconfigs}"
- --env "COMPONENT_KCONFIGS_PROJBUILD=${kconfigs_projbuild}"
+ execute_process(COMMAND ${confgen_basecommand}
--output header ${SDKCONFIG_HEADER}
--output cmake ${SDKCONFIG_CMAKE})
__version__ = "0.1"
def main():
- parser = argparse.ArgumentParser(description='confgen.py v%s - Config Generation Tool' % __version__, prog='conftool')
+ parser = argparse.ArgumentParser(description='confgen.py v%s - Config Generation Tool' % __version__, prog=os.path.basename(sys.argv[0]))
parser.add_argument('--config',
help='Project configuration settings',
nargs='?',
default=None)
+ parser.add_argument('--defaults',
+ help='Optional project defaults file, used if --config file doesn\'t exist',
+ nargs='?',
+ 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')
config = kconfiglib.Kconfig(args.kconfig)
+ if args.defaults is not None:
+ # always load defaults first, so any items which are not defined in that config
+ # will have the default defined in the defaults file
+ if not os.path.exists(args.defaults):
+ raise RuntimeError("Defaults file not found: %s" % args.defaults)
+ config.load_config(args.defaults)
+
if args.config is not None:
if os.path.exists(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:
+ elif args.default is None:
raise RuntimeError("Config file not found: %s" % args.config)
for output_type, filename in args.output: