version: Replace bespoke application version with new version system
Uses Zephyr's new version infrastruction system for configuring the version of the application and displaying it. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
be3bfb0ec3
commit
2c85d9224f
|
@ -7,9 +7,6 @@
|
|||
cmake_minimum_required(VERSION 3.13.1)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
|
||||
project(app LANGUAGES C VERSION 1.0.0)
|
||||
|
||||
configure_file(app_version.h.in ${CMAKE_BINARY_DIR}/app/include/app_version.h)
|
||||
target_include_directories(app PRIVATE ${CMAKE_BINARY_DIR}/app/include src)
|
||||
project(app LANGUAGES C)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
|
|
5
app/VERSION
Normal file
5
app/VERSION
Normal file
|
@ -0,0 +1,5 @@
|
|||
VERSION_MAJOR = 1
|
||||
VERSION_MINOR = 0
|
||||
PATCHLEVEL = 0
|
||||
VERSION_TWEAK = 0
|
||||
EXTRAVERSION =
|
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* @file app_version.h
|
||||
*
|
||||
* Application version information.
|
||||
*
|
||||
* Copyright (c) 2021 Nordic Semiconductor ASA
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef APP_VERSION_H_
|
||||
#define APP_VERSION_H_
|
||||
|
||||
/** Application major version. */
|
||||
#define APP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}
|
||||
/** Application minor version. */
|
||||
#define APP_VERSION_MINOR ${PROJECT_VERSION_MINOR}
|
||||
/** Application patch version. */
|
||||
#define APP_VERSION_PATCH ${PROJECT_VERSION_PATCH}
|
||||
|
||||
/** Application version. */
|
||||
#define APP_VERSION \
|
||||
((APP_VERSION_MAJOR << 16) + \
|
||||
(APP_VERSION_MINOR << 8) + \
|
||||
APP_VERSION_PATCH)
|
||||
|
||||
/** Application version (string). */
|
||||
#define APP_VERSION_STR "${PROJECT_VERSION}"
|
||||
|
||||
#endif /* APP_VERSION_H_ */
|
|
@ -5,8 +5,7 @@
|
|||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
|
||||
#include "app_version.h"
|
||||
#include <app_version.h>
|
||||
|
||||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
|
||||
|
@ -16,7 +15,7 @@ int main(void)
|
|||
int ret;
|
||||
const struct device *sensor;
|
||||
|
||||
printk("Zephyr Example Application %s\n", APP_VERSION_STR);
|
||||
printk("Zephyr Example Application %s\n", APP_VERSION_STRING);
|
||||
|
||||
sensor = DEVICE_DT_GET(DT_NODELABEL(examplesensor0));
|
||||
if (!device_is_ready(sensor)) {
|
||||
|
|
Loading…
Reference in a new issue