forked from jomjol/AI-on-the-edge-device
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.h
92 lines (71 loc) · 1.96 KB
/
version.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#ifndef _VERSION_H
#define _VERSION_H
// These variables are autogenerated and compiled
// into the library by the version.cmake script
extern "C"
{
extern const char* GIT_TAG;
extern const char* GIT_REV;
extern const char* GIT_BRANCH;
extern const char* BUILD_TIME;
}
#include <string>
#include <string.h>
#include "Helper.h"
#include <fstream>
#include <algorithm>
const char* build_time(void)
{
return BUILD_TIME;
}
const char* libfive_git_version(void)
{
return GIT_TAG;
}
const char* libfive_git_revision(void)
{
return GIT_REV;
}
const char* libfive_git_branch(void)
{
return GIT_BRANCH;
}
std::string getFwVersion(void) {
std::string buf;
if (std::string(GIT_TAG) == "") { // Tag not set, show branch
buf = "Development-Branch: " + std::string(GIT_BRANCH);
}
else { // Tag is set, ignore branch
buf = "Release: " + std::string(GIT_TAG);
}
buf = buf + " (Commit: " + std::string(GIT_REV) + ")";
return buf;
}
std::string getHTMLversion(void){
char buf[100]="?\0";
FILE* pFile;
string fn = FormatFileName("/sdcard/html/version.txt");
pFile = fopen(fn.c_str(), "r");
if (pFile == NULL)
return std::string(buf);
fgets(buf, sizeof(buf), pFile); // Line 1: Version
fclose(pFile);
string value = string(buf);
value.erase(std::remove(value.begin(), value.end(), '\n'), value.end()); // Remove any newlines
return value;
}
std::string getHTMLcommit(void){
char buf[100]="?\0";
FILE* pFile;
string fn = FormatFileName("/sdcard/html/version.txt");
pFile = fopen(fn.c_str(), "r");
if (pFile == NULL)
return std::string(buf);
fgets(buf, sizeof(buf), pFile); // Line 1: Version -> ignored
fgets(buf, sizeof(buf), pFile); // Line 2: Commit
fclose(pFile);
string value = string(buf);
value.erase(std::remove(value.begin(), value.end(), '\n'), value.end()); // Remove any newlines
return value;
}
#endif // _VERSION_H