Tasmota/pio-tools/name-firmware.py

28 lines
735 B
Python
Raw Normal View History

2021-08-16 11:37:38 +01:00
Import("env")
Import("projenv")
2019-11-16 12:57:07 +00:00
import os
import shutil
2021-08-16 11:37:38 +01:00
import pathlib
2019-11-16 12:57:07 +00:00
2021-08-16 11:37:38 +01:00
import tasmotapiolib
2021-08-16 11:37:38 +01:00
def bin_map_copy(source, target, env):
firsttarget = pathlib.Path(target[0].path)
2021-08-16 11:37:38 +01:00
# get locations and file names based on variant
map_file = tasmotapiolib.get_final_map_path(env)
bin_file = tasmotapiolib.get_final_bin_path(env)
# check if new target files exist and remove if necessary
for f in [map_file, bin_file]:
2021-08-16 11:37:38 +01:00
if f.is_file():
f.unlink()
# copy firmware.bin and map to final destination
shutil.copy(firsttarget, bin_file)
shutil.move(tasmotapiolib.get_source_map_path(env), map_file)
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", bin_map_copy)