🔧 Add date, version to Config Export

This commit is contained in:
Scott Lahteine 2022-08-04 15:48:14 -05:00
parent 4c9146cffd
commit b7fd046d59
6 changed files with 50 additions and 130 deletions

View file

@ -1,8 +1,10 @@
#
# signature.py
#
import subprocess,re,json,hashlib
import schema
import subprocess,re,json,hashlib
from datetime import datetime
from pathlib import Path
#
@ -112,9 +114,9 @@ def compute_build_signature(env):
defines[key] = value if len(value) else ""
#
# Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_DUMP
# Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT
#
if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_DUMP' in defines):
if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT' in defines):
return
# Second step is to filter useless macro
@ -157,18 +159,32 @@ def compute_build_signature(env):
except:
return 0
config_dump = tryint('CONFIG_DUMP')
config_dump = tryint('CONFIG_EXPORT')
#
# Produce an INI file if CONFIG_DUMP == 2
# Produce an INI file if CONFIG_EXPORT == 2
#
if config_dump == 2:
print("Generating config.ini ...")
ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_DUMP')
filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' }
config_ini = build_path / 'config.ini'
with config_ini.open('w') as outfile:
outfile.write('#\n# Marlin Firmware\n# config.ini - Options to apply before the build\n#\n')
ignore = ('CONFIGURATION_H_VERSION', 'CONFIGURATION_ADV_H_VERSION', 'CONFIG_EXPORT')
filegrp = { 'Configuration.h':'config:basic', 'Configuration_adv.h':'config:advanced' }
vers = defines["CONFIGURATION_H_VERSION"]
dt_string = datetime.now().strftime("%Y-%m-%d at %H:%M:%S")
ini_fmt = '{0:40}{1}\n'
outfile.write(
'#\n'
+ '# Marlin Firmware\n'
+ '# config.ini - Options to apply before the build\n'
+ '#\n'
+ f'# Generated by Marlin build on {dt_string}\n'
+ '#\n'
+ '\n'
+ '[config:base]\n'
+ ini_fmt.format('ini_use_config', ' = all')
+ ini_fmt.format('ini_config_vers', f' = {vers}')
)
# Loop through the data array of arrays
for header in data:
if header.startswith('__'):
@ -177,10 +193,10 @@ def compute_build_signature(env):
for key in sorted(data[header]):
if key not in ignore:
val = 'on' if data[header][key] == '' else data[header][key]
outfile.write('{0:40}{1}'.format(key.lower(), ' = ' + val) + '\n')
outfile.write(ini_fmt.format(key.lower(), ' = ' + val))
#
# Produce a schema.json file if CONFIG_DUMP == 3
# Produce a schema.json file if CONFIG_EXPORT == 3
#
if config_dump >= 3:
try:
@ -191,7 +207,7 @@ def compute_build_signature(env):
if conf_schema:
#
# Produce a schema.json file if CONFIG_DUMP == 3
# Produce a schema.json file if CONFIG_EXPORT == 3
#
if config_dump in (3, 13):
print("Generating schema.json ...")
@ -201,7 +217,7 @@ def compute_build_signature(env):
schema.dump_json(conf_schema, build_path / 'schema_grouped.json')
#
# Produce a schema.yml file if CONFIG_DUMP == 4
# Produce a schema.yml file if CONFIG_EXPORT == 4
#
elif config_dump == 4:
print("Generating schema.yml ...")
@ -226,7 +242,7 @@ def compute_build_signature(env):
pass
#
# Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_DUMP == 1
# Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1
#
if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines:
with marlin_json.open('w') as outfile: