11#
22# signature.py
33#
4- import subprocess ,re ,json ,hashlib
54import schema
5+
6+ import subprocess ,re ,json ,hashlib
7+ from datetime import datetime
68from pathlib import Path
79
810#
@@ -112,9 +114,9 @@ def compute_build_signature(env):
112114 defines [key ] = value if len (value ) else ""
113115
114116 #
115- # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_DUMP
117+ # Continue to gather data for CONFIGURATION_EMBEDDING or CONFIG_EXPORT
116118 #
117- if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_DUMP ' in defines ):
119+ if not ('CONFIGURATION_EMBEDDING' in defines or 'CONFIG_EXPORT ' in defines ):
118120 return
119121
120122 # Second step is to filter useless macro
@@ -157,18 +159,32 @@ def tryint(key):
157159 except :
158160 return 0
159161
160- config_dump = tryint ('CONFIG_DUMP ' )
162+ config_dump = tryint ('CONFIG_EXPORT ' )
161163
162164 #
163- # Produce an INI file if CONFIG_DUMP == 2
165+ # Produce an INI file if CONFIG_EXPORT == 2
164166 #
165167 if config_dump == 2 :
166168 print ("Generating config.ini ..." )
167- ignore = ('CONFIGURATION_H_VERSION' , 'CONFIGURATION_ADV_H_VERSION' , 'CONFIG_DUMP' )
168- filegrp = { 'Configuration.h' :'config:basic' , 'Configuration_adv.h' :'config:advanced' }
169169 config_ini = build_path / 'config.ini'
170170 with config_ini .open ('w' ) as outfile :
171- outfile .write ('#\n # Marlin Firmware\n # config.ini - Options to apply before the build\n #\n ' )
171+ ignore = ('CONFIGURATION_H_VERSION' , 'CONFIGURATION_ADV_H_VERSION' , 'CONFIG_EXPORT' )
172+ filegrp = { 'Configuration.h' :'config:basic' , 'Configuration_adv.h' :'config:advanced' }
173+ vers = defines ["CONFIGURATION_H_VERSION" ]
174+ dt_string = datetime .now ().strftime ("%Y-%m-%d at %H:%M:%S" )
175+ ini_fmt = '{0:40}{1}\n '
176+ outfile .write (
177+ '#\n '
178+ + '# Marlin Firmware\n '
179+ + '# config.ini - Options to apply before the build\n '
180+ + '#\n '
181+ + f'# Generated by Marlin build on { dt_string } \n '
182+ + '#\n '
183+ + '\n '
184+ + '[config:base]\n '
185+ + ini_fmt .format ('ini_use_config' , ' = all' )
186+ + ini_fmt .format ('ini_config_vers' , f' = { vers } ' )
187+ )
172188 # Loop through the data array of arrays
173189 for header in data :
174190 if header .startswith ('__' ):
@@ -177,10 +193,10 @@ def tryint(key):
177193 for key in sorted (data [header ]):
178194 if key not in ignore :
179195 val = 'on' if data [header ][key ] == '' else data [header ][key ]
180- outfile .write ('{0:40}{1}' .format (key .lower (), ' = ' + val ) + ' \n ' )
196+ outfile .write (ini_fmt .format (key .lower (), ' = ' + val ))
181197
182198 #
183- # Produce a schema.json file if CONFIG_DUMP == 3
199+ # Produce a schema.json file if CONFIG_EXPORT == 3
184200 #
185201 if config_dump >= 3 :
186202 try :
@@ -191,7 +207,7 @@ def tryint(key):
191207
192208 if conf_schema :
193209 #
194- # Produce a schema.json file if CONFIG_DUMP == 3
210+ # Produce a schema.json file if CONFIG_EXPORT == 3
195211 #
196212 if config_dump in (3 , 13 ):
197213 print ("Generating schema.json ..." )
@@ -201,7 +217,7 @@ def tryint(key):
201217 schema .dump_json (conf_schema , build_path / 'schema_grouped.json' )
202218
203219 #
204- # Produce a schema.yml file if CONFIG_DUMP == 4
220+ # Produce a schema.yml file if CONFIG_EXPORT == 4
205221 #
206222 elif config_dump == 4 :
207223 print ("Generating schema.yml ..." )
@@ -226,7 +242,7 @@ def tryint(key):
226242 pass
227243
228244 #
229- # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_DUMP == 1
245+ # Produce a JSON file for CONFIGURATION_EMBEDDING or CONFIG_EXPORT == 1
230246 #
231247 if config_dump == 1 or 'CONFIGURATION_EMBEDDING' in defines :
232248 with marlin_json .open ('w' ) as outfile :
0 commit comments