{"id":18442,"url":"https://patchwork.libcamera.org/api/1.1/patches/18442/?format=json","web_url":"https://patchwork.libcamera.org/patch/18442/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230322180347.1766-1-laurent.pinchart@ideasonboard.com>","date":"2023-03-22T18:03:47","name":"[libcamera-devel] meson: Really fix git version parsing","commit_ref":"4cd9cb4a90550e0c45c85b0b00ca8a72ed13fdb4","pull_url":null,"state":"accepted","archived":false,"hash":"e61541803f7d403e28ca32ccd812f265c9ed0190","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18442/mbox/","series":[{"id":3812,"url":"https://patchwork.libcamera.org/api/1.1/series/3812/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3812","date":"2023-03-22T18:03:47","name":"[libcamera-devel] meson: Really fix git version parsing","version":1,"mbox":"https://patchwork.libcamera.org/series/3812/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18442/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18442/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 92D54C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Mar 2023 18:03:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B780C626E5;\n\tWed, 22 Mar 2023 19:03:43 +0100 (CET)","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 1393461ECE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 19:03:42 +0100 (CET)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6D477183F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Mar 2023 19:03:41 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1679508223;\n\tbh=UFKonO9KHnRf9rsDLgRyQkgSEGP0t9AVYawUMxa65rA=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=T5uJj1dLSwnUu0fsDxW+NY2oeJUOcw5lCPibAnUAoqPxu7JZ7mFtjMjdJfqhF22GV\n\tT0HAqUBRM/n0D877AVDWs4DJNVcVvP5IuNHqN7XZXDqCPoGmVZ7o6R6QPPEyDwb3iz\n\tqqcxqN/aulqkk2FsyJwK/RF/HHhSoYTgkyjCaSF2F4EyVmGw/U+eW8RzqLSBKqojeg\n\tmAF9bVs0gjmR3+3M/XBjqjxesKr/6psVr8ZH4RiA5yUpPNAKuSAuTCD1FioPC6PI7k\n\t940n72mcua9Fa12gFAp6IMoIC/0biGQp7rUwK9PkZwcLS6BGk0qyBK+ZI3tQGPclHp\n\tjnHIS7CifldSA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1679508221;\n\tbh=UFKonO9KHnRf9rsDLgRyQkgSEGP0t9AVYawUMxa65rA=;\n\th=From:To:Subject:Date:From;\n\tb=EEy+Or17sdMiqkfRjf8twdx7VjrXqdWawRk8pWdvgfaJK/udeSiRvqUAWOlhzPYY2\n\td0Ofg6uoW8BWmVE62hJCAGLnaN7iyXZwdCeEETz7FKUhtp5r7+vJu6pLzeC/pQuPQg\n\tyf+0zEFXkwVu8sXNUI4CRmDqsRyjcfwCfKRqvKdA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"EEy+Or17\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 22 Mar 2023 20:03:47 +0200","Message-Id":"<20230322180347.1766-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.39.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH] meson: Really fix git version parsing","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The previous attempt to fix git version parsing in commit d34cefad1791\n(\"meson: Fix git version parsing\") was too naive, and didn't take into\naccount cases where the libcamera git version contains no or multiple\n'+' signs.\n\nFixing this is more complex than a one-liner change, as meson doesn't\nsupport Python-style slicing of arrays or a length method on strings.\nThe simplest and most versatile option is to patch the version string in\nthe gen-version.sh script. Do so, and clarify the comments related to\nversion handling in meson.build.\n\nFixes: d34cefad1791 (\"meson: Fix git version parsing\")\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n meson.build          | 29 ++++++++++++++++++-----------\n utils/gen-version.sh |  8 ++++++++\n 2 files changed, 26 insertions(+), 11 deletions(-)\n\n\nbase-commit: e39f046f660a6d0954d81b92bd183e7ba679fa56","diff":"diff --git a/meson.build b/meson.build\nindex 189e97736d90..8628e6acebee 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -11,15 +11,19 @@ project('libcamera', 'c', 'cpp',\n     license : 'LGPL 2.1+')\n \n # Generate version information. The libcamera_git_version variable contains the\n-# full version with git patch count and SHA1 (e.g. 1.2.3+211-c94a24f4), while\n-# the libcamera_version variable contains the major.minor.patch (e.g. 1.2.3)\n-# only. If the source tree isn't under git control, or if it matches the last\n-# git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n-# libcamera_git_version.\n+# full version with build metadata (patch count and SHA1, e.g.\n+# 1.2.3+211-c94a24f4), while the libcamera_version variable contains the\n+# major.minor.patch (e.g. 1.2.3) only.\n+#\n+# If the source tree matches the last git version tag, the build metadata\n+# (e.g. +211-c94a24f4) is omitted from libcamera_git_version.\n libcamera_git_version = run_command('utils/gen-version.sh',\n                                     meson.project_build_root(),\n                                     meson.project_source_root(),\n                                     check: false).stdout().strip()\n+\n+# If the source tree isn't under git control, set libcamera_git_version to the\n+# meson project version.\n if libcamera_git_version == ''\n     libcamera_git_version = meson.project_version()\n endif\n@@ -31,7 +35,7 @@ project_version = meson.project_version().split('+')[0]\n # meson.project_version() could leave the project in a mis-described state.\n # Produce a warning in this event, and fix to a best effort.\n if libcamera_version != project_version\n-    warning('The sources disagree about the version: '\n+    warning('The sources and meson.build disagree about the version: '\n             + libcamera_version + ' != ' + project_version)\n \n     summary({'libcamera git version' : libcamera_git_version,\n@@ -39,13 +43,16 @@ if libcamera_version != project_version\n             },\n             bool_yn : true, section : 'Versions')\n \n-    # Replace the version components reported by git with the release version,\n-    # but keep all trailing information supplied by git.\n-    libcamera_git_version = (project_version + '+' +\n-                             libcamera_git_version.split('+')[1])\n+    # Re-run gen-version.sh to replace the git version (major.minor.patch) with\n+    # the meson project version. The build metadata provided by git are kept.\n+    libcamera_git_version = run_command('utils/gen-version.sh',\n+                                        meson.project_build_root(),\n+                                        meson.project_source_root(),\n+                                        project_version,\n+                                        check: false).stdout().strip()\n     libcamera_version = project_version\n \n-    # Append a marker to show we have modified this version string\n+    # Append a marker to show we have modified this version string.\n     libcamera_git_version += '-nvm'\n endif\n \ndiff --git a/utils/gen-version.sh b/utils/gen-version.sh\nindex eb7c72685c54..e1f7ca7b6f01 100755\n--- a/utils/gen-version.sh\n+++ b/utils/gen-version.sh\n@@ -5,6 +5,7 @@\n \n build_dir=\"$1\"\n src_dir=\"$2\"\n+project_version=\"$3\"\n \n # If .tarball-version exists, output the version string from the file and exit.\n # This file is auto-generated on a 'meson dist' command from the run-dist.sh\n@@ -43,6 +44,13 @@ then\n fi\n git diff-index --quiet HEAD || version=\"$version-dirty ($(date --iso-8601=seconds))\"\n \n+# If a project version is provided, use it to replace the version number.\n+if [ -n \"$project_version\" ]\n+then\n+\tversion=$(echo \"$version\" | sed -e 's/^[^-]*-//')\n+\tversion=\"v$project_version-$version\"\n+fi\n+\n # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from\n # of the git SHA1 and remove the initial 'v'.\n version=$(echo \"$version\" | sed -e 's/-/+/' | sed -e 's/-g/-/' | cut -c 2-)\n","prefixes":["libcamera-devel"]}