#remote build

This commit is contained in:
Yuri Trikoz
2020-12-01 21:40:33 +03:00
parent d0ef8ec82e
commit 0fc7cccda7
8 changed files with 83 additions and 10 deletions

11
.gitignore vendored
View File

@@ -1,7 +1,6 @@
.pio
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
lib/libraies-master
.vscode
lib
build.log
build_output
.cache

View File

@@ -3,7 +3,7 @@
#include "Clock.h"
#include "Global.h"
#include "Utils/TimeUtils.h"
#include "Utils\SerialPrint.h"
#include "Utils/SerialPrint.h"
extern void clock_init();

View File

@@ -1,8 +1,11 @@
[platformio]
default_envs = esp8266
build_cache_dir = .cache
;=============================================================================================================================================
[common_env_data]
lib_ldf_mode = chain+
lib_deps_external =
bblanchon/ArduinoJson @5.*
thomasfredericks/Bounce2
@@ -31,7 +34,9 @@ monitor_filters = esp32_exception_decoder
upload_speed = 921600
monitor_speed = 115200
board_build.filesystem = littlefs
extra_scripts = ./tools/littlefsbuilder.py
extra_scripts =
tools/littlefsbuilder.py
${scripts_defaults.extra_scripts}
;=============================================================================================================================================
[env:esp8266_01_1m]
framework = arduino
@@ -65,4 +70,11 @@ monitor_filters = esp8266_exception_decoder
upload_speed = 921600
monitor_speed = 115200
board_build.filesystem = littlefs
extra_scripts =
${scripts_defaults.extra_scripts}
;=============================================================================================================================================
[scripts_defaults]
extra_scripts =
tools/name-firmware.py
tools/gzip-firmware.py

View File

@@ -1,5 +1,5 @@
#include "Utils/FileUtils.h"
#include "Utils\SerialPrint.h"
#include "Utils/SerialPrint.h"
#include "Utils/StringUtils.h"

View File

@@ -1,4 +1,4 @@
#include "Utils\SerialPrint.h"
#include "Utils/SerialPrint.h"
#include "Global.h"

28
tools/gzip-firmware.py Normal file
View File

@@ -0,0 +1,28 @@
Import('env')
import os
import shutil
import gzip
OUTPUT_DIR = "build_output{}".format(os.path.sep)
def bin_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 = "{}firmware{}{}.bin".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
if os.path.isfile(gzip_file): os.remove(gzip_file)
# write gzip firmware file
with open(bin_file,"rb") as fp:
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
shutil.copyfileobj(fp, f)
ORG_FIRMWARE_SIZE = os.stat(bin_file).st_size
GZ_FIRMWARE_SIZE = os.stat(gzip_file).st_size
print("Compressed to {:.0f}% ({} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])

34
tools/name-firmware.py Normal file
View File

@@ -0,0 +1,34 @@
Import('env')
import os
import shutil
OUTPUT_DIR = "build_output{}".format(os.path.sep)
def bin_map_copy(source, target, env):
variant = str(target[0]).split(os.path.sep)[2]
# check if output directories exist and create if necessary
if not os.path.isdir(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR)
for d in ['firmware', 'map']:
if not os.path.isdir("{}{}".format(OUTPUT_DIR, d)):
os.mkdir("{}{}".format(OUTPUT_DIR, d))
# create string with location and file names based on variant
map_file = "{}map{}{}.map".format(OUTPUT_DIR, os.path.sep, variant)
bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant)
# check if new target files exist and remove if necessary
for f in [map_file, bin_file]:
if os.path.isfile(f):
os.remove(f)
# copy firmware.bin to firmware/<variant>.bin
shutil.copy(str(target[0]), bin_file)
# copy firmware.map to map/<variant>.map
if os.path.isfile("firmware.map"):
shutil.move("firmware.map", map_file)
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_map_copy])