From patchwork Sat Aug 20 08:07:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 17182 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 45A53C3272 for ; Sat, 20 Aug 2022 08:08:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 66D0361FC0; Sat, 20 Aug 2022 10:08:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1660982885; bh=PJFNS35809PNJlMkFwSvZO1OyPq+qlB55G1ODx1+6+w=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=iDuaG1/L74RAN6KXtOOaf6LmSddrDbDwMnABZwlHhVQGmIEr3c72+wcvTOpTa3Zvq xsumkMr88yK88v7Mpji3aHw+93SX1cSnFD/U7knhZ/HtT3BRKt/NlUwR307AVpzXwR TEA+27FWFX3FAl6cp97TZmupK3APBbd6tY+Bf3V4FxmB7mjSpIo3qmlykE4sxpLOBz y9E2AKnMz9IAF2UWS+F6XQvZ+5PWb7CIw40i1t+Y9Uq2lfbPMA+wTCS3o819QbiUxq H8HflP4ibFcKKMMDzETGrwPLyKfb3Igv6ctlI1ySub+bKjh8qLViO6IFYg52rGvNel vekFgO+UcrRuQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 75DAE603E3 for ; Sat, 20 Aug 2022 10:08:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="nHKcON3Z"; dkim-atps=neutral Received: from deskari.lan (91-158-154-79.elisa-laajakaista.fi [91.158.154.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B688E3F1; Sat, 20 Aug 2022 10:08:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1660982883; bh=PJFNS35809PNJlMkFwSvZO1OyPq+qlB55G1ODx1+6+w=; h=From:To:Cc:Subject:Date:From; b=nHKcON3ZIA/wZ8bsWD5ChfwIvzUb5RD4BhDpN2gKrByDYFph35bQAvg89vAfT5uP7 FthPSZSO5vmjpJe7d64wie+3ttJgkWkuOIqLbHs5xSrL7b6blvbp2lbOkGA+jqhULx 7dequHkwfYpV8oQIiQhi2KWbgm4Xs239WqWip2Bo= To: libcamera-devel@lists.libcamera.org, Kieran Bingham , Laurent Pinchart Date: Sat, 20 Aug 2022 11:07:44 +0300 Message-Id: <20220820080744.30325-1-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH] libcamera: Disable automatic vcs versioning 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: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" libcamera builds the git hash version into the libcamera library. This makes ninja create the generated version.cpp on every build, and if the git hash has changed, compilation of version.cpp and linking of libcamera library. This patch adds a meson option to disable this behavior and instead use the meson project-version as the version built into the library, which is only generated at meson configuration time. With this change, ninja will nicely say "no work to do" if there's nothing to compile, instead of starting the build and generating version.cpp. But, more importantly, it often reduces build time. For example, this takes a particular git range compilation (~20 py bindings patches) from 43 seconds to 10 seconds. Obviously the improvement depends very much on the patches in question. If every commit changes libcamera itself, there is no difference. Signed-off-by: Tomi Valkeinen --- meson_options.txt | 5 +++++ src/libcamera/meson.build | 29 +++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index 7a9aecfc..6a0bd0be 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -63,3 +63,8 @@ option('pycamera', type : 'feature', value : 'disabled', description : 'Enable libcamera Python bindings (experimental)') + +option('disable-vcs-versioning', + type : 'boolean', + value : false, + description : 'Disable automatic libcamera library versioning with the git hash') diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index ce1f0f2f..6fd6f084 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -121,14 +121,27 @@ endforeach libcamera_sources += control_sources -gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh' - -# Use vcs_tag() and not configure_file() or run_command(), to ensure that the -# version gets updated with every ninja build and not just at meson setup time. -version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()], - input : 'version.cpp.in', - output : 'version.cpp', - fallback : meson.project_version()) +if get_option('disable-vcs-versioning') + cdata = configuration_data() + cdata.set('VCS_TAG', meson.project_version()) + + # For some reason using 'version.cpp' as output file works fine for generation + # but causes meson to delete the file before build. Any other file name + # seems to work. + version_cpp = configure_file(input : 'version.cpp.in', + output : 'version_static.cpp', + configuration : cdata) + +else + gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh' + + # Use vcs_tag() and not configure_file() or run_command(), to ensure that the + # version gets updated with every ninja build and not just at meson setup time. + version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()], + input : 'version.cpp.in', + output : 'version.cpp', + fallback : meson.project_version()) +endif libcamera_sources += version_cpp