🏗️ Refactor build encrypt / rename (#22124)

This commit is contained in:
Scott Lahteine
2021-06-13 15:43:33 -05:00
committed by Scott Lahteine
parent 14ffc66c45
commit 2aa35577f2
8 changed files with 59 additions and 63 deletions

View File

@ -27,11 +27,12 @@ def encrypt_file(input, output_file, file_length):
output_file.write(input_file)
return
# Encrypt ${PROGNAME}.bin and save it as build.firmware
# Encrypt ${PROGNAME}.bin and save it with the name given in build.encrypt
def encrypt(source, target, env):
print("Encrypting to:", board.get("build.firmware"))
fwname = board.get("build.encrypt")
print("Encrypting %s to %s" % (target[0].path, fwname))
firmware = open(target[0].path, "rb")
renamed = open(target[0].dir.path + "/" + board.get("build.firmware"), "wb")
renamed = open(target[0].dir.path + "/" + fwname, "wb")
length = os.path.getsize(target[0].path)
encrypt_file(firmware, renamed, length)
@ -39,8 +40,8 @@ def encrypt(source, target, env):
firmware.close()
renamed.close()
if 'firmware' in board.get("build").keys():
marlin.add_post_action(encrypt);
if 'encrypt' in board.get("build").keys():
marlin.add_post_action(encrypt);
else:
print("You need to define output file via board_build.firmware = 'filename' parameter")
exit(1);
print("LERDGE builds require output file via board_build.encrypt = 'filename' parameter")
exit(1);