mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[ion/device] Fix the location of the version informations
Change-Id: I9991f2b0c9a4ee678bd27f2e619f8772678a84f0
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
GIT := $(shell command -v git 2> /dev/null)
|
||||
PATCH_LEVEL = NONE
|
||||
ifdef GIT
|
||||
PATCH_LEVEL = `git rev-parse HEAD`
|
||||
PATCH_LEVEL = `git rev-parse --short HEAD`
|
||||
endif
|
||||
|
||||
SFLAGS += -Iion/include -DKD_CONFIG_H=1
|
||||
ion/src/shared/software_version.o: SFLAGS += -DPATCH_LEVEL=$(PATCH_LEVEL) -DVERSION=$(VERSION)
|
||||
include ion/src/$(PLATFORM)/Makefile
|
||||
|
||||
include ion/src/$(PLATFORM)/Makefile
|
||||
include ion/src/shared/tools/Makefile
|
||||
|
||||
ion/src/shared/software_version.o: SFLAGS += -DPATCH_LEVEL=$(PATCH_LEVEL) -DVERSION=$(VERSION)
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
events.o \
|
||||
software_version.o \
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
include ion/src/device/boot/Makefile
|
||||
include ion/src/device/bench/Makefile
|
||||
|
||||
ion/src/shared/software_version.o: SFLAGS += -DHEADER_SECTION="__attribute__((section(\".header\")))"
|
||||
|
||||
objs += $(addprefix ion/src/shared/, \
|
||||
console_line.o \
|
||||
events_keyboard.o \
|
||||
|
||||
@@ -34,6 +34,10 @@ SECTIONS {
|
||||
KEEP(*(.isr_vector_table))
|
||||
} >FLASH
|
||||
|
||||
.header : {
|
||||
KEEP(*(.header))
|
||||
} >FLASH
|
||||
|
||||
.text : {
|
||||
. = ALIGN(4);
|
||||
*(.text)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <ion.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define STR_EXPAND(arg) #arg
|
||||
#define STR(arg) STR_EXPAND(arg)
|
||||
@@ -7,14 +8,41 @@
|
||||
#error This file expects PATCH_LEVEL to be defined
|
||||
#endif
|
||||
|
||||
#ifndef HEADER_SECTION
|
||||
#define HEADER_SECTION
|
||||
#endif
|
||||
|
||||
class VersionInfo {
|
||||
public:
|
||||
constexpr VersionInfo() :
|
||||
m_header(Magic),
|
||||
m_version(STR(VERSION)),
|
||||
m_patchLevel(STR(PATCH_LEVEL)),
|
||||
m_footer(Magic) { }
|
||||
const char * version() const {
|
||||
assert(m_header == Magic);
|
||||
assert(m_footer == Magic);
|
||||
return m_version;
|
||||
}
|
||||
const char * patchLevel() const {
|
||||
assert(m_header == Magic);
|
||||
assert(m_footer == Magic);
|
||||
return m_patchLevel;
|
||||
}
|
||||
private:
|
||||
constexpr static uint32_t Magic = 0xDEC00DF0;
|
||||
uint32_t m_header;
|
||||
const char m_version[8];
|
||||
const char m_patchLevel[8];
|
||||
uint32_t m_footer;
|
||||
};
|
||||
|
||||
constexpr VersionInfo HEADER_SECTION version_infos;
|
||||
|
||||
const char * Ion::softwareVersion() {
|
||||
return STR(VERSION);
|
||||
return version_infos.version();
|
||||
}
|
||||
|
||||
const char * Ion::patchLevel() {
|
||||
static char patchLevel[20] = {0};
|
||||
if (patchLevel[0] == 0) {
|
||||
strlcpy(patchLevel, STR(PATCH_LEVEL), 6+1);
|
||||
}
|
||||
return patchLevel;
|
||||
return version_infos.patchLevel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user