From 0c30aeeebc2188c389bee1b2501370428c45925b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 9 Aug 2021 10:58:37 +0200 Subject: [PATCH] Fix compile erro by lack of map file (#12837) --- pio-tools/gzip-firmware.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pio-tools/gzip-firmware.py b/pio-tools/gzip-firmware.py index e99973af4..fac23cf2d 100644 --- a/pio-tools/gzip-firmware.py +++ b/pio-tools/gzip-firmware.py @@ -14,18 +14,20 @@ def map_gzip(source, target, env): # create string with location and file names based on variant bin_file = "{}map{}{}.map".format(OUTPUT_DIR, os.path.sep, variant) - gzip_file = "{}map{}{}.map.gz".format(OUTPUT_DIR, os.path.sep, variant) - # check if new target map files exist and remove if necessary - if os.path.isfile(gzip_file): os.remove(gzip_file) + if os.path.isfile(bin_file): + gzip_file = "{}map{}{}.map.gz".format(OUTPUT_DIR, os.path.sep, variant) - # write gzip map file - with open(bin_file,"rb") as fp: - with gzip.open(gzip_file, "wb", compresslevel = 9) as f: - shutil.copyfileobj(fp, f) + # check if new target map files exist and remove if necessary + if os.path.isfile(gzip_file): os.remove(gzip_file) - # remove map file - if os.path.isfile(bin_file): os.remove(bin_file) + # write gzip map file + with open(bin_file,"rb") as fp: + with gzip.open(gzip_file, "wb", compresslevel = 9) as f: + shutil.copyfileobj(fp, f) + + # remove map file + if os.path.isfile(bin_file): os.remove(bin_file) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [map_gzip])