From patchwork Wed Oct 13 12:23:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14498 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 0B90CBDB1C for ; Tue, 9 Nov 2021 17:42:35 +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 9CDD0DEE for ; Tue, 9 Nov 2021 18:42:34 +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="CunA1Eg1"; dkim-atps=neutral Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id CKOcA7jPZmFSRwAA4E0KoQ (envelope-from ) for ; Wed, 13 Oct 2021 14:23:20 +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 E9F03291; Wed, 13 Oct 2021 14:23:19 +0200 (CEST) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7799368F4F; Wed, 13 Oct 2021 14:23:19 +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="CunA1Eg1"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6265260501 for ; Wed, 13 Oct 2021 14:23:17 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id g25so7789828wrb.2 for ; Wed, 13 Oct 2021 05:23:17 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=rG8DW+6gx/1Sb+gw8D3PypjPmNytpF2ok91imMRQ66E=; b=CunA1Eg1cpF//dlMjRLYO+qsYesVdJMkiI5SNLaE6x6beuyzcG2vGB3I1jB/P6cH3T 5IVxnFqBa4MBP4KdhBcZLXnUoL9cxHZCLj6v0h06H2c6aYAPLcQf8fXyz0Pi6UPTHwii +kUQIAw//f1EthOQe15maktLr/ASxWpODSZKdB2iTeduDFRg2PGTC7UfTsKxy5pz4V6W fxRAsk6LpU6+Nzw7lhBkQus7UmR+epeqrjzs4Z4pKQdZ6+fOMm/+qFjE86e71kpLHZ0b vplnIxDUFV9DBY/rkETBP5ORDWZYwtGuaAmfQyZEqTCAoGmgtWClXVlc7ikZpx3C/oGl D/Zg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=rG8DW+6gx/1Sb+gw8D3PypjPmNytpF2ok91imMRQ66E=; b=AC6nDL8+XoiIqX4LgghA4llyVd0vP2gsJU2hzpJNOhDeMwZlX7bFSGKAHiNH50fi44 IzmElxChLavOwIisymn+kJYZf5f7gvSMIPUEluYYeIznqROrEnnw/Vb9vJOaTCXHrCzW 10dMentSypsAHJFCDi5fMNRmHmXXvuDrJh3VgYtxkQyzMg8tKnAIR/FDTEaMD1IAUTYr JBu+DBjVPmTsLzmpm+KHJvVVqC9ksOs8onZdULCn39T5uR2PJ8CVR3nyixJixAoqcSVN R/2/bBCrvLRmpW0Xi4z+sHSZqrisK3DcngDjm/BDqJNj4mqq5GTS+mItSZGTLYJoSTP8 BCAg== X-Gm-Message-State: AOAM530myWdiNNNovfOvuhKbutLNHSAegsnbjz3ViGoczdHozNBuKs6R x0jY3YFPIwabLBKi3i+vsjNcZJSrjOFnnQ== X-Google-Smtp-Source: =?utf-8?q?ABdhPJwEJRaPlVW23wl88ZrbufhMrrYqYBz+A6BXO?= =?utf-8?q?mh3L6139DPSiHYLZV+bpZDA/C45zDiwNOyD5A=3D=3D?= X-Received: by 2002:a7b:cbd1:: with SMTP id n17mr12328007wmi.113.1634127796821; Wed, 13 Oct 2021 05:23:16 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:a13d:95a9:c25e:7597]) by smtp.gmail.com with ESMTPSA id v3sm13412961wrg.23.2021.10.13.05.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 05:23:16 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Oct 2021 13:23:12 +0100 Message-Id: <20211013122312.1943362-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211013122312.1943362-1-naush@raspberrypi.com> References: <20211013122312.1943362-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/1] 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: mjMEtvGjIS1s 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 version.gen 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 version.gen 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..85ca0013733e 100644 --- a/meson.build +++ b/meson.build @@ -24,6 +24,9 @@ endif libcamera_version = libcamera_git_version.split('+')[0] +# This script gererates the version.gen 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..09cede84c25e 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -5,6 +5,15 @@ build_dir="$1" +# If version.gen 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}"/version.gen ] +then + cat "${MESON_SOURCE_ROOT}"/version.gen + 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..3b6c0adb05ed --- /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"/version.gen