mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-04-19 12:57:19 +00:00
Add git short hash to bin files #308
This commit is contained in:
parent
ed3ff69fc8
commit
749781587f
30
tools/auto_firmware_version.py
Normal file
30
tools/auto_firmware_version.py
Normal file
@ -0,0 +1,30 @@
|
||||
import pkg_resources
|
||||
|
||||
Import("env")
|
||||
|
||||
required_pkgs = {'dulwich'}
|
||||
installed_pkgs = {pkg.key for pkg in pkg_resources.working_set}
|
||||
missing_pkgs = required_pkgs - installed_pkgs
|
||||
|
||||
if missing_pkgs:
|
||||
env.Execute('$PYTHONEXE -m pip install dulwich --global-option="--pure"')
|
||||
|
||||
from dulwich import porcelain
|
||||
from dulwich.repo import Repo
|
||||
|
||||
def get_firmware_specifier_build_flag():
|
||||
build_version = porcelain.describe('.') # '.' refers to the repository root dir
|
||||
build_flag = "-D AUTO_VERSION=\\\"" + build_version + "\\\""
|
||||
print ("Firmware Revision: " + build_version)
|
||||
return (build_flag)
|
||||
|
||||
def get_firmware_commit_hash():
|
||||
r = Repo('.')
|
||||
commit_hash = r.head().decode("utf-8")[0:7]
|
||||
build_flag = "-D COMMIT_HASH=\\\"" + commit_hash + "\\\""
|
||||
print ("Commit Hash: " + commit_hash)
|
||||
return (build_flag)
|
||||
|
||||
env.Append(
|
||||
BUILD_FLAGS=[get_firmware_commit_hash()]
|
||||
)
|
@ -3,6 +3,7 @@ import os
|
||||
import sys
|
||||
import shutil
|
||||
import subprocess
|
||||
import pkg_resources
|
||||
|
||||
buildFlags = env.ParseFlags(env['BUILD_FLAGS'])
|
||||
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
||||
@ -11,6 +12,21 @@ platform = env.PioPlatform()
|
||||
FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
|
||||
FRAMEWORK_DIR = "{}{}".format(FRAMEWORK_DIR, os.path.sep)
|
||||
|
||||
required_pkgs = {'dulwich'}
|
||||
installed_pkgs = {pkg.key for pkg in pkg_resources.working_set}
|
||||
missing_pkgs = required_pkgs - installed_pkgs
|
||||
|
||||
if missing_pkgs:
|
||||
env.Execute('$PYTHONEXE -m pip install dulwich --global-option="--pure"')
|
||||
|
||||
from dulwich import porcelain
|
||||
from dulwich.repo import Repo
|
||||
|
||||
def get_firmware_commit_hash():
|
||||
r = Repo('.')
|
||||
commit_hash = r.head().decode("utf-8")[0:7]
|
||||
print ("Commit Hash: " + commit_hash)
|
||||
return (commit_hash)
|
||||
|
||||
def get_fw_version(source, target, env):
|
||||
global HASP_VER_MAJ
|
||||
@ -28,7 +44,7 @@ def get_fw_version(source, target, env):
|
||||
|
||||
|
||||
def copy_merge_bins(source, target, env):
|
||||
version = 'v' + str(HASP_VER_MAJ) + '.' + str(HASP_VER_MIN) + '.' + str(HASP_VER_REV)
|
||||
version = 'v' + str(HASP_VER_MAJ) + '.' + str(HASP_VER_MIN) + '.' + str(HASP_VER_REV) + '_' + get_firmware_commit_hash()
|
||||
name = str(target[0]).split(os.path.sep)[2]
|
||||
name = name.replace('_4MB', '').replace('_8MB', '').replace('_16MB', '').replace('_32MB', '')
|
||||
flash_size = env.GetProjectOption("board_upload.flash_size")
|
||||
@ -70,7 +86,7 @@ def copy_merge_bins(source, target, env):
|
||||
print(stderr.decode("utf-8") )
|
||||
|
||||
def copy_ota(source, target, env):
|
||||
version = 'v' + str(HASP_VER_MAJ) + '.' + str(HASP_VER_MIN) + '.' + str(HASP_VER_REV)
|
||||
version = 'v' + str(HASP_VER_MAJ) + '.' + str(HASP_VER_MIN) + '.' + str(HASP_VER_REV) + '_' + get_firmware_commit_hash()
|
||||
name =str(target[0]).split(os.path.sep)[2]
|
||||
name = name.replace('_4MB', '').replace('_8MB', '').replace('_16MB', '').replace('_32MB', '')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user