Show a patch.

GET /api/patches/1395/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1395,
    "url": "https://patchwork.libcamera.org/api/patches/1395/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1395/",
    "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": "<20190611201411.16369-1-kieran.bingham@ideasonboard.com>",
    "date": "2019-06-11T20:14:11",
    "name": "[libcamera-devel] libcamera: Auto generate version information",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "0bd94d6b5082acb55aa0ae100da77242a9d82cae",
    "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/1395/mbox/",
    "series": [
        {
            "id": 350,
            "url": "https://patchwork.libcamera.org/api/series/350/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=350",
            "date": "2019-06-11T20:14:11",
            "name": "[libcamera-devel] libcamera: Auto generate version information",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/350/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1395/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1395/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AECFE61FB7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 11 Jun 2019 22:14:18 +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 25D8DFA0;\n\tTue, 11 Jun 2019 22:14:18 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560284058;\n\tbh=poC7n5GNhItFhm/AzwSlLX7yEbzdObQfBOcMJc1XuYw=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=Yb6JuQLAM8icCMRHOWI3poE+LHPsyAcGjfkbjhEcqGNCOaXVZk5rvnMzotGJ3IwWo\n\t70hTS4q73CAcGu92fciLHzB5m2RUx8dmFXWuj1hLpXcXHPvHHzNdc4Gsb0hGcxHxWe\n\tO8cZ7j2eOqzQgdPaiok8Muh5Im8Cgp4y8+RGJfTU=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Tue, 11 Jun 2019 21:14:11 +0100",
        "Message-Id": "<20190611201411.16369-1-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] 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": "Tue, 11 Jun 2019 20:14:18 -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 Documentation/conf.py         |  6 ++++--\n include/libcamera/meson.build |  1 +\n include/libcamera/version.h   | 23 ++++++++++++++++++++\n meson.build                   |  9 +++++++-\n src/libcamera/meson.build     |  1 +\n src/libcamera/version.cpp     | 40 +++++++++++++++++++++++++++++++++++\n utils/version-gen             | 36 +++++++++++++++++++++++++++++++\n version.h.in                  |  3 +++\n 8 files changed, 116 insertions(+), 3 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..e5980b98216d 100644\n--- a/Documentation/conf.py\n+++ b/Documentation/conf.py\n@@ -23,10 +23,12 @@ project = 'libcamera'\n copyright = '2018-2019, The libcamera documentation authors'\n author = u'Kieran Bingham, Jacopo Mondi, Laurent Pinchart, Niklas Söderlund'\n \n+# Vesion information is provided by the build environment.\n+#\n # The short X.Y version\n-version = ''\n+# version = ''\n # The full version, including alpha/beta/rc tags\n-release = '0.1'\n+# release = '0.1'\n \n \n # -- General configuration ---------------------------------------------------\ndiff --git a/include/libcamera/meson.build b/include/libcamera/meson.build\nindex 1b86fdc7fca4..201832105457 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 = join_paths(meson.current_source_dir(), 'gen-header.sh')\ndiff --git a/include/libcamera/version.h b/include/libcamera/version.h\nnew file mode 100644\nindex 000000000000..ad21f148e748\n--- /dev/null\n+++ b/include/libcamera/version.h\n@@ -0,0 +1,23 @@\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+namespace libcamera {\n+\n+class LibcameraVersion\n+{\n+public:\n+\tLibcameraVersion();\n+\tstd::string toString();\n+};\n+\n+extern LibcameraVersion version;\n+\n+} /* namespace libcamera */\n+\n+#endif /* __LIBCAMERA_VERSION_H__ */\ndiff --git a/meson.build b/meson.build\nindex 4d3e99d3e58f..5182546382c5 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@@ -13,6 +15,11 @@ project('libcamera', 'c', 'cpp',\n #       generated from this too.\n api_version = '0.1'\n \n+vcs_tag(command: ['utils/version-gen', '.'],\n+        input: 'version.h.in',\n+\toutput: 'version.h',\n+\tfallback: '')\n+\n cc = meson.get_compiler('c')\n config_h = configuration_data()\n \ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 1ca1083cf5c7..b9a4153839c9 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -25,6 +25,7 @@ libcamera_sources = files([\n     'utils.cpp',\n     'v4l2_device.cpp',\n     'v4l2_subdevice.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..81f692f7cae7\n--- /dev/null\n+++ b/src/libcamera/version.cpp\n@@ -0,0 +1,40 @@\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+LibcameraVersion::LibcameraVersion()\n+{\n+\tLOG(Version, Info) << \"Libcamera Version \" << toString();\n+}\n+\n+/**\n+ * \\brief Return the library version as a string\n+ */\n+std::string LibcameraVersion::toString()\n+{\n+\treturn LIBCAMERA_VERSION;\n+}\n+\n+static LibcameraVersion version;\n+\n+} /* namespace libcamera */\ndiff --git a/utils/version-gen b/utils/version-gen\nnew file mode 100755\nindex 000000000000..b8e53d77b63e\n--- /dev/null\n+++ b/utils/version-gen\n@@ -0,0 +1,36 @@\n+#!/bin/sh\n+\n+if test -n \"$1\"\n+then\n+\tcd \"$1\"\n+fi\n+\n+# No fall back is provided for tarball releases or such, as we do not yet provide releases.\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 test -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+\n+git update-index --refresh > /dev/null 2>&1\n+dirty=`sh -c '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 test -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..142819645b64\n--- /dev/null\n+++ b/version.h.in\n@@ -0,0 +1,3 @@\n+#pragma once\n+\n+#define LIBCAMERA_VERSION \"@VCS_TAG@\"\n",
    "prefixes": [
        "libcamera-devel"
    ]
}