mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
fix: create firmware folder if it doesn't exist
This commit is contained in:
@@ -18,28 +18,32 @@ def bin_copy(source, target, env):
|
|||||||
if m and len(m.groups()) > 0:
|
if m and len(m.groups()) > 0:
|
||||||
bag[var] = m.group(1)
|
bag[var] = m.group(1)
|
||||||
|
|
||||||
|
|
||||||
# esp8266 or esp32
|
# esp8266 or esp32
|
||||||
platform = "esp" + env['PIOPLATFORM'].strip("espressif")
|
platform = "esp" + env['PIOPLATFORM'].strip("espressif")
|
||||||
|
|
||||||
# str(target[0]).split(os.path.sep)[2]
|
# if using the pio build directory, use str(target[0]).split(os.path.sep)[2]
|
||||||
variant = "EMS-ESP-" + bag.get('app_version').replace(".", "_") + "-" + platform
|
variant = "EMS-ESP-" + bag.get('app_version').replace(".", "_") + "-" + platform
|
||||||
|
|
||||||
# create string with location and file names based on variant
|
# create string with location and file names based on variant
|
||||||
bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant)
|
bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant)
|
||||||
gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant)
|
gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant)
|
||||||
|
|
||||||
# check if new target files exist and remove if necessary
|
# check if firmware directory and target subdirectories (esp8266/esp32) exist and create if necessary
|
||||||
if os.path.isfile(bin_file): os.remove(bin_file)
|
if not os.path.isdir(OUTPUT_DIR):
|
||||||
if os.path.isfile(gzip_file): os.remove(gzip_file)
|
os.mkdir(OUTPUT_DIR)
|
||||||
|
for d in ['firmware']:
|
||||||
|
if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)):
|
||||||
|
os.mkdir("{}{}".format(OUTPUT_DIR, d))
|
||||||
|
|
||||||
# copy firmware.bin to new name
|
# copy firmware.bin to new name and in the build/firmware folder, delete if already exists
|
||||||
|
if os.path.isfile(bin_file): os.remove(bin_file)
|
||||||
shutil.copy(str(target[0]), bin_file)
|
shutil.copy(str(target[0]), bin_file)
|
||||||
|
|
||||||
# create a zip'd version
|
# create the gzip'd version
|
||||||
|
if os.path.isfile(gzip_file): os.remove(gzip_file)
|
||||||
with open(bin_file, "rb") as fp:
|
with open(bin_file, "rb") as fp:
|
||||||
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
|
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
|
||||||
shutil.copyfileobj(fp, f)
|
shutil.copyfileobj(fp, f)
|
||||||
|
|
||||||
print("Built firmwares: "+ bin_file + ", " + gzip_file)
|
print("Built firmwares: "+ bin_file + ", " + gzip_file)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user