mirror of
https://github.com/esphome/esphome.git
synced 2024-11-25 00:18:11 +01:00
Add ESPHOME_VERSION_CODE define (#2324)
This commit is contained in:
parent
9ebe075f9b
commit
7452ef23b1
2 changed files with 15 additions and 2 deletions
|
@ -6,4 +6,7 @@
|
||||||
//
|
//
|
||||||
// This file is only used by static analyzers and IDEs.
|
// This file is only used by static analyzers and IDEs.
|
||||||
|
|
||||||
|
#include "esphome/core/macros.h"
|
||||||
|
|
||||||
#define ESPHOME_VERSION "dev"
|
#define ESPHOME_VERSION "dev"
|
||||||
|
#define ESPHOME_VERSION_CODE VERSION_CODE(2099, 12, 0)
|
||||||
|
|
|
@ -342,7 +342,9 @@ DEFINES_H_FORMAT = ESPHOME_H_FORMAT = """\
|
||||||
"""
|
"""
|
||||||
VERSION_H_FORMAT = """\
|
VERSION_H_FORMAT = """\
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "esphome/core/macros.h"
|
||||||
#define ESPHOME_VERSION "{}"
|
#define ESPHOME_VERSION "{}"
|
||||||
|
#define ESPHOME_VERSION_CODE VERSION_CODE({}, {}, {})
|
||||||
"""
|
"""
|
||||||
DEFINES_H_TARGET = "esphome/core/defines.h"
|
DEFINES_H_TARGET = "esphome/core/defines.h"
|
||||||
VERSION_H_TARGET = "esphome/core/version.h"
|
VERSION_H_TARGET = "esphome/core/version.h"
|
||||||
|
@ -415,8 +417,7 @@ def copy_src_tree():
|
||||||
CORE.relative_src_path("esphome.h"), ESPHOME_H_FORMAT.format(include_s)
|
CORE.relative_src_path("esphome.h"), ESPHOME_H_FORMAT.format(include_s)
|
||||||
)
|
)
|
||||||
write_file_if_changed(
|
write_file_if_changed(
|
||||||
CORE.relative_src_path("esphome", "core", "version.h"),
|
CORE.relative_src_path("esphome", "core", "version.h"), generate_version_h()
|
||||||
VERSION_H_FORMAT.format(__version__),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,6 +427,15 @@ def generate_defines_h():
|
||||||
return DEFINES_H_FORMAT.format("\n".join(define_content_l))
|
return DEFINES_H_FORMAT.format("\n".join(define_content_l))
|
||||||
|
|
||||||
|
|
||||||
|
def generate_version_h():
|
||||||
|
match = re.match(r"^(\d+)\.(\d+).(\d+)-?\w*$", __version__)
|
||||||
|
if not match:
|
||||||
|
raise EsphomeError(f"Could not parse version {__version__}.")
|
||||||
|
return VERSION_H_FORMAT.format(
|
||||||
|
__version__, match.group(1), match.group(2), match.group(3)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def write_cpp(code_s):
|
def write_cpp(code_s):
|
||||||
path = CORE.relative_src_path("main.cpp")
|
path = CORE.relative_src_path("main.cpp")
|
||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
|
|
Loading…
Reference in a new issue