1 /*
2  * Copyright (c) 2023 Yonatan Schachter
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/kernel.h>
8 #include <zephyr/bindesc.h>
9 #include <zephyr/version.h>
10 
11 #if defined(CONFIG_BINDESC_KERNEL_VERSION_STRING)
12 BINDESC_STR_DEFINE(kernel_version_string, BINDESC_ID_KERNEL_VERSION_STRING,
13 			KERNEL_VERSION_STRING);
14 #endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_STRING) */
15 
16 #if defined(CONFIG_BINDESC_KERNEL_VERSION_MAJOR)
17 BINDESC_UINT_DEFINE(kernel_version_major, BINDESC_ID_KERNEL_VERSION_MAJOR,
18 			KERNEL_VERSION_MAJOR);
19 #endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_MAJOR) */
20 
21 #if defined(CONFIG_BINDESC_KERNEL_VERSION_MINOR)
22 BINDESC_UINT_DEFINE(kernel_version_minor, BINDESC_ID_KERNEL_VERSION_MINOR,
23 			KERNEL_VERSION_MINOR);
24 #endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_MINOR) */
25 
26 #if defined(CONFIG_BINDESC_KERNEL_VERSION_PATCHLEVEL)
27 BINDESC_UINT_DEFINE(kernel_version_patchlevel, BINDESC_ID_KERNEL_VERSION_PATCHLEVEL,
28 			KERNEL_PATCHLEVEL);
29 #endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_PATCHLEVEL) */
30 
31 #if defined(CONFIG_BINDESC_KERNEL_VERSION_NUMBER)
32 BINDESC_UINT_DEFINE(kernel_version_number, BINDESC_ID_KERNEL_VERSION_NUMBER,
33 			KERNEL_VERSION_NUMBER);
34 #endif /* defined(CONFIG_BINDESC_KERNEL_VERSION_NUMBER) */
35 
36 #if defined(CONFIG_BINDESC_KERNEL_BUILD_VERSION)
37 BINDESC_STR_DEFINE(kernel_build_version, BINDESC_ID_KERNEL_BUILD_VERSION,
38 			STRINGIFY(BUILD_VERSION));
39 #endif /* CONFIG_BINDESC_KERNEL_BUILD_VERSION */
40 
41 #if defined(HAS_APP_VERSION)
42 #include <zephyr/app_version.h>
43 
44 #if defined(CONFIG_BINDESC_APP_VERSION_STRING)
45 BINDESC_STR_DEFINE(app_version_string, BINDESC_ID_APP_VERSION_STRING,
46 			APP_VERSION_STRING);
47 #endif /* defined(CONFIG_BINDESC_APP_VERSION_STRING) */
48 
49 #if defined(CONFIG_BINDESC_APP_VERSION_MAJOR)
50 BINDESC_UINT_DEFINE(app_version_major, BINDESC_ID_APP_VERSION_MAJOR,
51 			APP_VERSION_MAJOR);
52 #endif /* defined(CONFIG_BINDESC_APP_VERSION_MAJOR) */
53 
54 #if defined(CONFIG_BINDESC_APP_VERSION_MINOR)
55 BINDESC_UINT_DEFINE(app_version_minor, BINDESC_ID_APP_VERSION_MINOR,
56 			APP_VERSION_MINOR);
57 #endif /* defined(CONFIG_BINDESC_APP_VERSION_MINOR) */
58 
59 #if defined(CONFIG_BINDESC_APP_VERSION_PATCHLEVEL)
60 BINDESC_UINT_DEFINE(app_version_patchlevel, BINDESC_ID_APP_VERSION_PATCHLEVEL,
61 			APP_PATCHLEVEL);
62 #endif /* defined(CONFIG_BINDESC_APP_VERSION_PATCHLEVEL) */
63 
64 #if defined(CONFIG_BINDESC_APP_VERSION_NUMBER)
65 BINDESC_UINT_DEFINE(app_version_number, BINDESC_ID_APP_VERSION_NUMBER,
66 			APP_VERSION_NUMBER);
67 #endif /* defined(CONFIG_BINDESC_APP_VERSION_NUMBER) */
68 
69 #if defined(CONFIG_BINDESC_APP_BUILD_VERSION)
70 BINDESC_STR_DEFINE(app_build_version, BINDESC_ID_APP_BUILD_VERSION,
71 			STRINGIFY(APP_BUILD_VERSION));
72 #endif /* CONFIG_BINDESC_APP_BUILD_VERSION */
73 
74 #endif /* defined(HAS_APP_VERSION) */
75