mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
confgen: base config creation on output type args
This commit is contained in:
@@ -50,10 +50,6 @@ 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)
|
||||||
@@ -91,15 +87,11 @@ def main():
|
|||||||
raise RuntimeError("Defaults file not found: %s" % args.defaults)
|
raise RuntimeError("Defaults file not found: %s" % args.defaults)
|
||||||
config.load_config(args.defaults)
|
config.load_config(args.defaults)
|
||||||
|
|
||||||
if args.config is not None:
|
# If config file previously exists, load it
|
||||||
if os.path.exists(args.config):
|
if args.config and os.path.exists(args.config):
|
||||||
config.load_config(args.config)
|
config.load_config(args.config, replace=False)
|
||||||
elif args.create_config_if_missing:
|
|
||||||
print("Creating config file %s..." % args.config)
|
|
||||||
config.write_config(args.config)
|
|
||||||
elif args.default is None:
|
|
||||||
raise RuntimeError("Config file not found: %s" % args.config)
|
|
||||||
|
|
||||||
|
# Output the files specified in the arguments
|
||||||
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")
|
||||||
try:
|
try:
|
||||||
@@ -263,6 +255,7 @@ def write_json_menus(config, filename):
|
|||||||
def update_if_changed(source, destination):
|
def update_if_changed(source, destination):
|
||||||
with open(source, "r") as f:
|
with open(source, "r") as f:
|
||||||
source_contents = f.read()
|
source_contents = f.read()
|
||||||
|
|
||||||
if os.path.exists(destination):
|
if os.path.exists(destination):
|
||||||
with open(destination, "r") as f:
|
with open(destination, "r") as f:
|
||||||
dest_contents = f.read()
|
dest_contents = f.read()
|
||||||
|
Reference in New Issue
Block a user