mirror of https://github.com/arendst/Tasmota.git
gzip map file
This commit is contained in:
parent
3906a52c0f
commit
5ff35f99f2
|
@ -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")
|
||||||
# gzip only for ESP8266
|
|
||||||
if env["PIOPLATFORM"] != "espressif32":
|
|
||||||
|
|
||||||
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
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
|
||||||
|
if env["PIOPLATFORM"] != "espressif32":
|
||||||
|
|
||||||
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]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue