From b817bcec6b5377fef0717d39348a173b7157a91b Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Fri, 18 Jan 2019 11:59:40 +0000 Subject: libcamera: Auto generate version information Generate a version string, and provide a global string object which allows applications to interrogate the current libcamera version information. The version header is automatically updated by meson on each build. The string roughly follows the semver [0] conventions of major.minor.patch-label as a value. [0] https://semver.org/ A script (utils/gen-version.sh) is provided which is modelled upon the processing from autoconf's git-version-gen. The gen-version.sh script will look for tags in the form vX.Y as starting points for the version string. While the repository does not have any matching tags, v0.0 will be assumed, resulting in versions with both major and minor being set to '0', and the patch count resulting from the number of patches in the history to that point. Finally, a uniquely identifying shortened hash is provided from git: v0.0.509+0ec0edf7 Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/libcamera/camera_manager.cpp | 8 ++++++++ src/libcamera/meson.build | 1 + 2 files changed, 9 insertions(+) (limited to 'src') diff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp index cf881ce2..c5da46b4 100644 --- a/src/libcamera/camera_manager.cpp +++ b/src/libcamera/camera_manager.cpp @@ -9,6 +9,7 @@ #include #include +#include #include "device_enumerator.h" #include "event_dispatcher_poll.h" @@ -25,6 +26,11 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Camera) +/** + * \brief The library global version string + */ +const std::string version(LIBCAMERA_VERSION); + /** * \class CameraManager * \brief Provide access and manage all cameras in the system @@ -79,6 +85,8 @@ int CameraManager::start() if (enumerator_) return -EBUSY; + LOG(Camera, Info) << "libcamera " << version; + enumerator_ = DeviceEnumerator::create(); if (!enumerator_ || enumerator_->enumerate()) return -ENODEV; diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 8075b1f6..336f4f06 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -80,6 +80,7 @@ control_types_cpp = custom_target('control_types_cpp', libcamera_sources += control_types_cpp libcamera_deps = [ + declare_dependency(sources : version_h), cc.find_library('dl'), libudev, ] -- cgit v1.2.1