mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-02-18 15:21:25 +00:00
🩹 Correctly add JSON to mc.zip (#25706)
This commit is contained in:
parent
a5b5db4819
commit
5426759a37
1 changed files with 5 additions and 6 deletions
|
@ -39,9 +39,9 @@ def get_file_sha256sum(filepath):
|
||||||
# Compress a JSON file into a zip file
|
# Compress a JSON file into a zip file
|
||||||
#
|
#
|
||||||
import zipfile
|
import zipfile
|
||||||
def compress_file(filepath, outpath):
|
def compress_file(filepath, storedname, outpath):
|
||||||
with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf:
|
with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf:
|
||||||
zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9)
|
zipf.write(filepath, arcname=storedname, compress_type=zipfile.ZIP_BZIP2, compresslevel=9)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compute the build signature. The idea is to extract all defines in the configuration headers
|
# Compute the build signature. The idea is to extract all defines in the configuration headers
|
||||||
|
@ -56,14 +56,13 @@ def compute_build_signature(env):
|
||||||
files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ]
|
files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ]
|
||||||
|
|
||||||
build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
|
||||||
build_path_relative = Path('.pio', 'build', env['PIOENV'])
|
|
||||||
|
|
||||||
# Check if we can skip processing
|
# Check if we can skip processing
|
||||||
hashes = ''
|
hashes = ''
|
||||||
for header in files_to_keep:
|
for header in files_to_keep:
|
||||||
hashes += get_file_sha256sum(header)[0:10]
|
hashes += get_file_sha256sum(header)[0:10]
|
||||||
|
|
||||||
marlin_json = build_path_relative / 'marlin_config.json'
|
marlin_json = build_path / 'marlin_config.json'
|
||||||
marlin_zip = build_path / 'mc.zip'
|
marlin_zip = build_path / 'mc.zip'
|
||||||
|
|
||||||
# Read existing config file
|
# Read existing config file
|
||||||
|
@ -72,7 +71,7 @@ def compute_build_signature(env):
|
||||||
conf = json.load(infile)
|
conf = json.load(infile)
|
||||||
if conf['__INITIAL_HASH'] == hashes:
|
if conf['__INITIAL_HASH'] == hashes:
|
||||||
# Same configuration, skip recomputing the building signature
|
# Same configuration, skip recomputing the building signature
|
||||||
compress_file(marlin_json, marlin_zip)
|
compress_file(marlin_json, 'marlin_config.json', marlin_zip)
|
||||||
return
|
return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
@ -256,7 +255,7 @@ def compute_build_signature(env):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Compress the JSON file as much as we can
|
# Compress the JSON file as much as we can
|
||||||
compress_file(marlin_json, marlin_zip)
|
compress_file(marlin_json, 'marlin_config.json', marlin_zip)
|
||||||
|
|
||||||
# Generate a C source file for storing this array
|
# Generate a C source file for storing this array
|
||||||
with open('Marlin/src/mczip.h','wb') as result_file:
|
with open('Marlin/src/mczip.h','wb') as result_file:
|
||||||
|
|
Loading…
Reference in a new issue