{"id":14523,"url":"https://patchwork.libcamera.org/api/1.1/patches/14523/?format=json","web_url":"https://patchwork.libcamera.org/patch/14523/","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":"<20211014101635.2890492-1-naush@raspberrypi.com>","date":"2021-10-14T10:16:35","name":"[libcamera-devel,v3] build: Preserve upstream git versioning using meson dist","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"385b5caa2e091972ca228e1707e0c4267e30ebed","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14523/mbox/","series":[{"id":2704,"url":"https://patchwork.libcamera.org/api/1.1/series/2704/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2704","date":"2021-10-14T10:16:35","name":"[libcamera-devel,v3] build: Preserve upstream git versioning using meson dist","version":3,"mbox":"https://patchwork.libcamera.org/series/2704/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14523/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14523/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":["parsemail@patchwork.libcamera.org","kbingham@ideasonboard.com"],"Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9E83DBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 14:00:31 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E8E1E501\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 15:00:30 +0100 (CET)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id J0L5JY8DaGH7PwAA4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 14 Oct 2021 12:16:47 +0200","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[IPv6:2001:4b98:dc0:43:216:3eff:fe33:f827])\tby\n\tperceval.ideasonboard.com (Postfix) with ESMTPS id 439352F3;\n\tThu, 14 Oct 2021 12:16:47 +0200 (CEST)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9AAAE68F50;\n\tThu, 14 Oct 2021 12:16:46 +0200 (CEST)","from mail-wr1-x433.google.com (mail-wr1-x433.google.com\n\t[IPv6:2a00:1450:4864:20::433])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8919468541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 12:16:45 +0200 (CEST)","by mail-wr1-x433.google.com with SMTP id o20so17849787wro.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 03:16:45 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:26af:fb8f:5d03:5eab])\n\tby smtp.gmail.com with ESMTPSA id\n\tv10sm2142644wri.29.2021.10.14.03.16.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 14 Oct 2021 03:16:44 -0700 (PDT)"],"Authentication-Results":["perceval.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"jJM4G+af\"; dkim-atps=neutral","lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature\n\tverification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com header.b=\"jJM4G+af\";\tdkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=wNYY6T7ghEWwviRg67OwOYqtIqRIwS6gzSciPVafIXs=;\n\tb=jJM4G+afc79KDbQD5rDgwRX8POe81hY2IF+9LLH+Pv/VjUnmCcZkIfd595O2x+M7bL\n\tnlMouKQ0SgB9rz/DU/LcX2Ne3v5DK/nDsG6B3HYDrellDk0ilEL6/Uu/XMMvBA2u2KCQ\n\tsSjwqIhKdAcUZMOpPdBwK3vVklj8RFFwWxcUSpXOMBYVBYCYrT3JcZOE/FQ5VbSOrFL7\n\tQd8rzptDUMfyNCB++vXVawTib9OeKQTKdygj+0KFcKg0AELWJvNcv5ojy5a0nX39xT02\n\tSADhNXOzLoEVCiXeXPVGxXPkWzcZdbAO+Dn/tPanffTTRPOeyoLg7QTGA5j0IXN1hA63\n\tvPHg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=wNYY6T7ghEWwviRg67OwOYqtIqRIwS6gzSciPVafIXs=;\n\tb=e83liOD/jA4nYwKQTwT++/nF6RLIIQsC6v/kacm0nGIMP7+6Jsdk3SveBLJV3xt3YY\n\t/zxTmn8msvuZxTggBujs0t6+9skPqMyuHO7OWr0Q43i+718nAMhEEmsRdwVgr4457/mV\n\tduk4sLtQsipn7uvCvS9lUOeecqYIzcUi9TWgnaOlouDrMis90FhztxtXoAjQiaVyrnGx\n\tvxj5PGkdqEK7/veEKMLFH21rUkZxJMN5l0QScYq7U/vqrvc+PC/EwTSfqotzwhblWGYj\n\tyc/HQSrvP8u4gOkvS+P8GhZHv6uZdEXbQvtGqqhUa3+fVH0FQHJjreLhvKRnqYMLAwGe\n\tdAGw==","X-Gm-Message-State":"AOAM5310nIyLeAt6x4ZJZvNCfU51F7Gw77Jg4Qe2R2F6vPe3btIof+Ho\n\tJAmxwJMLlK7Esn9v4RqxLJikV/KmoN/szOlE","X-Google-Smtp-Source":"=?utf-8?q?ABdhPJxzwxawmkBq3csyIShmfCsJ4xBKxlho79Tyk?=\n\t=?utf-8?q?6bO1+lnmfJQ9UaZxzvAOTyLPbcdmXMA5HHoow=3D=3D?=","X-Received":"by 2002:adf:b302:: with SMTP id j2mr5630628wrd.285.1634206604649;\n\tThu, 14 Oct 2021 03:16:44 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 14 Oct 2021 11:16:35 +0100","Message-Id":"<20211014101635.2890492-1-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3] build: Preserve upstream git\n\tversioning using meson dist","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>","X-TUID":"oWACB0GLJCZc","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"},"content":"When distributions build and package libcamera libraries, they may not\nnecessarily run the build in the upstream source tree. In these cases, the git\nSHA1 versioning information will be lost.\n\nThis change addresses that problem by requiring package managers to run\n'meson dist' to create a tarball of the source files and build from there.\nOn runing 'meson dist', the utils/run-dist.sh script will create a\n.tarball-version file in the release tarball with the version string generated\nfrom the existing utils/gen-version.sh script.\n\nThe utils/gen-version.sh script has been updated to check for the presence of\nthis .tarball-version file and read the version string from it instead of\ncreating one.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n meson.build               |  3 +++\n src/libcamera/meson.build | 11 +++++------\n utils/gen-version.sh      |  9 +++++++++\n utils/run-dist.sh         | 11 +++++++++++\n 4 files changed, 28 insertions(+), 6 deletions(-)\n create mode 100644 utils/run-dist.sh","diff":"diff --git a/meson.build b/meson.build\nindex a49c484fe64e..67be6762108c 100644\n--- a/meson.build\n+++ b/meson.build\n@@ -24,6 +24,9 @@ endif\n \n libcamera_version = libcamera_git_version.split('+')[0]\n \n+# This script gererates the .tarball-version file on a 'meson dist' command.\n+meson.add_dist_script('utils/run-dist.sh')\n+\n # Configure the build environment.\n cc = meson.get_compiler('c')\n cxx = meson.get_compiler('cpp')\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex 243dd3c180eb..360eaf80ecf1 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -93,12 +93,11 @@ endforeach\n \n libcamera_sources += control_sources\n \n-gen_version = meson.source_root() / 'utils' / 'gen-version.sh'\n-\n-version_cpp = vcs_tag(command : [gen_version, meson.build_root()],\n-                      input : 'version.cpp.in',\n-                      output : 'version.cpp',\n-                      fallback : meson.project_version())\n+version_data = configuration_data()\n+version_data.set('VCS_TAG', libcamera_git_version)\n+version_cpp = configure_file(input : 'version.cpp.in',\n+                             output : 'version.cpp',\n+                             configuration : version_data)\n \n libcamera_sources += version_cpp\n \ndiff --git a/utils/gen-version.sh b/utils/gen-version.sh\nindex b09ad495f86a..216b1ff0b33e 100755\n--- a/utils/gen-version.sh\n+++ b/utils/gen-version.sh\n@@ -5,6 +5,15 @@\n \n build_dir=\"$1\"\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+# script.\n+if [ -f \"${MESON_SOURCE_ROOT}\"/.tarball-version ]\n+then\n+\tcat \"${MESON_SOURCE_ROOT}\"/.tarball-version\n+\texit 0\n+fi\n+\n # Bail out if the directory isn't under git control\n src_dir=$(git rev-parse --git-dir 2>&1) || exit 1\n src_dir=$(readlink -f \"$src_dir/..\")\ndiff --git a/utils/run-dist.sh b/utils/run-dist.sh\nnew file mode 100644\nindex 000000000000..e89c3733b56c\n--- /dev/null\n+++ b/utils/run-dist.sh\n@@ -0,0 +1,11 @@\n+#!/bin/sh\n+\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+#\n+# On a meson dist run, generate the version string and store it in a file.\n+# This will later be picked up by the utils/gen-version.sh script and used\n+# instead of re-generating it. This way, if we are not building in the upstream\n+# git source tree, the upstream version information will be preserved.\n+\n+cd \"$MESON_SOURCE_ROOT\" || return\n+./utils/gen-version.sh > \"$MESON_DIST_ROOT\"/.tarball-version\n","prefixes":["libcamera-devel","v3"]}