zephyr/subsys/bindesc/bindesc_version.c
Yonatan Schachter 5508b17fb4 bindesc: Add initial support for binary descriptor definition
Binary descriptors are data objects stored at a known location
of a binary image. They can be read by an external tool or image,
and are used mostly for build information: version, build time,
host information, etc.
This commit adds initial support for defining such descriptors.

Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2023-09-28 07:39:09 -04:00

65 lines
2.3 KiB
C

/*
* Copyright (c) 2023 Yonatan Schachter
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/bindesc.h>
#include <version.h>
#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_STRING)
BINDESC_STR_DEFINE(kernel_version_string, BINDESC_ID_KERNEL_VERSION_STRING,
KERNEL_VERSION_STRING);
#endif /* IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_STRING) */
#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_MAJOR)
BINDESC_UINT_DEFINE(kernel_version_major, BINDESC_ID_KERNEL_VERSION_MAJOR,
KERNEL_VERSION_MAJOR);
#endif /* IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_MAJOR) */
#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_MINOR)
BINDESC_UINT_DEFINE(kernel_version_minor, BINDESC_ID_KERNEL_VERSION_MINOR,
KERNEL_VERSION_MINOR);
#endif /* IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_MINOR) */
#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_PATCHLEVEL)
BINDESC_UINT_DEFINE(kernel_version_patchlevel, BINDESC_ID_KERNEL_VERSION_PATCHLEVEL,
KERNEL_PATCHLEVEL);
#endif /* IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_PATCHLEVEL) */
#if IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_NUMBER)
BINDESC_UINT_DEFINE(kernel_version_number, BINDESC_ID_KERNEL_VERSION_NUMBER,
KERNEL_VERSION_NUMBER);
#endif /* IS_ENABLED(CONFIG_BINDESC_KERNEL_VERSION_NUMBER) */
#if IS_ENABLED(HAS_APP_VERSION)
#include <app_version.h>
#if IS_ENABLED(CONFIG_BINDESC_APP_VERSION_STRING)
BINDESC_STR_DEFINE(app_version_string, BINDESC_ID_APP_VERSION_STRING,
APP_VERSION_STRING);
#endif /* IS_ENABLED(CONFIG_BINDESC_APP_VERSION_STRING) */
#if IS_ENABLED(CONFIG_BINDESC_APP_VERSION_MAJOR)
BINDESC_UINT_DEFINE(app_version_major, BINDESC_ID_APP_VERSION_MAJOR,
APP_VERSION_MAJOR);
#endif /* IS_ENABLED(CONFIG_BINDESC_APP_VERSION_MAJOR) */
#if IS_ENABLED(CONFIG_BINDESC_APP_VERSION_MINOR)
BINDESC_UINT_DEFINE(app_version_minor, BINDESC_ID_APP_VERSION_MINOR,
APP_VERSION_MINOR);
#endif /* IS_ENABLED(CONFIG_BINDESC_APP_VERSION_MINOR) */
#if IS_ENABLED(CONFIG_BINDESC_APP_VERSION_PATCHLEVEL)
BINDESC_UINT_DEFINE(app_version_patchlevel, BINDESC_ID_APP_VERSION_PATCHLEVEL,
APP_PATCHLEVEL);
#endif /* IS_ENABLED(CONFIG_BINDESC_APP_VERSION_PATCHLEVEL) */
#if IS_ENABLED(CONFIG_BINDESC_APP_VERSION_NUMBER)
BINDESC_UINT_DEFINE(app_version_number, BINDESC_ID_APP_VERSION_NUMBER,
APP_VERSION_NUMBER);
#endif /* IS_ENABLED(CONFIG_BINDESC_APP_VERSION_NUMBER) */
#endif /* IS_ENABLED(HAS_APP_VERSION) */