updated Buildscripts to have central Versioning
This commit is contained in:
		| @@ -1,7 +1,3 @@ | |||||||
| # SCRIPT TO GZIP CRITICAL FILES FOR ACCELERATED WEBSERVING |  | ||||||
| # see also https://community.platformio.org/t/question-esp32-compress-files-in-data-to-gzip-before-upload-possible-to-spiffs/6274/10 |  | ||||||
|  |  | ||||||
|  |  | ||||||
| import glob | import glob | ||||||
| import shutil | import shutil | ||||||
| import gzip | import gzip | ||||||
| @@ -169,8 +165,13 @@ def gzip_webfiles(source, target, env): | |||||||
|     return |     return | ||||||
|  |  | ||||||
| def gzip_binffiles(source, target, env): | def gzip_binffiles(source, target, env): | ||||||
|  |     git_revision = popen('git rev-parse --short HEAD').read().strip() | ||||||
|  |     custom_flash_version = env.GetProjectOption("custom_flash_version", "0.99") | ||||||
|  |  | ||||||
|  |     # Format the target file name | ||||||
|  |     target_filename = f"filesystem_{custom_flash_version}_{git_revision}.fs" | ||||||
|     littlefsbin = target[0].get_abspath() |     littlefsbin = target[0].get_abspath() | ||||||
|     targetbin = os.path.join(os.path.dirname(littlefsbin), 'filesystem.fs') |     targetbin = os.path.join(os.path.dirname(littlefsbin), target_filename) | ||||||
|     shutil.copyfile(littlefsbin, targetbin) |     shutil.copyfile(littlefsbin, targetbin) | ||||||
|     gzip_file(targetbin, os.path.join(str(targetbin) + '.gz')) |     gzip_file(targetbin, os.path.join(str(targetbin) + '.gz')) | ||||||
|     os.remove(targetbin) |     os.remove(targetbin) | ||||||
|   | |||||||
| @@ -7,8 +7,27 @@ from os import popen | |||||||
|  |  | ||||||
| git_revision = popen('git rev-parse --short HEAD').read().strip() | git_revision = popen('git rev-parse --short HEAD').read().strip() | ||||||
|  |  | ||||||
| env.Replace(PROGNAME="firmware_%s.fw" % git_revision) | # Versionsnummern aus platformio.ini holen | ||||||
| env.Append(CPPDEFINES=[('GIT_REV', '\\"{}\\"'.format(git_revision))]) | custom_firmware_version = env.GetProjectOption("custom_firmware_version", "0.99") | ||||||
|  | custom_flash_version = env.GetProjectOption("custom_flash_version", "0.99") | ||||||
|  |  | ||||||
|  | # Versionsnummern aufteilen in Major und Minor | ||||||
|  | fw_major, fw_minor = custom_firmware_version.split('.') | ||||||
|  | fl_major, fl_minor = custom_flash_version.split('.') | ||||||
|  |  | ||||||
|  | # Version in Datei "version" im Ordner "data_src" überschreiben | ||||||
|  | with open('data_src/version', 'w') as version_file: | ||||||
|  |     version_file.write(custom_flash_version) | ||||||
|  |      | ||||||
|  | # Build-Flags setzen | ||||||
|  | env.Replace(PROGNAME="firmware_%s_%s.fw" % (custom_firmware_version, git_revision)) | ||||||
|  | env.Append(CPPDEFINES=[ | ||||||
|  |     ('GIT_REV', '\\"{}\\"'.format(git_revision)), | ||||||
|  |     ('FW_MAJOR', fw_major), | ||||||
|  |     ('FW_MINOR', fw_minor), | ||||||
|  |     ('FL_MAJOR', fl_major), | ||||||
|  |     ('FL_MINOR', fl_minor) | ||||||
|  | ]) | ||||||
|  |  | ||||||
| struct2json.struct2json() | struct2json.struct2json() | ||||||
| dtcs.build_dtcs() | dtcs.build_dtcs() | ||||||
| @@ -31,8 +31,8 @@ typedef struct Constants_s | |||||||
| } Constants_t; | } Constants_t; | ||||||
|  |  | ||||||
| const Constants_t constants PROGMEM = { | const Constants_t constants PROGMEM = { | ||||||
|     1, 5,   // Firmware_Version |     FW_MAJOR, FW_MINOR,   // Firmware_Version | ||||||
|     1, 5,   // Required Flash Version |     FL_MAJOR, FL_MINOR,   // Required Flash Version | ||||||
|     GIT_REV // Git-Hash-String |     GIT_REV // Git-Hash-String | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -17,6 +17,9 @@ platform = espressif8266 | |||||||
| framework = arduino | framework = arduino | ||||||
| board = d1_mini | board = d1_mini | ||||||
|  |  | ||||||
|  | custom_firmware_version = 1.05  | ||||||
|  | custom_flash_version = 1.05  | ||||||
|  |  | ||||||
| upload_protocol = esptool | upload_protocol = esptool | ||||||
| upload_speed = 921600 | upload_speed = 921600 | ||||||
| ;upload_port = 10.0.1.48 | ;upload_port = 10.0.1.48 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user