[{"id":20209,"web_url":"https://patchwork.libcamera.org/comment/20209/","msgid":"<YWiU8VGOw1es92KO@pendragon.ideasonboard.com>","date":"2021-10-14T20:37:05","subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Thu, Oct 14, 2021 at 12:59:50PM +0100, Naushir Patuck wrote:\n> The gen-version.sh script expects to be called from a git repo, and sets its\n> src_root variable accordingly. This may not always be the case if it is built\n> from a tarball source - full support for which is in a future commit.\n> \n> The MESON_SOURCE_ROOT environnement variable does not get set when called from\n> the meson vcs_tag() function, but does when called from the run_command()\n> function, so that cannot be used either.\n> \n> Instead, explicitly pass the meson source root to the gen-version.sh script.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  meson.build               | 3 ++-\n>  src/libcamera/meson.build | 2 +-\n>  utils/gen-version.sh      | 4 ++--\n>  3 files changed, 5 insertions(+), 4 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index a49c484fe64e..556a3f7c42f8 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -17,7 +17,8 @@ project('libcamera', 'c', 'cpp',\n>  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n>  # libcamera_git_version.\n>  libcamera_git_version = run_command('utils/gen-version.sh',\n> -                                    meson.build_root()).stdout().strip()\n> +                                    meson.build_root(),\n> +                                    meson.source_root()).stdout().strip()\n>  if libcamera_git_version == ''\n>      libcamera_git_version = meson.project_version()\n>  endif\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 243dd3c180eb..d8dd8344002c 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -95,7 +95,7 @@ libcamera_sources += control_sources\n>  \n>  gen_version = meson.source_root() / 'utils' / 'gen-version.sh'\n>  \n\nWhile at it, could you please add\n\n# Use vcs_tag() and not configure_file() or run_command(), to ensure that the\n# version gets updated with every ninja build and not just at meson setup time.\n\nso we'll remember next time ?\n\n> -version_cpp = vcs_tag(command : [gen_version, meson.build_root()],\n> +version_cpp = vcs_tag(command : [gen_version, meson.build_root(), meson.source_root()],\n>                        input : 'version.cpp.in',\n>                        output : 'version.cpp',\n>                        fallback : meson.project_version())\n> diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> index b09ad495f86a..da191691a7c5 100755\n> --- a/utils/gen-version.sh\n> +++ b/utils/gen-version.sh\n> @@ -4,10 +4,10 @@\n>  # Generate a version string using git describe\n>  \n>  build_dir=\"$1\"\n> +src_dir=\"$2\"\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/..\")\n> +git rev-parse --git-dir > /dev/null 2>&1 || exit 1\n\nIt would be nice if we could make the source directory optional, the\nsame way the build directory is, so that running gen-version.sh from the\ncommand line for testing would be easier. How about the following ?\n\n# Bail out if the directory isn't under git control\ngit_dir=$(git rev-parse --git-dir 2>&1) || exit 1\n\n# Derive the source directory from the git directory if not specified.\nif [ -z \"$src_dir\" ]\nthen\n\tsrc_dir=$(readlink -f \"$git_dir/..\")\nfi\n\n\nWith this (and assuming it works :-)),\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  # Get a short description from the tree.\n>  version=$(git describe --abbrev=8 --match \"v[0-9]*\" 2>/dev/null)","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 0B42AC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 20:37:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7011568F4F;\n\tThu, 14 Oct 2021 22:37:23 +0200 (CEST)","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 90DE168541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 22:37:21 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F18DA2F3;\n\tThu, 14 Oct 2021 22:37:20 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"dYvuZvHE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634243841;\n\tbh=CUJS5iftFIlQ+V5F9U+7Fxw/f2Y7QRI8J55NBTRaWAU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dYvuZvHEktertYb1ofHfo4wtG2lADD7kmEORL4fzcsMTTuVNMZfgJ+l5TuotIAyJ4\n\tbBDB5SQgbS0DraKpcbnavThuNPgM746Aq7Zh4CABblrAQHNnvhk2dlHmLVn3Zl2eNw\n\tztZg6PKMdPtb+Hz5u5Ouc3wq8aTaaJuLl4nIPbBk=","Date":"Thu, 14 Oct 2021 23:37:05 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YWiU8VGOw1es92KO@pendragon.ideasonboard.com>","References":"<20211014115951.2996808-1-naush@raspberrypi.com>\n\t<20211014115951.2996808-2-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211014115951.2996808-2-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20210,"web_url":"https://patchwork.libcamera.org/comment/20210/","msgid":"<YWiV0MFq61UBaBAk@pendragon.ideasonboard.com>","date":"2021-10-14T20:40:48","subject":"Re: [libcamera-devel] [PATCH v4 2/2] build: Preserve upstream git\n\tversioning using meson dist","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Thu, Oct 14, 2021 at 12:59:51PM +0100, Naushir Patuck wrote:\n> When distributions build and package libcamera libraries, they may not\n> necessarily run the build in the upstream source tree. In these cases, the git\n> SHA1 versioning information will be lost.\n> \n> This 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.\n> On 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\n> from the existing utils/gen-version.sh script.\n> \n> The utils/gen-version.sh script has been updated to check for the presence of\n> this .tarball-version file and read the version string from it instead of\n> creating one.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  meson.build          |  3 +++\n>  utils/gen-version.sh |  9 +++++++++\n>  utils/run-dist.sh    | 11 +++++++++++\n>  3 files changed, 23 insertions(+)\n>  create mode 100644 utils/run-dist.sh\n> \n> diff --git a/meson.build b/meson.build\n> index 556a3f7c42f8..bd19bd836579 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -25,6 +25,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')\n> diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> index da191691a7c5..8759e722ffe1 100755\n> --- a/utils/gen-version.sh\n> +++ b/utils/gen-version.sh\n> @@ -6,6 +6,15 @@\n>  build_dir=\"$1\"\n>  src_dir=\"$2\"\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 \"$src_dir\"/.tarball-version ]\n\nIf you agree with the comments on the previous patch, this should likely\nbecome\n\nif [ -n \"$src_dir\" ] && [ -f \"$src_dir\"/.tarball-version ] \n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +then\n> +\tcat \"$src_dir\"/.tarball-version\n> +\texit 0\n> +fi\n> +\n>  # Bail out if the directory isn't under git control\n>  git rev-parse --git-dir > /dev/null 2>&1 || exit 1\n>  \n> diff --git a/utils/run-dist.sh b/utils/run-dist.sh\n> new file mode 100644\n> index 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","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 B4ED2C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Oct 2021 20:41:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 300F468F4F;\n\tThu, 14 Oct 2021 22:41:06 +0200 (CEST)","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 8525668541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Oct 2021 22:41:04 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EF4932F3;\n\tThu, 14 Oct 2021 22:41:03 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"P90gZe24\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634244064;\n\tbh=tN22x/xePOPBm6/00NVfywhxW3rcHoCz/VIaMY3AW+c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=P90gZe242Sc0MLq7U0c2FzSvsWsZJ0jf2mg+taiMyfS+rL6CAP1WjBCYha61vwv/+\n\tmKt6kZsRZntyjnTw1eBWMi6Tjy0eg1ndx1xz/P9cSPR/6sF+08B0vkfXo5YgfbCj7o\n\tt73DUU6ec7hD05H3zuRD3Hp7huu/sdTONukXN1tQ=","Date":"Thu, 14 Oct 2021 23:40:48 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YWiV0MFq61UBaBAk@pendragon.ideasonboard.com>","References":"<20211014115951.2996808-1-naush@raspberrypi.com>\n\t<20211014115951.2996808-3-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211014115951.2996808-3-naush@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/2] 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20238,"web_url":"https://patchwork.libcamera.org/comment/20238/","msgid":"<CAEmqJPoPpxzkdXoMixkz3L9dh9Ls2dBmQyeJ04-tQg5sr=sWZw@mail.gmail.com>","date":"2021-10-15T07:39:58","subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\n\nOn Thu, 14 Oct 2021 at 21:37, Laurent Pinchart <\nlaurent.pinchart@ideasonboard.com> wrote:\n\n> Hi Naush,\n>\n> Thank you for the patch.\n>\n> On Thu, Oct 14, 2021 at 12:59:50PM +0100, Naushir Patuck wrote:\n> > The gen-version.sh script expects to be called from a git repo, and sets\n> its\n> > src_root variable accordingly. This may not always be the case if it is\n> built\n> > from a tarball source - full support for which is in a future commit.\n> >\n> > The MESON_SOURCE_ROOT environnement variable does not get set when\n> called from\n> > the meson vcs_tag() function, but does when called from the run_command()\n> > function, so that cannot be used either.\n> >\n> > Instead, explicitly pass the meson source root to the gen-version.sh\n> script.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  meson.build               | 3 ++-\n> >  src/libcamera/meson.build | 2 +-\n> >  utils/gen-version.sh      | 4 ++--\n> >  3 files changed, 5 insertions(+), 4 deletions(-)\n> >\n> > diff --git a/meson.build b/meson.build\n> > index a49c484fe64e..556a3f7c42f8 100644\n> > --- a/meson.build\n> > +++ b/meson.build\n> > @@ -17,7 +17,8 @@ project('libcamera', 'c', 'cpp',\n> >  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted\n> from\n> >  # libcamera_git_version.\n> >  libcamera_git_version = run_command('utils/gen-version.sh',\n> > -                                    meson.build_root()).stdout().strip()\n> > +                                    meson.build_root(),\n> > +\n> meson.source_root()).stdout().strip()\n> >  if libcamera_git_version == ''\n> >      libcamera_git_version = meson.project_version()\n> >  endif\n> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > index 243dd3c180eb..d8dd8344002c 100644\n> > --- a/src/libcamera/meson.build\n> > +++ b/src/libcamera/meson.build\n> > @@ -95,7 +95,7 @@ libcamera_sources += control_sources\n> >\n> >  gen_version = meson.source_root() / 'utils' / 'gen-version.sh'\n> >\n>\n> While at it, could you please add\n>\n> # Use vcs_tag() and not configure_file() or run_command(), to ensure that\n> the\n> # version gets updated with every ninja build and not just at meson setup\n> time.\n>\n> so we'll remember next time ?\n>\n\nWill do!\n\n\n>\n> > -version_cpp = vcs_tag(command : [gen_version, meson.build_root()],\n> > +version_cpp = vcs_tag(command : [gen_version, meson.build_root(),\n> meson.source_root()],\n> >                        input : 'version.cpp.in',\n> >                        output : 'version.cpp',\n> >                        fallback : meson.project_version())\n> > diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> > index b09ad495f86a..da191691a7c5 100755\n> > --- a/utils/gen-version.sh\n> > +++ b/utils/gen-version.sh\n> > @@ -4,10 +4,10 @@\n> >  # Generate a version string using git describe\n> >\n> >  build_dir=\"$1\"\n> > +src_dir=\"$2\"\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/..\")\n> > +git rev-parse --git-dir > /dev/null 2>&1 || exit 1\n>\n> It would be nice if we could make the source directory optional, the\n> same way the build directory is, so that running gen-version.sh from the\n> command line for testing would be easier. How about the following ?\n>\n> # Bail out if the directory isn't under git control\n> git_dir=$(git rev-parse --git-dir 2>&1) || exit 1\n>\n> # Derive the source directory from the git directory if not specified.\n> if [ -z \"$src_dir\" ]\n> then\n>         src_dir=$(readlink -f \"$git_dir/..\")\n> fi\n>\n>\n> With this (and assuming it works :-)),\n>\n\nKieran had a suggestion in his feedback on a previous version of the patch.\n$build_dir/source symlinks to our source tree.  This is created from the top\nlevel meson.build file:\n\n# Create a symlink from the build root to the source root. This is used when\n# running libcamera from the build directory to locate resources in the\nsource\n# directory (such as IPA configuration files).\nrun_command('ln', '-fsT', meson.source_root(), meson.build_root() /\n'source')\n\nAssuming this does not disappear in the future, I can use that to reference\nthe\nsource dir in the gen-version script. This will effectively make this patch\n(1/2)\nredundant, and I only need to change gen-version.sh appropriately.  What\ndo you think?\n\nNaush\n\n\n\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\n> >  # Get a short description from the tree.\n> >  version=$(git describe --abbrev=8 --match \"v[0-9]*\" 2>/dev/null)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 2235DC324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 07:40:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 81A2268F52;\n\tFri, 15 Oct 2021 09:40:17 +0200 (CEST)","from mail-lf1-x134.google.com (mail-lf1-x134.google.com\n\t[IPv6:2a00:1450:4864:20::134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C7CDE6023B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 09:40:15 +0200 (CEST)","by mail-lf1-x134.google.com with SMTP id x192so2982251lff.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Oct 2021 00:40:15 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"OWFKv33y\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=K7yNbl1yXJXZp3uhUhMP1E7EAC6/ti+biPWjuZDmrZA=;\n\tb=OWFKv33yeFLDuXOQuK7oPh8yf9XK4bx0NiPm7rWMvOPh42WduR6ApKj7QZPcVyK7Zg\n\t5iNpZOZFkVAeab9ObERCMOZXZhrNA32un2jWm9ghGlEVkVKXJvilhlRWkBnnk2vkwvrt\n\tMfAifsokpQwM2FLMDaAevrplBnipajDCYCJytaUfMT7Gu3YOLCSo31h3QxXPkAtyCHC2\n\tB5HxQeeIJjRSegczXCKdA6ub73G4+2r7zXz6kpRJ5zNbkRwkIzY+Gx1rJd3IVtfVSn0q\n\taHNJlXAbEsy0IGXMNCaDI3p+iXjFfAabDBKfYUqLSvHwaxG7bIBftK61Iva1Qc3ETKof\n\tiXzQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=K7yNbl1yXJXZp3uhUhMP1E7EAC6/ti+biPWjuZDmrZA=;\n\tb=Ic8DknKnbjEvbjrfTv3SiBDHQ6Zbw1jXaXoOhbga5zDtW/2McGL6EmJKupBYDTgwqY\n\tutRtE6HDdr2TaX99Yy6Gd4N3isUic9CN/mb/39r67BYREB/cNsoDezk2SOuQLGmDkHNR\n\tRnmz3Vqyk8G2H54HdwGLz2JIqEWLu/F4sK/yKlUu9Zxv7eQ5+Xx+QtuX12+tPRM05vWv\n\tESVbUAGs6eeFIcnOcDZ/EDzRS399NVbJqzGsUFZvmCj4nQ/3gvU/JtCMjXQz8w3cOfLW\n\tkfk6bzGuhOVvbs54SGGF1R+agV42z6n3qjtxQiQfPYWHSaIPRAcV8GF6qA/ORfKgqmLN\n\tQV4A==","X-Gm-Message-State":"AOAM533u3fIpKfOXQv54DLs+TtUVRiUEX1RWRmTnuOA+9mPm5rUsHsJ1\n\tRw4TgowNFfEai7JWl/dkWE5Mm0ti1odPKpFfELAJ2r9umbwx2sr7","X-Google-Smtp-Source":"ABdhPJwq7hs4pZ6G4FjfUVmJ6S7/CWK6duWm+4wmIvoVi1wRVfjWPbwxZnLcKoLLTDjGrM2E5nJ+0FgQ0wWOV3dwm8U=","X-Received":"by 2002:a19:f00d:: with SMTP id\n\tp13mr9622926lfc.122.1634283614624; \n\tFri, 15 Oct 2021 00:40:14 -0700 (PDT)","MIME-Version":"1.0","References":"<20211014115951.2996808-1-naush@raspberrypi.com>\n\t<20211014115951.2996808-2-naush@raspberrypi.com>\n\t<YWiU8VGOw1es92KO@pendragon.ideasonboard.com>","In-Reply-To":"<YWiU8VGOw1es92KO@pendragon.ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Fri, 15 Oct 2021 08:39:58 +0100","Message-ID":"<CAEmqJPoPpxzkdXoMixkz3L9dh9Ls2dBmQyeJ04-tQg5sr=sWZw@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"multipart/alternative; boundary=\"0000000000004fef4505ce5f4eb8\"","Subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":20253,"web_url":"https://patchwork.libcamera.org/comment/20253/","msgid":"<YWoL1tKgtX6N/Ujp@pendragon.ideasonboard.com>","date":"2021-10-15T23:16:38","subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nOn Fri, Oct 15, 2021 at 08:39:58AM +0100, Naushir Patuck wrote:\n> On Thu, 14 Oct 2021 at 21:37, Laurent Pinchart wrote:\n> > On Thu, Oct 14, 2021 at 12:59:50PM +0100, Naushir Patuck wrote:\n> > > The gen-version.sh script expects to be called from a git repo, and sets its\n> > > src_root variable accordingly. This may not always be the case if it is built\n> > > from a tarball source - full support for which is in a future commit.\n> > >\n> > > The MESON_SOURCE_ROOT environnement variable does not get set when called from\n> > > the meson vcs_tag() function, but does when called from the run_command()\n> > > function, so that cannot be used either.\n> > >\n> > > Instead, explicitly pass the meson source root to the gen-version.sh script.\n> > >\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > ---\n> > >  meson.build               | 3 ++-\n> > >  src/libcamera/meson.build | 2 +-\n> > >  utils/gen-version.sh      | 4 ++--\n> > >  3 files changed, 5 insertions(+), 4 deletions(-)\n> > >\n> > > diff --git a/meson.build b/meson.build\n> > > index a49c484fe64e..556a3f7c42f8 100644\n> > > --- a/meson.build\n> > > +++ b/meson.build\n> > > @@ -17,7 +17,8 @@ project('libcamera', 'c', 'cpp',\n> > >  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n> > >  # libcamera_git_version.\n> > >  libcamera_git_version = run_command('utils/gen-version.sh',\n> > > -                                    meson.build_root()).stdout().strip()\n> > > +                                    meson.build_root(),\n> > > + meson.source_root()).stdout().strip()\n> > >  if libcamera_git_version == ''\n> > >      libcamera_git_version = meson.project_version()\n> > >  endif\n> > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > > index 243dd3c180eb..d8dd8344002c 100644\n> > > --- a/src/libcamera/meson.build\n> > > +++ b/src/libcamera/meson.build\n> > > @@ -95,7 +95,7 @@ libcamera_sources += control_sources\n> > >\n> > >  gen_version = meson.source_root() / 'utils' / 'gen-version.sh'\n> >\n> > While at it, could you please add\n> >\n> > # Use vcs_tag() and not configure_file() or run_command(), to ensure that the\n> > # version gets updated with every ninja build and not just at meson setup time.\n> >\n> > so we'll remember next time ?\n> \n> Will do!\n> \n> > > -version_cpp = vcs_tag(command : [gen_version, meson.build_root()],\n> > > +version_cpp = vcs_tag(command : [gen_version, meson.build_root(), meson.source_root()],\n> > >                        input : 'version.cpp.in',\n> > >                        output : 'version.cpp',\n> > >                        fallback : meson.project_version())\n> > > diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> > > index b09ad495f86a..da191691a7c5 100755\n> > > --- a/utils/gen-version.sh\n> > > +++ b/utils/gen-version.sh\n> > > @@ -4,10 +4,10 @@\n> > >  # Generate a version string using git describe\n> > >\n> > >  build_dir=\"$1\"\n> > > +src_dir=\"$2\"\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/..\")\n> > > +git rev-parse --git-dir > /dev/null 2>&1 || exit 1\n> >\n> > It would be nice if we could make the source directory optional, the\n> > same way the build directory is, so that running gen-version.sh from the\n> > command line for testing would be easier. How about the following ?\n> >\n> > # Bail out if the directory isn't under git control\n> > git_dir=$(git rev-parse --git-dir 2>&1) || exit 1\n> >\n> > # Derive the source directory from the git directory if not specified.\n> > if [ -z \"$src_dir\" ]\n> > then\n> >         src_dir=$(readlink -f \"$git_dir/..\")\n> > fi\n> >\n> >\n> > With this (and assuming it works :-)),\n> \n> Kieran had a suggestion in his feedback on a previous version of the patch.\n> $build_dir/source symlinks to our source tree.  This is created from the top\n> level meson.build file:\n> \n> # Create a symlink from the build root to the source root. This is used when\n> # running libcamera from the build directory to locate resources in the source\n> # directory (such as IPA configuration files).\n> run_command('ln', '-fsT', meson.source_root(), meson.build_root() / 'source')\n> \n> Assuming this does not disappear in the future, I can use that to reference the\n> source dir in the gen-version script. This will effectively make this patch (1/2)\n> redundant, and I only need to change gen-version.sh appropriately.  What\n> do you think?\n\nThat would only work when running the script from the build directory.\nFor testing purpose, it's nice to be able to run it manually in the\nsource directory, and get the same output as when run by meson. I'd thus\nprefer deriving src_dir from git_dir when not specified.\n\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > >  # Get a short description from the tree.\n> > >  version=$(git describe --abbrev=8 --match \"v[0-9]*\" 2>/dev/null)","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 C3409C324C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Oct 2021 23:16:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5303368F4A;\n\tSat, 16 Oct 2021 01:16:57 +0200 (CEST)","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 F2DCA68541\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 16 Oct 2021 01:16:54 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 621A929B;\n\tSat, 16 Oct 2021 01:16:54 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Jgn0cqKa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1634339814;\n\tbh=wJSUl1duVutDEKhBrewCRwKOp0qB1mClMEecd9XRPbA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Jgn0cqKarJQMcoMnEaQp2w2tIf3yG3Nix7zgbyFL4FXa+fa5ARBAvwOynioyUqmNP\n\t36RXYhCsqM9n8WUx8S9GU8sNquDfs97LcAnFNFxJco+n7mPQMNyM669L+98ZDilW3i\n\td2XDsJnyO7v/xdi2n6/YmWchVsbUXzQ3GxCx0+iw=","Date":"Sat, 16 Oct 2021 02:16:38 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<YWoL1tKgtX6N/Ujp@pendragon.ideasonboard.com>","References":"<20211014115951.2996808-1-naush@raspberrypi.com>\n\t<20211014115951.2996808-2-naush@raspberrypi.com>\n\t<YWiU8VGOw1es92KO@pendragon.ideasonboard.com>\n\t<CAEmqJPoPpxzkdXoMixkz3L9dh9Ls2dBmQyeJ04-tQg5sr=sWZw@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPoPpxzkdXoMixkz3L9dh9Ls2dBmQyeJ04-tQg5sr=sWZw@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4 1/2] utils: gen-version: Pass the\n\tmeson source root to the gen-version.sh script","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]