Merge pull request #1033 from caco3/auto-add-version

Auto add version
This commit is contained in:
jomjol
2022-09-19 20:03:56 +02:00
committed by GitHub
10 changed files with 69 additions and 23 deletions

View File

@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.13.4)
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common)
set(PROJECT_VER "0.0.9.3")
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp

View File

@@ -39,6 +39,7 @@ set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
const char* GIT_TAG=\"${GIT_TAG}\";
const char* GIT_BRANCH=\"${GIT_BRANCH}\";
const char* BUILD_TIME=\"${BUILD_TIME}\";")
set(VERSION_HTML "${GIT_BRANCH}, ${GIT_REV}${GIT_DIFF}, ${GIT_TAG}")
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp VERSION_)
@@ -48,6 +49,7 @@ endif()
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cpp "${VERSION}")
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/../sd-card/html/version.txt "${VERSION_HTML}")
endif()
#######################################################################
#######################################################################

View File

@@ -29,6 +29,11 @@
#include "server_camera.h"
#include "Helper.h"
extern const char* GIT_TAG;
extern const char* GIT_REV;
extern const char* GIT_BRANCH;
extern const char* BUILD_TIME;
// #include "jomjol_WS2812Slow.h"
#include "SmartLeds.h"
@@ -133,6 +138,12 @@ void task_NoSDBlink(void *pvParameter)
extern "C" void app_main(void)
{
TickType_t xDelay;
string versionFormated = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
"', Revision: " + std::string(GIT_REV) +", Date/Time: " + std::string(BUILD_TIME);
printf("=============================================================================================\n");
printf("%s\n", versionFormated.c_str());
printf("=============================================================================================\n");
PowerResetCamera();
esp_err_t cam = Camera.InitCam();
@@ -179,7 +190,8 @@ extern "C" void app_main(void)
setBootTime();
LogFile.WriteToFile("=============================================================================================");
LogFile.WriteToFile("=================================== Main Started ============================================");
LogFile.WriteToFile("=============================================================================================");
LogFile.WriteToFile("=============================================================================================");
LogFile.WriteToFile(versionFormated);
LogFile.SwitchOnOff(false);
std::string zw = gettimestring("%Y%m%d-%H%M%S");

View File

@@ -82,7 +82,9 @@ esp_err_t info_get_handler(httpd_req_t *req)
if (_task.compare("GitBaseBranch") == 0)
{
httpd_resp_sendstr_chunk(req, git_base_branch());
string buf = "Branch: '" + std::string(GIT_BRANCH) + "', Tag: '" + std::string(GIT_TAG) + \
"', Revision: " + std::string(GIT_REV);
httpd_resp_sendstr_chunk(req, buf.c_str());
httpd_resp_sendstr_chunk(req, NULL);
return ESP_OK;
}
@@ -285,7 +287,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
std::string gitversion = libfive_git_version();
std::string buildtime = build_time();
std::string gitbranch = libfive_git_branch();
std::string gitbasebranch = git_base_branch();
std::string gittag = libfive_git_version();
std::string gitrevision = libfive_git_revision();
std::string htmlversion = getHTMLversion();
char freeheapmem[11];
sprintf(freeheapmem, "%zu", esp_get_free_heap_size());
@@ -300,7 +303,8 @@ esp_err_t sysinfo_handler(httpd_req_t *req)
\"firmware\" : \"" + gitversion + "\",\
\"buildtime\" : \"" + buildtime + "\",\
\"gitbranch\" : \"" + gitbranch + "\",\
\"gitbasebranch\" : \"" + gitbasebranch + "\",\
\"gittag\" : \"" + gittag + "\",\
\"gitrevision\" : \"" + gitrevision + "\",\
\"html\" : \"" + htmlversion + "\",\
\"cputemp\" : \"" + cputemp + "\",\
\"hostname\" : \"" + hostname + "\",\

View File

@@ -1,3 +1,6 @@
#ifndef _VERSION_H
#define _VERSION_H
// These variables are autogenerated and compiled
// into the library by the version.cmake script
extern "C"
@@ -13,14 +16,6 @@ extern "C"
#include "Helper.h"
#include <fstream>
const char* GIT_BASE_BRANCH = "master - v11.3.0 - 2022-09-16";
const char* git_base_branch(void)
{
return GIT_BASE_BRANCH;
}
const char* build_time(void)
{
@@ -43,7 +38,7 @@ const char* libfive_git_branch(void)
}
char _char_getHTMLversion[20]="NaN\0";
char _char_getHTMLversion[50]="NaN\0";
const char* getHTMLversion(void){
FILE* pFile;
@@ -53,8 +48,10 @@ const char* getHTMLversion(void){
if (pFile == NULL)
return _char_getHTMLversion;
fgets(_char_getHTMLversion, 20, pFile);
fgets(_char_getHTMLversion, sizeof(_char_getHTMLversion), pFile);
fclose(pFile);
return _char_getHTMLversion;
}
}
#endif // _VERSION_H

View File

@@ -29,3 +29,28 @@ function LoadHostname() {
// alert("Loading Hostname failed");
}
}
function LoadVersion() {
_basepath = getbasepath();
var xhttp = new XMLHttpRequest();
xhttp.addEventListener('load', function(event) {
if (xhttp.status >= 200 && xhttp.status < 300) {
version = xhttp.responseText;
document.getElementById("Version").innerHTML = version;
}
else {
console.warn(request.statusText, request.responseText);
}
});
try {
url = _basepath + '/version?type=GitBaseBranch';
xhttp.open("GET", url, true);
xhttp.send();
}
catch (error)
{}
}

View File

@@ -151,8 +151,11 @@ li.dropdown {
<iframe name="maincontent" class="iframe" id="maincontent" src="wasserzaehler_roi.html"></iframe>
<span id="Version" style="font-size: 10px; margin-top: -5px">Loading version...</span>
<script type="text/javascript">
LoadHostname();
LoadVersion();
</script>
</div>

View File

@@ -152,11 +152,15 @@ li.dropdown {
<iframe name="maincontent" class="iframe" id="maincontent" src="edit_config_param.html"></iframe>
<span id="Version" style="font-size: 10px; margin-top: -5px">Loading version...</span>
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="gethost.js"></script>
<script type="text/javascript">
LoadHostname();
LoadVersion();
</script>
</div>

View File

@@ -12,7 +12,7 @@ h3 {font-size: 1.2em;}
p {font-size: 1em;}
div {
width: 250px;
width: 350px;
padding: 10px 5px;
border: 1px solid #ccc;
font-family: arial;
@@ -93,22 +93,22 @@ div {
<tr>
<td>
Git-Base-Branch:
Git-Tag:
</td>
<td>
<div>
<object data="/version?type=GitBaseBranch"></object>
<object data="/version?type=GitTag"></object>
</div>
</td>
</tr>
<tr>
<td>
Git-Version:
Git-Revision:
</td>
<td>
<div>
<object data="/version?type=GitVersion"></object>
<object data="/version?type=GitRevision"></object>
</div>
</td>
</tr>

View File

@@ -1 +1,2 @@
16.4.1
# HTML version
# Do not edit, it will get be updated by cmake!