{"id":17182,"url":"https://patchwork.libcamera.org/api/1.1/patches/17182/?format=json","web_url":"https://patchwork.libcamera.org/patch/17182/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220820080744.30325-1-tomi.valkeinen@ideasonboard.com>","date":"2022-08-20T08:07:44","name":"[libcamera-devel,RFC] libcamera: Disable automatic vcs versioning","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"b97e45cf3751ffb14900f11f93245a71020e881f","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/1.1/people/109/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17182/mbox/","series":[{"id":3429,"url":"https://patchwork.libcamera.org/api/1.1/series/3429/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3429","date":"2022-08-20T08:07:44","name":"[libcamera-devel,RFC] libcamera: Disable automatic vcs versioning","version":1,"mbox":"https://patchwork.libcamera.org/series/3429/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17182/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17182/checks/","tags":{},"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 45A53C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 20 Aug 2022 08:08:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 66D0361FC0;\n\tSat, 20 Aug 2022 10:08:05 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 75DAE603E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Aug 2022 10:08:03 +0200 (CEST)","from deskari.lan (91-158-154-79.elisa-laajakaista.fi\n\t[91.158.154.79])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B688E3F1;\n\tSat, 20 Aug 2022 10:08:02 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660982885;\n\tbh=PJFNS35809PNJlMkFwSvZO1OyPq+qlB55G1ODx1+6+w=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=iDuaG1/L74RAN6KXtOOaf6LmSddrDbDwMnABZwlHhVQGmIEr3c72+wcvTOpTa3Zvq\n\txsumkMr88yK88v7Mpji3aHw+93SX1cSnFD/U7knhZ/HtT3BRKt/NlUwR307AVpzXwR\n\tTEA+27FWFX3FAl6cp97TZmupK3APBbd6tY+Bf3V4FxmB7mjSpIo3qmlykE4sxpLOBz\n\ty9E2AKnMz9IAF2UWS+F6XQvZ+5PWb7CIw40i1t+Y9Uq2lfbPMA+wTCS3o819QbiUxq\n\tH8HflP4ibFcKKMMDzETGrwPLyKfb3Igv6ctlI1ySub+bKjh8qLViO6IFYg52rGvNel\n\tvekFgO+UcrRuQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660982883;\n\tbh=PJFNS35809PNJlMkFwSvZO1OyPq+qlB55G1ODx1+6+w=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=nHKcON3ZIA/wZ8bsWD5ChfwIvzUb5RD4BhDpN2gKrByDYFph35bQAvg89vAfT5uP7\n\tFthPSZSO5vmjpJe7d64wie+3ttJgkWkuOIqLbHs5xSrL7b6blvbp2lbOkGA+jqhULx\n\t7dequHkwfYpV8oQIiQhi2KWbgm4Xs239WqWip2Bo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"nHKcON3Z\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH] libcamera: Disable automatic vcs\n\tversioning","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>","From":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"libcamera builds the git hash version into the libcamera library. This\nmakes ninja create the generated version.cpp on every build, and if the\ngit hash has changed, compilation of version.cpp and linking of\nlibcamera library.\n\nThis patch adds a meson option to disable this behavior and instead use\nthe meson project-version as the version built into the library, which\nis only generated at meson configuration time.\n\nWith this change, ninja will nicely say \"no work to do\" if there's\nnothing to compile, instead of starting the build and generating\nversion.cpp.\n\nBut, more importantly, it often reduces build time. For example, this\ntakes a particular git range compilation (~20 py bindings patches) from\n43 seconds to 10 seconds. Obviously the improvement depends very much on\nthe patches in question. If every commit changes libcamera itself, there\nis no difference.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n---\n meson_options.txt         |  5 +++++\n src/libcamera/meson.build | 29 +++++++++++++++++++++--------\n 2 files changed, 26 insertions(+), 8 deletions(-)","diff":"diff --git a/meson_options.txt b/meson_options.txt\nindex 7a9aecfc..6a0bd0be 100644\n--- a/meson_options.txt\n+++ b/meson_options.txt\n@@ -63,3 +63,8 @@ option('pycamera',\n         type : 'feature',\n         value : 'disabled',\n         description : 'Enable libcamera Python bindings (experimental)')\n+\n+option('disable-vcs-versioning',\n+        type : 'boolean',\n+        value : false,\n+        description : 'Disable automatic libcamera library versioning with the git hash')\ndiff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\nindex ce1f0f2f..6fd6f084 100644\n--- a/src/libcamera/meson.build\n+++ b/src/libcamera/meson.build\n@@ -121,14 +121,27 @@ endforeach\n \n libcamera_sources += control_sources\n \n-gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh'\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-version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()],\n-                      input : 'version.cpp.in',\n-                      output : 'version.cpp',\n-                      fallback : meson.project_version())\n+if get_option('disable-vcs-versioning')\n+    cdata = configuration_data()\n+    cdata.set('VCS_TAG', meson.project_version())\n+\n+    # For some reason using 'version.cpp' as output file works fine for generation\n+    # but causes meson to delete the file before build. Any other file name\n+    # seems to work.\n+    version_cpp = configure_file(input : 'version.cpp.in',\n+                                 output : 'version_static.cpp',\n+                                 configuration : cdata)\n+\n+else\n+    gen_version = meson.project_source_root() / 'utils' / 'gen-version.sh'\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+    version_cpp = vcs_tag(command : [gen_version, meson.project_build_root(), meson.project_source_root()],\n+                          input : 'version.cpp.in',\n+                          output : 'version.cpp',\n+                          fallback : meson.project_version())\n+endif\n \n libcamera_sources += version_cpp\n \n","prefixes":["libcamera-devel","RFC"]}