From patchwork Tue Oct 12 15:24:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14109 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 210A9C323E for ; Tue, 12 Oct 2021 15:24:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DFD6468F53; Tue, 12 Oct 2021 17:24:29 +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="ICg2pXwm"; 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 412FD68F4C for ; Tue, 12 Oct 2021 17:24:28 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id t2so68095151wrb.8 for ; Tue, 12 Oct 2021 08:24:28 -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=OvMhSQhG+5/bk6lR+tOIZyQf2Gts38eW8TySEnyx7kM=; b=ICg2pXwm7tgC1Vt1lFUiagKyXA+ap7z4Al2dz6gjjJH/8hrjQnERTmejhGeDhmlft5 rglBCxc2lSb1Vzko6NHgg4tNfiFI81OsBhuVCFcFLnMLJeZHdtHO3EqQwPGReBKknvSB vIIreI52/nNWfFNuFmeQluNlmTpt94dtI9X1zK97madc9s2tKZfKpC15gtysWLKha9mF Uwrwt9ausVD1tWii3cxfLfjYFkQgg0A8ssXEUWm8nCU+skJL+0oWv4yVNkLmf+2WHpyo 2tJvJ5/hu7KmrFUcV0SjHHFdhYVQV3mDKsqNloimhseyRbmYmJR70pxb/4vNA0xxZIYH kdCQ== 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=OvMhSQhG+5/bk6lR+tOIZyQf2Gts38eW8TySEnyx7kM=; b=eoCX93YKUiS/jtC3Dsjp88YAZ5bfwe4zo13R9Db1XTosFb6f4NQD7K5ogHp0Pqe5E8 1wBj+HnKAtX3kJ59EILB22xxCUUAgkNCaQTjZEKFCXWOemqOo7gEs81YQm9vDxKigL1T rZcwPHkNKQDQ8sZZjo8b1hPgU6MSOj9dqpkANLOnkl5uEg5+l8yuDU8anPvO/dPlppCd KmJt0WsOYF+I3/oCjcXAHHs7GwXXpzrmJGVZl0eZmIVNnpC0IgjfIGuBz3vONJ/SPDJV fXXdaMsWmDAvp0ukntv6n3nnK75n3DNdN1KgjkvYqRU7iczJ0xbEm0abR3TJ92ThGdaf CxDw== X-Gm-Message-State: AOAM530F7Kve82232ULUS+vl6QVG+uibolYDhugDdZRAuLa6NN6n3kew AKt/XrfdKsel0V4lCtUfrWRwQyrm3IoyUA== X-Google-Smtp-Source: ABdhPJxt8lueEJw6S2FI5B54f9WtvOHanNi92x8bvRsv8HHJ+Kw96/JEu9gJoiDDEOAlYYQs0Ay7Nw== X-Received: by 2002:adf:d1cb:: with SMTP id b11mr33346850wrd.418.1634052267654; Tue, 12 Oct 2021 08:24:27 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:26ae:314c:5c3f:f0df]) by smtp.gmail.com with ESMTPSA id s14sm10683449wro.76.2021.10.12.08.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 08:24:26 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Oct 2021 16:24:09 +0100 Message-Id: <20211012152410.978077-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012152410.978077-1-naush@raspberrypi.com> References: <20211012152410.978077-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 1/2] utils: Add an option to override SHA string in gen-version.sh 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" Add an optional second command line argument to the gen-version.sh shell script that would be used as the SHA value in the version string. An override is needed if distributions make libcamera builds outside of the upstream git tree. In these cases, the user can then use the correct SHA value of the upstream tree instead of the local downstream build tree. Signed-off-by: Naushir Patuck --- utils/gen-version.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/utils/gen-version.sh b/utils/gen-version.sh index b09ad495f86a..ba5185fa264c 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -2,15 +2,26 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Generate a version string using git describe +# +# An optional sha string can be passed as the second command line argument +# if the caller wishes to override the SHA value picked up by git. This may be +# useful when distribution packages are build outside of the upstream repo. build_dir="$1" +sha_override="$2" -# 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/..") - -# Get a short description from the tree. -version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null) +if [ -n "$sha_override" ] +then + # Use the sha provided on the command line. + version="v0.0.0-g$sha_override" +else + # 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/..") + + # Get a short description from the tree. + version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null) +fi if [ -z "$version" ] then @@ -26,7 +37,7 @@ if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir") then git update-index --refresh > /dev/null 2>&1 fi -git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))" +[ -n "$sha_override" ] || git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))" # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from # of the git SHA1 and remove the initial 'v'. From patchwork Tue Oct 12 15:24:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14494 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 875C0BDB1C for ; Tue, 9 Nov 2021 17:41:34 +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 15BB3501 for ; Tue, 9 Nov 2021 18:41:34 +0100 (CET) Authentication-Results: perceval.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="LpaRqYxk"; dkim-atps=neutral Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id ODQgHq2oZWFYVgAA4E0KoQ (envelope-from ) for ; Tue, 12 Oct 2021 17:24:29 +0200 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by perceval.ideasonboard.com (Postfix) with ESMTPS id 6BFABF1 for ; Tue, 12 Oct 2021 17:24:29 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id e3so34423451wrc.11 for ; Tue, 12 Oct 2021 08:24:29 -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=V75kjcsLywmMW/LLmyT1n9vuBzmEicER1Wde/5MtUvI=; b=LpaRqYxkWMdCIQBlZgwHO2IAP8C3Mvf+Y//SwgOX80Rhp9zvblScgHQgYQ2Fzc/lcG LOC62hezRSf8gdUlIbg88vqakRk4iXuXbwJsmWdJgUiymomdxBIytCfjyIXiNVqB1Y4J 9DmCaNL1R37yLuC2tJGHJgQBDJ9EkvydeqUlrv6NWPTi/oyt9ZFEyqKdKWLnDNNSwIRH 7pVyv0gbybmj3Se75DU+EOxYm8DUCxs/D/K2/xqUJg5dbYN9o9zl8Ks4wT828nkHOwmm D1HnqehyPKJF6mqWaVNMmQaDtmW8cGk5Yt4NxSzrWK2PiS75TV1VzQ53LiOGGjHNLRrw 1hbA== 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=V75kjcsLywmMW/LLmyT1n9vuBzmEicER1Wde/5MtUvI=; b=lNEav0Z29pS9GW8ZitjwDhxEd6RdKeivgAhbW7jIaP11f4oSYt2r5Z2tzXe3ECE/rA i41/62RzUbya4/t2qsijBfG2z7vsucI5N+WGJ8axUe7wlUJGtuRocZ/4E/P8g6BHcYBZ pN0lb7SZ0cHJKe3bzfT4MVkC0aVzXxvQT1kVXVtw47Dy+iuh3ywc7NBjv6F1UOSLL6wk q8jurmk4fWyhrijk+5EunR4xIWCMKgUbfw+ewjeHcafpQbk0HBPO4S+hdLfj6TwOyEmO nkSJJZPrrVDpvFw0LFItE+e3mVmt1HGpWbhcAKH6hKsdmxsG3U/UxGsHLLIWNQKZ3tbM epyQ== X-Gm-Message-State: AOAM533en5TItUrj3+zCNe7QwsCrRMGSD6ZXR9Zih3NJ345VtslBfPfl wqDGIR/YCZEsOioPFYEiNjEs3A== X-Google-Smtp-Source: =?utf-8?q?ABdhPJzHu6qDT69tJ5wu131nKYkarqVUeg89Cn+Ug?= =?utf-8?q?0RR4P08IadY9RY9xOl5GI+KYaYG815hhPJQ5Q=3D=3D?= X-Received: by 2002:a05:600c:4ed3:: with SMTP id g19mr6325005wmq.16.1634052269019; Tue, 12 Oct 2021 08:24:29 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:26ae:314c:5c3f:f0df]) by smtp.gmail.com with ESMTPSA id s14sm10683449wro.76.2021.10.12.08.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 08:24:27 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Kieran Bingham , Naushir Patuck Subject: [RFC 2/2] build: Add a "version_sha" meson build option Date: Tue, 12 Oct 2021 16:24:10 +0100 Message-Id: <20211012152410.978077-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012152410.978077-1-naush@raspberrypi.com> References: <20211012152410.978077-1-naush@raspberrypi.com> MIME-Version: 1.0 X-TUID: ExgVzqdk8IW0 Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org This build option can be used to override the SHA value in the version string generated by utils/gen-version.sh. An override is needed if distributions make libcamera builds outside of the upstream git tree. In these cases, the user can then use the correct SHA value of the upstream tree instead of the local downstream build tree. Signed-off-by: Naushir Patuck --- meson.build | 4 +++- meson_options.txt | 5 +++++ src/libcamera/meson.build | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index a49c484fe64e..cea6ca78cfa0 100644 --- a/meson.build +++ b/meson.build @@ -16,8 +16,10 @@ project('libcamera', 'c', 'cpp', # only. If the source tree isn't under git control, or if it matches the last # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from # libcamera_git_version. +version_sha_override = get_option('version_sha') libcamera_git_version = run_command('utils/gen-version.sh', - meson.build_root()).stdout().strip() + meson.build_root(), + version_sha_override).stdout().strip() if libcamera_git_version == '' libcamera_git_version = meson.project_version() endif diff --git a/meson_options.txt b/meson_options.txt index 2c80ad8b5e0b..96db8de4cdeb 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -58,3 +58,8 @@ option('v4l2', type : 'boolean', value : false, description : 'Compile the V4L2 compatibility layer') + +option('version_sha', + type : 'string', + value : '', + description : 'Custom version sha string to use') diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 243dd3c180eb..94cded2ce6c3 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -93,9 +93,10 @@ endforeach libcamera_sources += control_sources +version_sha_override = get_option('version_sha') gen_version = meson.source_root() / 'utils' / 'gen-version.sh' -version_cpp = vcs_tag(command : [gen_version, meson.build_root()], +version_cpp = vcs_tag(command : [gen_version, meson.build_root(), version_sha_override], input : 'version.cpp.in', output : 'version.cpp', fallback : meson.project_version())