mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-08 11:26:31 +00:00
Merge pull request #12830 from Jason2866/gzip_map
gzip map file to save disk space
This commit is contained in:
commit
0b28019544
@ -6,11 +6,32 @@ import gzip
|
|||||||
platform = env.PioPlatform()
|
platform = env.PioPlatform()
|
||||||
board = env.BoardConfig()
|
board = env.BoardConfig()
|
||||||
mcu = board.get("build.mcu", "esp32")
|
mcu = board.get("build.mcu", "esp32")
|
||||||
|
|
||||||
|
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
||||||
|
|
||||||
|
def map_gzip(source, target, env):
|
||||||
|
variant = str(target[0]).split(os.path.sep)[2]
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# 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])
|
||||||
|
|
||||||
# gzip only for ESP8266
|
# gzip only for ESP8266
|
||||||
if env["PIOPLATFORM"] != "espressif32":
|
if env["PIOPLATFORM"] != "espressif32":
|
||||||
|
|
||||||
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
|
||||||
|
|
||||||
def bin_gzip(source, target, env):
|
def bin_gzip(source, target, env):
|
||||||
variant = str(target[0]).split(os.path.sep)[2]
|
variant = str(target[0]).split(os.path.sep)[2]
|
||||||
|
|
||||||
@ -33,5 +54,5 @@ if env["PIOPLATFORM"] != "espressif32":
|
|||||||
print("\u001b[31;1m!!! Tasmota firmware size is too big with {} bytes. Max size is 995326 bytes !!! \u001b[0m".format(ORG_FIRMWARE_SIZE))
|
print("\u001b[31;1m!!! Tasmota firmware size is too big with {} bytes. Max size is 995326 bytes !!! \u001b[0m".format(ORG_FIRMWARE_SIZE))
|
||||||
else:
|
else:
|
||||||
print("Compression reduced firmware size by {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
|
print("Compression reduced firmware size by {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
|
||||||
|
|
||||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])
|
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user