mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
* feat: add improv - add version to build flags - add improv - remove byte pointers from config calls * ´fix: improve not initilizing in ADHOC mode * feat: add wifihandler to observers * refactor: move improv handler to top of loop * refactor: minor refactor to callback * refactor: minor refactor to callback * refactor: trying to weed out the timeout issue * refactor: trying to weed out the timeout issue * refactor: total refactor to clean up code - clean up statemanagers - fix observer - fix bugs introducted by fixing the observer BREAKING CHANGES * refactor: minor logging refactor * fix: add config save to delete method * fix: improv provisioning error * refactor: simplify library interface - implement pass by reference for all objects - implement get by reference for all objects - remove passing state to classes - migrate to range based for loops BREAKING CHANGES * fix: esp crash on wifi updates - figure out why esp crashes sometimes when wifi config changes * fix: add warning about clang-format to baseAPI.hpp * refactor: update improv * ci(ci-test): setup prerelease - use ci to merge binaries for testing in etvr app * fix: compile time error * fix: compile time error * fix folder names * fix folder names * fix: compile time error * fix: compile time error * feat: remove improv from main - keep improv code, incase we fix issue later on - comment out improv includes * fix: remove pre-release from release cycle * fix: resolve wifiState manager state in config * fix: file name casing * fix: file name casing * feat: add custom string_view header - it is the intention to implement string_view - vastly reduce heap allocations and improve performance of strings * refactor: move improv class to new branch * fix: file name casing * feat: add newer esp cam driver * Cleanup after merge --------- Co-authored-by: lorow <smykupyka@gmail.com>
171 lines
5.0 KiB
Python
171 lines
5.0 KiB
Python
# Description: Custom name for firmware
|
|
|
|
Import("env")
|
|
import subprocess
|
|
import sys
|
|
from colors import *
|
|
|
|
project = ""
|
|
version = ""
|
|
commit = ""
|
|
branch = ""
|
|
|
|
|
|
def onError():
|
|
print("Please install Git for Windows and add it to your PATH")
|
|
print(
|
|
"Continuing with default values for PIO_SRC_NAM, PIO_SRC_TAG, PIO_SRC_REV, PIO_SRC_BRH"
|
|
)
|
|
sys.stdout.write(RESET)
|
|
|
|
project = "PIO"
|
|
version = "0.0.0"
|
|
commit = "0000000"
|
|
branch = "main"
|
|
|
|
customName(project, version, commit, branch)
|
|
|
|
|
|
def handleGit():
|
|
try:
|
|
checkgit = "git rev-parse --is-inside-work-tree"
|
|
|
|
if subprocess.check_output(checkgit, shell=True).decode().strip() != "true":
|
|
sys.stdout.write(RED)
|
|
onError()
|
|
|
|
sys.stdout.write(GREEN)
|
|
print("Git is installed and we are in a Git repository, continuing...")
|
|
sys.stdout.write(RESET)
|
|
|
|
# Get Git project name
|
|
projcmd = "git rev-parse --show-toplevel"
|
|
project = subprocess.check_output(projcmd, shell=True).decode().strip()
|
|
project = project.split("/")
|
|
project = project[len(project) - 1]
|
|
|
|
# Get 0.0.0 version from latest Git tag
|
|
tagcmd = "git describe --tags --always --abbrev=0"
|
|
version = subprocess.check_output(tagcmd, shell=True).decode().strip()
|
|
|
|
# Get latest commit short from Git
|
|
revcmd = "git log --pretty=format:'%h' -n 1"
|
|
commit = subprocess.check_output(revcmd, shell=True).decode().strip()
|
|
|
|
# Get branch name from Git
|
|
branchcmd = "git rev-parse --abbrev-ref HEAD"
|
|
branch = subprocess.check_output(branchcmd, shell=True).decode().strip()
|
|
|
|
print("Project: %s" % project)
|
|
print("Version: %s" % version)
|
|
print("Commit: %s" % commit)
|
|
print("Branch: %s" % branch)
|
|
|
|
# Make all available for use in the macros
|
|
customName(project, version, commit, branch)
|
|
|
|
sys.stdout.write(GREEN)
|
|
print("Git information has been added to the build flags")
|
|
# print(env.Dump())
|
|
sys.stdout.write(RESET)
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
sys.stdout.write(RED)
|
|
print("Error: %s" % e)
|
|
onError()
|
|
|
|
|
|
def customName(project, version, commit, branch):
|
|
|
|
my_flags = env.ParseFlags(env["BUILD_FLAGS"])
|
|
defines = dict()
|
|
|
|
# add the git information to the build flags
|
|
my_flags.get("CPPDEFINES").append(("PIO_SRC_NAM", project))
|
|
my_flags.get("CPPDEFINES").append(("PIO_SRC_TAG", version))
|
|
my_flags.get("CPPDEFINES").append(("PIO_SRC_REV", commit))
|
|
my_flags.get("CPPDEFINES").append(("PIO_SRC_BRH", branch))
|
|
|
|
for x in my_flags.get("CPPDEFINES"):
|
|
if type(x) is tuple:
|
|
(k, v) = x
|
|
defines[k] = v
|
|
# print("Type Tuple: %s" % x)
|
|
elif type(x) is list:
|
|
k = x[0]
|
|
v = x[1]
|
|
defines[k] = v
|
|
# print("Type List: %s" % x)
|
|
else:
|
|
defines[x] = "" # empty value
|
|
# print("Warning: unknown type for %s" % x)
|
|
|
|
# print("Project: %s" % defines)
|
|
# strip quotes needed for shell escaping
|
|
s = lambda x: x.replace('"', "")
|
|
s = lambda x: x.replace("'", "")
|
|
|
|
""" env.Replace(
|
|
PROGNAME="%s-%s-%s-%s-%s"
|
|
% (
|
|
s(defines.get("PIO_SRC_NAM")),
|
|
s(defines.get("PIO_SRC_TAG")),
|
|
str(env["PIOENV"]),
|
|
s(defines.get("PIO_SRC_REV")),
|
|
s(defines.get("PIO_SRC_BRH")),
|
|
)
|
|
) """
|
|
|
|
firm_version = env.GetProjectOption("custom_firmware_version")
|
|
|
|
# strip quotes needed for shell escaping in the firmware version
|
|
|
|
if firm_version is None:
|
|
firm_version = "0.0.0"
|
|
else:
|
|
firm_version = firm_version.replace('"', "")
|
|
firm_version = firm_version.replace("'", "")
|
|
|
|
env.Replace(
|
|
PROGNAME="%s-v%s-%s"
|
|
% (
|
|
str(env["PIOENV"]),
|
|
firm_version,
|
|
s(defines.get("PIO_SRC_BRH")),
|
|
)
|
|
)
|
|
|
|
# detect if there is a forward slash in the PROGNAME and replace it with an underscore
|
|
if "/" in env["PROGNAME"]:
|
|
env.Replace(PROGNAME="%s" % (env["PROGNAME"].replace("/", "-")))
|
|
|
|
# create a file with the name of the firmware
|
|
env.Execute(
|
|
"echo %s > %s" % (env["PROGNAME"], env.subst("./tools/firmware_name.txt"))
|
|
)
|
|
|
|
# replace the VERSION macro with the version from Git
|
|
env.Replace(VERSION="%s" % (s(defines.get("PIO_SRC_TAG"))))
|
|
|
|
|
|
try:
|
|
flags = env["BUILD_FLAGS"]
|
|
my_flags = env.ParseFlags(flags)
|
|
|
|
# Dump global construction environment (for debug purpose)
|
|
# write env.Dump() to a file
|
|
# with open("env_dump.txt", "w") as f:
|
|
# f.write(env.Dump())
|
|
|
|
handleGit()
|
|
except ValueError as ex:
|
|
# look for apostrophes and warn the user
|
|
sys.stdout.write(RED)
|
|
print(
|
|
"[Warning]: Apostrophes are not allowed in the build flags. Please remove them from the \033[;1m\033[1;36m`user-config.ini` \033[1;31mfile and try again."
|
|
)
|
|
raise Exception(
|
|
"Could not parse BUILD_FLAGS - Possible apostrophy used in user configuration",
|
|
ex,
|
|
)
|