From patchwork Thu Oct 14 10:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14523 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9E83DBDB1C for ; Wed, 10 Nov 2021 14:00:31 +0000 (UTC) Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E8E1E501 for ; Wed, 10 Nov 2021 15:00:30 +0100 (CET) Authentication-Results: perceval.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jJM4G+af"; dkim-atps=neutral Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id J0L5JY8DaGH7PwAA4E0KoQ (envelope-from ) for ; Thu, 14 Oct 2021 12:16:47 +0200 Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [IPv6:2001:4b98:dc0:43:216:3eff:fe33:f827]) by perceval.ideasonboard.com (Postfix) with ESMTPS id 439352F3; Thu, 14 Oct 2021 12:16:47 +0200 (CEST) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AAAE68F50; Thu, 14 Oct 2021 12:16:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jJM4G+af"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8919468541 for ; Thu, 14 Oct 2021 12:16:45 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id o20so17849787wro.3 for ; Thu, 14 Oct 2021 03:16:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wNYY6T7ghEWwviRg67OwOYqtIqRIwS6gzSciPVafIXs=; b=jJM4G+afc79KDbQD5rDgwRX8POe81hY2IF+9LLH+Pv/VjUnmCcZkIfd595O2x+M7bL nlMouKQ0SgB9rz/DU/LcX2Ne3v5DK/nDsG6B3HYDrellDk0ilEL6/Uu/XMMvBA2u2KCQ sSjwqIhKdAcUZMOpPdBwK3vVklj8RFFwWxcUSpXOMBYVBYCYrT3JcZOE/FQ5VbSOrFL7 Qd8rzptDUMfyNCB++vXVawTib9OeKQTKdygj+0KFcKg0AELWJvNcv5ojy5a0nX39xT02 SADhNXOzLoEVCiXeXPVGxXPkWzcZdbAO+Dn/tPanffTTRPOeyoLg7QTGA5j0IXN1hA63 vPHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wNYY6T7ghEWwviRg67OwOYqtIqRIwS6gzSciPVafIXs=; b=e83liOD/jA4nYwKQTwT++/nF6RLIIQsC6v/kacm0nGIMP7+6Jsdk3SveBLJV3xt3YY /zxTmn8msvuZxTggBujs0t6+9skPqMyuHO7OWr0Q43i+718nAMhEEmsRdwVgr4457/mV duk4sLtQsipn7uvCvS9lUOeecqYIzcUi9TWgnaOlouDrMis90FhztxtXoAjQiaVyrnGx vxj5PGkdqEK7/veEKMLFH21rUkZxJMN5l0QScYq7U/vqrvc+PC/EwTSfqotzwhblWGYj yc/HQSrvP8u4gOkvS+P8GhZHv6uZdEXbQvtGqqhUa3+fVH0FQHJjreLhvKRnqYMLAwGe dAGw== X-Gm-Message-State: AOAM5310nIyLeAt6x4ZJZvNCfU51F7Gw77Jg4Qe2R2F6vPe3btIof+Ho JAmxwJMLlK7Esn9v4RqxLJikV/KmoN/szOlE X-Google-Smtp-Source: =?utf-8?q?ABdhPJxzwxawmkBq3csyIShmfCsJ4xBKxlho79Tyk?= =?utf-8?q?6bO1+lnmfJQ9UaZxzvAOTyLPbcdmXMA5HHoow=3D=3D?= X-Received: by 2002:adf:b302:: with SMTP id j2mr5630628wrd.285.1634206604649; Thu, 14 Oct 2021 03:16:44 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:26af:fb8f:5d03:5eab]) by smtp.gmail.com with ESMTPSA id v10sm2142644wri.29.2021.10.14.03.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 03:16:44 -0700 (PDT) From: Naushir Patuck 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 Subject: [libcamera-devel] [PATCH v3] build: Preserve upstream git versioning using meson dist X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" X-TUID: oWACB0GLJCZc Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org When distributions build and package libcamera libraries, they may not necessarily run the build in the upstream source tree. In these cases, the git SHA1 versioning information will be lost. This change addresses that problem by requiring package managers to run 'meson dist' to create a tarball of the source files and build from there. On runing 'meson dist', the utils/run-dist.sh script will create a .tarball-version file in the release tarball with the version string generated from the existing utils/gen-version.sh script. The utils/gen-version.sh script has been updated to check for the presence of this .tarball-version file and read the version string from it instead of creating one. Signed-off-by: Naushir Patuck --- meson.build | 3 +++ src/libcamera/meson.build | 11 +++++------ utils/gen-version.sh | 9 +++++++++ utils/run-dist.sh | 11 +++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 utils/run-dist.sh diff --git a/meson.build b/meson.build index a49c484fe64e..67be6762108c 100644 --- a/meson.build +++ b/meson.build @@ -24,6 +24,9 @@ endif libcamera_version = libcamera_git_version.split('+')[0] +# This script gererates the .tarball-version file on a 'meson dist' command. +meson.add_dist_script('utils/run-dist.sh') + # Configure the build environment. cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 243dd3c180eb..360eaf80ecf1 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -93,12 +93,11 @@ endforeach libcamera_sources += control_sources -gen_version = meson.source_root() / 'utils' / 'gen-version.sh' - -version_cpp = vcs_tag(command : [gen_version, meson.build_root()], - input : 'version.cpp.in', - output : 'version.cpp', - fallback : meson.project_version()) +version_data = configuration_data() +version_data.set('VCS_TAG', libcamera_git_version) +version_cpp = configure_file(input : 'version.cpp.in', + output : 'version.cpp', + configuration : version_data) libcamera_sources += version_cpp diff --git a/utils/gen-version.sh b/utils/gen-version.sh index b09ad495f86a..216b1ff0b33e 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -5,6 +5,15 @@ build_dir="$1" +# If .tarball-version exists, output the version string from the file and exit. +# This file is auto-generated on a 'meson dist' command from the run-dist.sh +# script. +if [ -f "${MESON_SOURCE_ROOT}"/.tarball-version ] +then + cat "${MESON_SOURCE_ROOT}"/.tarball-version + exit 0 +fi + # Bail out if the directory isn't under git control src_dir=$(git rev-parse --git-dir 2>&1) || exit 1 src_dir=$(readlink -f "$src_dir/..") diff --git a/utils/run-dist.sh b/utils/run-dist.sh new file mode 100644 index 000000000000..e89c3733b56c --- /dev/null +++ b/utils/run-dist.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# +# On a meson dist run, generate the version string and store it in a file. +# This will later be picked up by the utils/gen-version.sh script and used +# instead of re-generating it. This way, if we are not building in the upstream +# git source tree, the upstream version information will be preserved. + +cd "$MESON_SOURCE_ROOT" || return +./utils/gen-version.sh > "$MESON_DIST_ROOT"/.tarball-version