Skip to content

Commit 19b4ae8

Browse files
authored
🩹 Correctly add JSON to mc.zip (#25706)
1 parent 5e2e003 commit 19b4ae8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

buildroot/share/PlatformIO/scripts/signature.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def get_file_sha256sum(filepath):
3939
# Compress a JSON file into a zip file
4040
#
4141
import zipfile
42-
def compress_file(filepath, outpath):
42+
def compress_file(filepath, storedname, outpath):
4343
with zipfile.ZipFile(outpath, 'w', compression=zipfile.ZIP_BZIP2, compresslevel=9) as zipf:
44-
zipf.write(filepath, compress_type=zipfile.ZIP_BZIP2, compresslevel=9)
44+
zipf.write(filepath, arcname=storedname, compress_type=zipfile.ZIP_BZIP2, compresslevel=9)
4545

4646
#
4747
# Compute the build signature. The idea is to extract all defines in the configuration headers
@@ -56,14 +56,13 @@ def compute_build_signature(env):
5656
files_to_keep = [ 'Marlin/Configuration.h', 'Marlin/Configuration_adv.h' ]
5757

5858
build_path = Path(env['PROJECT_BUILD_DIR'], env['PIOENV'])
59-
build_path_relative = Path('.pio', 'build', env['PIOENV'])
6059

6160
# Check if we can skip processing
6261
hashes = ''
6362
for header in files_to_keep:
6463
hashes += get_file_sha256sum(header)[0:10]
6564

66-
marlin_json = build_path_relative / 'marlin_config.json'
65+
marlin_json = build_path / 'marlin_config.json'
6766
marlin_zip = build_path / 'mc.zip'
6867

6968
# Read existing config file
@@ -72,7 +71,7 @@ def compute_build_signature(env):
7271
conf = json.load(infile)
7372
if conf['__INITIAL_HASH'] == hashes:
7473
# Same configuration, skip recomputing the building signature
75-
compress_file(marlin_json, marlin_zip)
74+
compress_file(marlin_json, 'marlin_config.json', marlin_zip)
7675
return
7776
except:
7877
pass
@@ -256,7 +255,7 @@ def tryint(key):
256255
return
257256

258257
# Compress the JSON file as much as we can
259-
compress_file(marlin_json, marlin_zip)
258+
compress_file(marlin_json, 'marlin_config.json', marlin_zip)
260259

261260
# Generate a C source file for storing this array
262261
with open('Marlin/src/mczip.h','wb') as result_file:

0 commit comments

Comments
 (0)