mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Fix project version longer than 30 characters breaking compilation (#6535)
This commit is contained in:
parent
ff0d33ffe3
commit
ed02747ebc
3 changed files with 3 additions and 1 deletions
|
@ -134,7 +134,7 @@ class ProjectUpdateTrigger : public Trigger<std::string>, public Component {
|
||||||
uint32_t hash = fnv1_hash(ESPHOME_PROJECT_NAME);
|
uint32_t hash = fnv1_hash(ESPHOME_PROJECT_NAME);
|
||||||
ESPPreferenceObject pref = global_preferences->make_preference<char[30]>(hash, true);
|
ESPPreferenceObject pref = global_preferences->make_preference<char[30]>(hash, true);
|
||||||
char previous_version[30];
|
char previous_version[30];
|
||||||
char current_version[30] = ESPHOME_PROJECT_VERSION;
|
char current_version[30] = ESPHOME_PROJECT_VERSION_30;
|
||||||
if (pref.load(&previous_version)) {
|
if (pref.load(&previous_version)) {
|
||||||
int cmp = strcmp(previous_version, current_version);
|
int cmp = strcmp(previous_version, current_version);
|
||||||
if (cmp < 0) {
|
if (cmp < 0) {
|
||||||
|
|
|
@ -394,6 +394,7 @@ async def to_code(config):
|
||||||
if project_conf := config.get(CONF_PROJECT):
|
if project_conf := config.get(CONF_PROJECT):
|
||||||
cg.add_define("ESPHOME_PROJECT_NAME", project_conf[CONF_NAME])
|
cg.add_define("ESPHOME_PROJECT_NAME", project_conf[CONF_NAME])
|
||||||
cg.add_define("ESPHOME_PROJECT_VERSION", project_conf[CONF_VERSION])
|
cg.add_define("ESPHOME_PROJECT_VERSION", project_conf[CONF_VERSION])
|
||||||
|
cg.add_define("ESPHOME_PROJECT_VERSION_30", project_conf[CONF_VERSION][:30])
|
||||||
for conf in project_conf.get(CONF_ON_UPDATE, []):
|
for conf in project_conf.get(CONF_ON_UPDATE, []):
|
||||||
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
|
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID])
|
||||||
await cg.register_component(trigger, conf)
|
await cg.register_component(trigger, conf)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#define ESPHOME_BOARD "dummy_board"
|
#define ESPHOME_BOARD "dummy_board"
|
||||||
#define ESPHOME_PROJECT_NAME "dummy project"
|
#define ESPHOME_PROJECT_NAME "dummy project"
|
||||||
#define ESPHOME_PROJECT_VERSION "v2"
|
#define ESPHOME_PROJECT_VERSION "v2"
|
||||||
|
#define ESPHOME_PROJECT_VERSION_30 "v2"
|
||||||
#define ESPHOME_VARIANT "ESP32"
|
#define ESPHOME_VARIANT "ESP32"
|
||||||
|
|
||||||
// Feature flags
|
// Feature flags
|
||||||
|
|
Loading…
Reference in a new issue