{"id":18780,"url":"https://patchwork.libcamera.org/api/1.1/patches/18780/?format=json","web_url":"https://patchwork.libcamera.org/patch/18780/","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":"<20230704142435.3490823-3-kieran.bingham@ideasonboard.com>","date":"2023-07-04T14:24:34","name":"[libcamera-devel,v3,2/3] utils: ABI Compatibility checker","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"62f3027610d2dc7f8b6dc5dd44b2e129f001eb69","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18780/mbox/","series":[{"id":3948,"url":"https://patchwork.libcamera.org/api/1.1/series/3948/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3948","date":"2023-07-04T14:24:32","name":"Use x.y soname versioning","version":3,"mbox":"https://patchwork.libcamera.org/series/3948/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18780/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18780/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 AFDCFBDC71\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  4 Jul 2023 14:24:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 77C4E628C7;\n\tTue,  4 Jul 2023 16:24:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 97A72628BD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  4 Jul 2023 16:24:39 +0200 (CEST)","from Monstersaurus.local\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5DCA210A0;\n\tTue,  4 Jul 2023 16:23:55 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1688480682;\n\tbh=p7GjK0PLjWilnGSACZL54atAPZgSIy6A6J0Yxgqb1To=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=4FSdKi9o//Hg/ZSkScNS/DaDiGIKTP148FjBcfLYWdgOgiXEyRW9foiFM9hew/FFr\n\tnLfiXEdQjKQ6YBDBQ6jVHjoGjRXlo5ua8Xe1fkfjJ0GoVa/PcladtxMkRJbXFhg7xy\n\t5Z6tBS3PK+3BBMWHnbd3+sewOdadmiOhTGfZXrNKPB3nE6WTZFM63GkoREiu5fhHTy\n\tA9MjwXD4Lki7axotSuHuYO5J5hShZU5m82LctfvfhmxxmgUoSm/t+4BIlTw01owrO2\n\to6T0++FrgdX22P9IPV3tyiAEb3Ks6BiukNIkjPLaoEt0Vn/vs0WngavtUzZUhFh9NU\n\tgD/8iJWtBFynQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1688480635;\n\tbh=p7GjK0PLjWilnGSACZL54atAPZgSIy6A6J0Yxgqb1To=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Oha3SaPs52uKpCnfr3zYYo5gPtU1UMxggXOOEiZh8hO8HNpsDXZQiwIeHTDJpZskJ\n\tNLDwyYqkEg017Mt0S+ch0Q0lk8obiD9d5hPQo25w+FduOgn4uGYs/1jkXsUQ7G3GO5\n\tQ36X0/7IFYVYAL7352GGXlb74wZsdpKFxC2ozIJo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Oha3SaPs\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Tue,  4 Jul 2023 15:24:34 +0100","Message-Id":"<20230704142435.3490823-3-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230704142435.3490823-1-kieran.bingham@ideasonboard.com>","References":"<20230704142435.3490823-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 2/3] utils: ABI Compatibility checker","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Provide support to compare ABI compatibility between any two git commits\nor by a commit and the most recent ancestral tag of that commit.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nv3\n  - use '--force' for git worktree add to prevent issues on cancelled\n    builds\n\n  - define 'libdir' and 'prefix' explicitly to prevent reliance on\n    system defaults.\n\n  - many fixups thanks to Laurents review.\n\n  - abi-compat now fails correctly in case of error. (This means it can\n    only run on trees that have the patch 1/3 of this series applied).\n\n\n utils/abi-compat.sh | 212 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 212 insertions(+)\n create mode 100755 utils/abi-compat.sh","diff":"diff --git a/utils/abi-compat.sh b/utils/abi-compat.sh\nnew file mode 100755\nindex 000000000000..785d081d6e1c\n--- /dev/null\n+++ b/utils/abi-compat.sh\n@@ -0,0 +1,212 @@\n+#!/bin/bash\n+\n+# SPDX-License-Identifier: GPL-2.0-or-later\n+# Generate and compare the ABI compatibilty of two libcamera versions\n+\n+name=$(basename \"$0\")\n+\n+usage() {\n+\tcat << EOF\n+$name: Determine the ABI/API compatibility of two build versions\n+\n+  $name [--help] [--abi-dir=<PATH>] [--tmp-dir=<PATH>] ARGS\n+\n+The positional arguments (ARGS) determine the versions that will be compared and\n+take three variants:\n+\n+  - No positional arguments:\n+      $name [optional arguments]\n+\n+      It is assumed to compare the current git HEAD against the most recent TAG\n+\n+  - One positional argument:\n+      $name [optional aguments] COMMITISH\n+\n+      The given COMMITISH is compared against it's most recent TAG\n+\n+  - Two positional arguments:\n+      $name [optional aguments] BASE COMMITISH\n+\n+      The given COMMITISH is compared against the given BASE.\n+\n+Optional Arguments:\n+  --abi-dir <path> Use <path> for storing (or retrieving existing) ABI data\n+                   files\n+\n+  --tmp-dir <path> Specify temporary build location for building ABI data.\n+                   This could be a tmpfs/RAM disk to save on disk writes.\n+EOF\n+}\n+\n+dbg () {\n+\techo \"$@\" >> /dev/stderr\n+}\n+\n+die () {\n+\techo \"$name: $*\" >> /dev/stderr\n+\texit 128\n+}\n+\n+describe () {\n+\tgit describe --tags \"$1\" \\\n+\t\t|| die \"Failed to describe $1\"\n+}\n+\n+prev_release () {\n+\tgit describe --tags --abbrev=0 \"$1\"^ \\\n+\t\t|| die \"Failed to identify previous release tag from $1\"\n+}\n+\n+# Make sure we exit on errors during argument parsing.\n+set -Eeuo pipefail\n+\n+positional=()\n+while [[ $# -gt 0 ]] ; do\n+\toption=\"$1\"\n+\tshift\n+\n+\tcase $option in\n+\t-h|--help)\n+\t\tusage\n+\t\texit 0 \n+\t        ;;\n+\n+\t--abi-dir)\n+\t\tabi_dir=$1\n+\t\tshift\n+\t\t;;\n+\n+\t--tmp-dir)\n+\t\ttmp=$1\n+\t\tshift\n+\t\t;;\n+\n+\t-*)\n+\t\tdie \"Unrecognised argument $option\"\n+\t\t;;\n+\n+\t*) # Parse unidentified arguments based on position.\n+\t\tpositional+=(\"$option\")\n+\t\t;;\n+\tesac\n+done\n+set -- \"${positional[@]}\" # restore positional parameters.\n+\n+# Parse positional arguments.\n+case $# in\n+\t0) \t# Check HEAD against previous 'release'.\n+\t\tfrom=$(prev_release HEAD)\n+\t\tto=$(describe HEAD)\n+\t\t;;\n+\n+\t1)\t# Check COMMIT against previous release.\n+\t\tfrom=$(prev_release \"$1\")\n+\t\tto=$(describe \"$1\")\n+\t\t;;\n+\n+\t2)\t# Check ABI between FROM and TO explicitly.\n+\t\tfrom=$(describe \"$1\")\n+\t\tto=$(describe \"$2\")\n+\t\t;;\n+\n+\t*)\n+\t\tdie \"Invalid arguments\"\n+\t\t;;\n+esac\n+\n+if ! which abi-compliance-checker; then\n+\tdie \"This tool requires 'abi-compliance-checker' to be installed.\"\n+fi\n+\n+\n+abi_dir=${abi_dir:-abi}\n+tmp=${tmp:-\"$abi_dir/tmp/\"}\n+\n+echo \"Validating ABI compatibility between $from and $to\"\n+\n+mkdir -p \"$abi_dir\"\n+mkdir -p \"$tmp\"\n+\n+# Generate an abi-compliance-checker xml description file.\n+create_xml() {\n+\tlocal output=\"$1\"\n+\tlocal version=\"$2\"\n+\tlocal root=\"$3\"\n+\n+\techo \"<version>$version</version>\" > \"$output\"\n+\techo \"<headers>$root/usr/local/include/</headers>\" >> \"$output\"\n+\techo \"<libs>$root/usr/local/lib/</libs>\" >> \"$output\"\n+}\n+\n+# Check if an ABI dump file exists, and if not create one by building a minimal\n+# configuration of libcamera at the specified version using a clean worktree.\n+create_abi_dump() {\n+\tlocal version=\"$1\"\n+\tlocal abi_file=\"$abi_dir/$version.abi.dump\"\n+\tlocal worktree=\"$tmp/$version\"\n+\tlocal build=\"$tmp/$version-build\"\n+\n+\t# Use a fully qualified path when calling ninja -C.\n+\tinstall=$(realpath \"$tmp/$version-install\")\n+\n+\tif [[ ! -e \"$abi_file\" ]] ; then\n+\t\tdbg \"Creating ABI dump for $version in $abi_dir\"\n+\t\tgit worktree add --force \"$worktree\" \"$version\"\n+\n+\t\t# Generate a minimal libcamera build. \"lib\" and \"prefix\" are\n+\t\t# defined explicitly to avoid system default ambiguities. \n+\t\tmeson setup \"$build\" \"$worktree\" \\\n+\t\t\t-Dlibdir=lib \\\n+\t\t\t-Dprefix=/usr/local/ \\\n+\t\t\t-Ddocumentation=disabled \\\n+\t\t\t-Dcam=disabled \\\n+\t\t\t-Dqcam=disabled \\\n+\t\t\t-Dgstreamer=disabled \\\n+\t\t\t-Dlc-compliance=disabled \\\n+\t\t\t-Dtracing=disabled \\\n+\t\t\t-Dpipelines=\n+\n+\t\tninja -C \"$build\"\n+\t\tDESTDIR=\"$install\" ninja -C \"$build\" install\n+\n+\t\t# Create an xml descriptor with parameters to generate the dump file.\n+\t\tcreate_xml \\\n+\t\t\t\"$install/libcamera-abi-dump.xml\" \\\n+\t\t\t\"$version\" \\\n+\t\t\t\"$install\"\n+\n+\t\tabi-compliance-checker \\\n+\t\t\t-lib libcamera \\\n+\t\t\t-v1 \"$version\" \\\n+\t\t\t-dump \"$install/libcamera-abi-dump.xml\" \\\n+\t\t\t-dump-path \"$abi_file\"\n+\n+\t\tdbg Created \"$abi_file\"\n+\n+\t\tdbg Removing Worktree \"$worktree\"\n+\t\tgit worktree remove -f \"$worktree\"\n+\n+\t\tdbg Removing \"$build\"\n+\t\trm -r \"$build\"\n+\n+\t\tdbg Removing \"$install\"\n+\t\trm -r \"$install\"\n+\tfi\n+}\n+\n+# Create the requested ABI dump files if they don't yet exist.\n+create_abi_dump \"$from\"\n+create_abi_dump \"$to\"\n+\n+# TODO: Future iterations and extensions here could add \"-stdout -xml\" and\n+# parse the results automatically.\n+abi-compliance-checker -l libcamera \\\n+\t-old \"$abi_dir/$from.abi.dump\" \\\n+\t-new \"$abi_dir/$to.abi.dump\"\n+\n+# On (far too many) occasions, the tools keep running leaving a cpu core @ 100%\n+# CPU usage. Perhaps some subprocess gets launched but never rejoined. Stop\n+# them all.\n+#\n+# TODO: Investigate this and report upstream.\n+killall abi-compliance-checker 2>/dev/null\n","prefixes":["libcamera-devel","v3","2/3"]}