Simple Build Info v2.0r1
Simple Build Info library provides macros for creating and handling build info from flash.
Loading...
Searching...
No Matches
sBuildInfo.h
Go to the documentation of this file.
1
10/*
11License
12
13Copyright (c) 2023, silvio3105 (www.github.com/silvio3105)
14
15Access and use of this Project and its contents are granted free of charge to any Person.
16The Person is allowed to copy, modify and use The Project and its contents only for non-commercial use.
17Commercial use of this Project and its contents is prohibited.
18Modifying this License and/or sublicensing is prohibited.
19
20THE PROJECT AND ITS CONTENT ARE PROVIDED "AS IS" WITH ALL FAULTS AND WITHOUT EXPRESSED OR IMPLIED WARRANTY.
21THE AUTHOR KEEPS ALL RIGHTS TO CHANGE OR REMOVE THE CONTENTS OF THIS PROJECT WITHOUT PREVIOUS NOTICE.
22THE AUTHOR IS NOT RESPONSIBLE FOR DAMAGE OF ANY KIND OR LIABILITY CAUSED BY USING THE CONTENTS OF THIS PROJECT.
23
24This License shall be included in all methodal textual files.
25*/
26
27
28#ifndef _SBUILDINFO_H_
29#define _SBUILDINFO_H_
30
31
51// ----- DEFINES
52#define SBI_VERSION "v2.0r1"
54#ifndef SBI_APP_NAME_LEN
55#define SBI_APP_NAME_LEN 16
56#endif // SBI_APP_NAME_LEN
57
58#ifndef SBI_APP_VER_LEN
59#define SBI_APP_VER_LEN 16
60#endif // SBI_APP_VER_LEN
61
62#ifndef SBI_APP_HW_LEN
63#define SBI_APP_HW_LEN 16
64#endif // SBI_APP_HW_LEN
65
66#ifndef SBI_APP_FLAGS_LEN
67#define SBI_APP_FLAGS_LEN 12
68#endif // SBI_APP_FLAGS_LEN
69
70
71
72// ----- CODE SNIPPETS
73#ifndef SBI_NO_FIX
84#define __SBI(_name, _ver, _rev, _flags) \
85 volatile const build_info_t __buildInfo __attribute__((section(".sBuildInfo"))) = \
86 { \
87 _name, \
88 _ver, \
89 _rev, \
90 __DATE__, \
91 _flags \
92 }
93
108#define __SBI_EXT(_tag, _variant, _ver, _rev, _flags) \
109 volatile const build_info_t __buildInfo __attribute__((section(".sBuildInfo"))) = \
110 { \
111 { \
112 .tag = _tag, \
113 _variant \
114 }, \
115 _ver, \
116 _rev, \
117 __DATE__, \
118 _flags \
119 }
120#else // SBI_NO_FIX
129#define __SBI(_name, _ver, _rev, _flags) \
130 volatile const build_info_t __buildInfo = \
131 { \
132 _name, \
133 _ver, \
134 _rev, \
135 __DATE__, \
136 _flags \
137 }
138
152#define __SBI_EXT(_tag, _variant, _ver, _rev, _flags) \
153 volatile const build_info_t __buildInfo = \
154 { \
155 { \
156 .tag = _tag, \
157 _variant \
158 }, \
159 _ver, \
160 _rev, \
161 __DATE__, \
162 _flags \
163 }
164#endif // SBI_NO_FIX
165
166
167#define SBI_NAME __buildInfo.app.name
168#define SBI_TAG __buildInfo.app.tag
169#define SBI_VARIANT __buildInfo.app.variant
170#define SBI_VER __buildInfo.appVer
171#define SBI_HW __buildInfo.hwRev
172#define SBI_DATE __buildInfo.buildDate
173#define SBI_FLAGS __buildInfo.buildFlags
174#define SBI_USED (void)(SBI_NAME)
177// ----- STRUCTS
183{
188 union
189 {
190 const char name[SBI_APP_NAME_LEN];
191 struct
192 {
193 const char tag[SBI_APP_NAME_LEN / 2];
194 const char variant[SBI_APP_NAME_LEN / 2];
195 };
198 const char hwRev[SBI_APP_HW_LEN];
199 const char buildDate[12];
201};
202
203
204// ----- EXTERNS
205extern volatile const build_info_t __buildInfo;
206
207
211#endif // _SBUILDINFO_H_
212
213// END WITH NEW LINE
#define SBI_APP_FLAGS_LEN
Maximum length of build flags.
Definition sBuildInfo.h:67
#define SBI_APP_VER_LEN
Maximum length of application version.
Definition sBuildInfo.h:59
#define SBI_APP_NAME_LEN
Maximum length of application name.
Definition sBuildInfo.h:55
#define SBI_APP_HW_LEN
Maximum length of hardware version.
Definition sBuildInfo.h:63
Build info struct.
Definition sBuildInfo.h:183
const char tag[SBI_APP_NAME_LEN/2]
C-string for application tag.
Definition sBuildInfo.h:193
const char buildFlags[SBI_APP_FLAGS_LEN]
C-string for build flags.
Definition sBuildInfo.h:200
const char appVer[SBI_APP_VER_LEN]
C-string for application version.
Definition sBuildInfo.h:197
const char buildDate[12]
C-string for build date.
Definition sBuildInfo.h:199
const char hwRev[SBI_APP_HW_LEN]
C-string for hardware revision.
Definition sBuildInfo.h:198
union build_info_t::@0 app
Union of application name, tag and variant.
const char name[SBI_APP_NAME_LEN]
C-string for application name.
Definition sBuildInfo.h:190
const char variant[SBI_APP_NAME_LEN/2]
C-string for application variant name.
Definition sBuildInfo.h:194