Patch Detail
Show a patch.
GET /api/patches/1604/?format=api
{ "id": 1604, "url": "https://patchwork.libcamera.org/api/patches/1604/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1604/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20190704130347.9372-2-kieran.bingham@ideasonboard.com>", "date": "2019-07-04T13:03:39", "name": "[libcamera-devel,v2,2/4] libcamera: Auto generate version information", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d7cda58c2402e4fb706fa1241cdda2741bc74228", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1604/mbox/", "series": [ { "id": 399, "url": "https://patchwork.libcamera.org/api/series/399/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=399", "date": "2019-07-04T13:03:38", "name": "[libcamera-devel,1/4] Documentation: Make the project brief more expressive", "version": 1, "mbox": "https://patchwork.libcamera.org/series/399/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1604/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1604/checks/", "tags": {}, "headers": { "Return-Path": "<kieran.bingham@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 327FC61569\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 4 Jul 2019 15:03:52 +0200 (CEST)", "from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B9C1B2AF;\n\tThu, 4 Jul 2019 15:03:51 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562245431;\n\tbh=lVmwcE5IIfm80uWWnVDzsDkB7qENFPtscBmaqv/7ufU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=stHj9FesAI97k1+o+gq0zSrQkKG129slalxyF+1ji47eLhpsrMyXbuOHW9IlM6FAT\n\t1PbRbySImNa3nvUPZA1+OoyECT3FA5yEgvj220m68dwpXykEgU5otJdlzZKeQjrUGm\n\tdoysyrVzM3b5Oq0DfZ6J1ZDQ2Z+MBCuD/Z7O4Xsc=", "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>", "Date": "Thu, 4 Jul 2019 14:03:39 +0100", "Message-Id": "<20190704130347.9372-2-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190704130347.9372-1-kieran.bingham@ideasonboard.com>", "References": "<20190704130347.9372-1-kieran.bingham@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/4] libcamera: Auto generate version\n\tinformation", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "X-List-Received-Date": "Thu, 04 Jul 2019 13:03:52 -0000" }, "content": "Generate a version string, and provide a global singleton object which\nallows applications to interogate the current libcamera version\ninformation.\n\nThe version header is automatically updated by meson on each build.\nThe string roughly follows the semver [0] conventions of\nmajor.minor.patch-label as a value.\n\n[0] https://semver.org/\n\nThe utils/version-gen script will look for tags in the form vX.Y as\nstarting points for the version string. While the repository does not\nhave any matching tags, v0.0 will be assumed, resulting in versions with\nboth major and minor being set to '0', and the patch count resulting\nfrom the number of patches in the history to that point.\n\nFinally, a uniquely identifying shortened checksum is provided from git:\n\n\tv0.0.509.c544\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nv2:\n - Store VCS_Tag return reference for dependancy linking\n - Fix indentation on meson.build\n - fix shell usage and shellcheck warnings in version-gen\n - Make LibcameraVersion version global\n - Sphinx version now explicit as to it's source from\n Documentation/meson.build\n - Pass project_version() through api_version\n - Use Camera object to report version rather than global constructor.\n---\n Documentation/conf.py | 7 ++----\n Documentation/meson.build | 2 +-\n include/libcamera/meson.build | 1 +\n include/libcamera/version.h | 24 +++++++++++++++++++++\n meson.build | 12 ++++++-----\n src/libcamera/camera_manager.cpp | 3 +++\n src/libcamera/meson.build | 1 +\n src/libcamera/version.cpp | 35 ++++++++++++++++++++++++++++++\n utils/version-gen | 37 ++++++++++++++++++++++++++++++++\n version.h.in | 14 ++++++++++++\n 10 files changed, 125 insertions(+), 11 deletions(-)\n create mode 100644 include/libcamera/version.h\n create mode 100644 src/libcamera/version.cpp\n create mode 100755 utils/version-gen\n create mode 100644 version.h.in", "diff": "diff --git a/Documentation/conf.py b/Documentation/conf.py\nindex 970edf3d7298..3ac61a208145 100644\n--- a/Documentation/conf.py\n+++ b/Documentation/conf.py\n@@ -23,11 +23,8 @@ project = 'libcamera'\n copyright = '2018-2019, The libcamera documentation authors'\n author = u'Kieran Bingham, Jacopo Mondi, Laurent Pinchart, Niklas Söderlund'\n \n-# The short X.Y version\n-version = ''\n-# The full version, including alpha/beta/rc tags\n-release = '0.1'\n-\n+# Version information is provided by the build environment, through the\n+# configuration_data (cdata) in Documentation/meson.build\n \n # -- General configuration ---------------------------------------------------\n \ndiff --git a/Documentation/meson.build b/Documentation/meson.build\nindex 629e853120cb..91539b2afd66 100644\n--- a/Documentation/meson.build\n+++ b/Documentation/meson.build\n@@ -1,4 +1,4 @@\n-doc_install_dir = join_paths(get_option('datadir'), 'doc', 'libcamera-@0@'.format(api_version))\n+doc_install_dir = join_paths(get_option('datadir'), 'doc', 'libcamera-@0@'.format(meson.project_version()))\n \n #\n # Doxygen\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 15484724df01..c925af7b3f96 100644\n--- a/include/libcamera/meson.build\n+++ b/include/libcamera/meson.build\n@@ -12,6 +12,7 @@ libcamera_api = files([\n 'signal.h',\n 'stream.h',\n 'timer.h',\n+ 'version.h',\n ])\n \n gen_header = files('gen-header.sh')\ndiff --git a/include/libcamera/version.h b/include/libcamera/version.h\nnew file mode 100644\nindex 000000000000..3075cfb7a6e3\n--- /dev/null\n+++ b/include/libcamera/version.h\n@@ -0,0 +1,24 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * version.h - Library version information\n+ */\n+#ifndef __LIBCAMERA_VERSION_H__\n+#define __LIBCAMERA_VERSION_H__\n+\n+#include <string>\n+\n+namespace libcamera {\n+\n+class LibcameraVersion\n+{\n+public:\n+\tstd::string toString() const;\n+};\n+\n+extern const LibcameraVersion version;\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_VERSION_H__ */\ndiff --git a/meson.build b/meson.build\nindex a3b0bc820072..c34763162d7d 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -1,6 +1,8 @@\n project('libcamera', 'c', 'cpp',\n meson_version : '>= 0.40',\n- version : '0.1',\n+ version : run_command('utils/version-gen',\n+ '@0@'.format(meson.source_root()),\n+ check : true).stdout().strip(),\n default_options : [\n 'werror=true',\n 'warning_level=2',\n@@ -8,10 +10,10 @@ project('libcamera', 'c', 'cpp',\n ],\n license : 'LGPL 2.1+')\n \n-# TODO: Extract this from project.version.\n-# Ideally the version at Documentation/conf.py should be\n-# generated from this too.\n-api_version = '0.1'\n+vcs = vcs_tag(command: ['utils/version-gen', '.'],\n+ input: 'version.h.in',\n+ output: 'version.h',\n+ fallback: 'v0.0')\n \n cc = meson.get_compiler('c')\n config_h = configuration_data()\ndiff --git a/src/libcamera/camera_manager.cpp b/src/libcamera/camera_manager.cpp\nindex cf881ce2e641..09be4b03af45 100644\n--- a/src/libcamera/camera_manager.cpp\n+++ b/src/libcamera/camera_manager.cpp\n@@ -9,6 +9,7 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/event_dispatcher.h>\n+#include <libcamera/version.h>\n \n #include \"device_enumerator.h\"\n #include \"event_dispatcher_poll.h\"\n@@ -79,6 +80,8 @@ int CameraManager::start()\n \tif (enumerator_)\n \t\treturn -EBUSY;\n \n+\tLOG(Camera, Info) << \"libcamera version : \" << version.toString();\n+\n \tenumerator_ = DeviceEnumerator::create();\n \tif (!enumerator_ || enumerator_->enumerate())\n \t\treturn -ENODEV;\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 45bd9d1793aa..0110f1906bc3 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -28,6 +28,7 @@ libcamera_sources = files([\n 'v4l2_device.cpp',\n 'v4l2_subdevice.cpp',\n 'v4l2_videodevice.cpp',\n+ 'version.cpp',\n ])\n \n libcamera_headers = files([\ndiff --git a/src/libcamera/version.cpp b/src/libcamera/version.cpp\nnew file mode 100644\nindex 000000000000..d46985c88da5\n--- /dev/null\n+++ b/src/libcamera/version.cpp\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * version.cpp - Version information\n+ */\n+\n+#include <libcamera/version.h>\n+\n+#include \"log.h\"\n+\n+/* The version header is automatically generated at the base of the project. */\n+#include \"../../version.h\"\n+\n+namespace libcamera {\n+\n+LOG_DEFINE_CATEGORY(Version)\n+\n+/**\n+ * \\class LibcameraVersion\n+ *\n+ * Reports library version information\n+ */\n+\n+/**\n+ * \\brief Return the library version as a string\n+ */\n+std::string LibcameraVersion::toString() const\n+{\n+\treturn LIBCAMERA_VERSION;\n+}\n+\n+const LibcameraVersion version;\n+\n+} /* namespace libcamera */\ndiff --git a/utils/version-gen b/utils/version-gen\nnew file mode 100755\nindex 000000000000..481616b45c70\n--- /dev/null\n+++ b/utils/version-gen\n@@ -0,0 +1,37 @@\n+#!/bin/sh\n+\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Generate a version string using git describe\n+\n+if [ -n \"$1\" ]\n+then\n+\tcd \"$1\" 2>/dev/null || exit 1\n+fi\n+\n+# Get a short description from the tree.\n+version=$(git describe --abbrev=4 --match \"v[0-9]*\" 2>/dev/null)\n+\n+if [ -z \"$version\" ]\n+then\n+\t# Handle an un-tagged repository\n+\tsha=$(git describe --abbrev=4 --always 2>/dev/null)\n+\tcommits=$(git log --oneline | wc -l 2>/dev/null)\n+\tversion=v0.0.$commits.$sha\n+fi\n+\n+# Prevent changed timestamps causing -dirty labels\n+git update-index --refresh > /dev/null 2>&1\n+dirty=$(git diff-index --name-only HEAD 2>/dev/null) || dirty=\n+\n+# Strip the 'g'\n+version=$(echo \"$version\" | sed -e 's/-g/-/g')\n+\n+# Fix the '-' (the patch count) to a '.' as a version increment.\n+version=$(echo \"$version\" | sed -e 's/-/./g')\n+\n+if [ -n \"$dirty\" ]\n+then\n+\tversion=$version-dirty\n+fi\n+\n+echo \"$version\"\ndiff --git a/version.h.in b/version.h.in\nnew file mode 100644\nindex 000000000000..ad9134682df6\n--- /dev/null\n+++ b/version.h.in\n@@ -0,0 +1,14 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * version.h - VCS TAG generated file.\n+ *\n+ * This file is auto-generated. Do not modify.\n+ */\n+#ifndef __LIBCAMERA_VERSION_TAG_H__\n+#define __LIBCAMERA_VERSION_TAG_H__\n+\n+#define LIBCAMERA_VERSION \"@VCS_TAG@\"\n+\n+#endif // __LIBCAMERA_VERSION_TAG_H__\n", "prefixes": [ "libcamera-devel", "v2", "2/4" ] }