{"id":18627,"url":"https://patchwork.libcamera.org/api/patches/18627/?format=json","web_url":"https://patchwork.libcamera.org/patch/18627/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20230515095812.3409747-2-kieran.bingham@ideasonboard.com>","date":"2023-05-15T09:58:11","name":"[libcamera-devel,v2,1/2] utils: ABI Compatibility checker","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"93d8d0d620e74ed3cb38b417f961266c0905df2e","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18627/mbox/","series":[{"id":3877,"url":"https://patchwork.libcamera.org/api/series/3877/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3877","date":"2023-05-15T09:58:10","name":"Use x.y soname versioning","version":2,"mbox":"https://patchwork.libcamera.org/series/3877/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18627/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18627/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 97220C3284\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 15 May 2023 09:58:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 003A062864;\n\tMon, 15 May 2023 11:58:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E9A96039F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 May 2023 11:58:17 +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 5DD3A4DB;\n\tMon, 15 May 2023 11:58:06 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1684144699;\n\tbh=KYUMbwyFpH59xBndsUDHsL8c52aSCrg6t6LqnfCicyw=;\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=n5EeHjZ2q7I303IWYnT+NAKBSIQ49Ii/JwbTLtskrDk1v6nxaOS+qxLe6yIujj1OK\n\tAyAyWzhxM3u6rQmiIiKb+GriOCyJYEcywl7ykks/Ew8b/JY/xU+Qtn/5g0R82jjf0a\n\tMZQLpTXjvLBVoHvwDuyN5gSCPNNO2tg29NywXfpcy3O7Vdv+hrREZGri+0O0zLXVNE\n\tYam3ASJN+zMDasUjo+71gpuhAq7nvaJzJMkpDj53GTsHMkUY3tN+vO5zi9Wt5cDSV+\n\tJjmet//9SICKmGN1g7amfOeXgYPpnXlpmnsxraAh/hgKUXD1P7nMuRqK1QhRzADrLI\n\tVks6tFA1LYpFA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1684144686;\n\tbh=KYUMbwyFpH59xBndsUDHsL8c52aSCrg6t6LqnfCicyw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=oHGy/1m2zvbEHprd43LUsItsCHCQQEM2/z0mywrie9F1M036X588iFf34WEV8/Ef8\n\t2YzpLhdIZ34nGEoT68MX7GO2XaYyTBoMN0rOZuT9kp60JzTCJsbz0K8ZJ8gFM4m5mm\n\tDopl+v5U2md/+A5Y8Bx2G9RYXp3oafHdlq/a5WvI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"oHGy/1m2\"; dkim-atps=neutral","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Mon, 15 May 2023 10:58:11 +0100","Message-Id":"<20230515095812.3409747-2-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230515095812.3409747-1-kieran.bingham@ideasonboard.com>","References":"<20230515095812.3409747-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 1/2] 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 utils/abi-compat.sh | 198 ++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 198 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..b1944dc7d594\n--- /dev/null\n+++ b/utils/abi-compat.sh\n@@ -0,0 +1,198 @@\n+#!/bin/bash\n+\n+NAME=$(basename \"$0\")\n+usage() {\n+cat << 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+POSITIONAL=()\n+while [[ $# -gt 0 ]]\n+do\n+case $1 in\n+    -h|--help)\n+        usage\n+\texit 127;\n+        ;;\n+\n+    --abi-dir)\n+\tABI_DIR=$2\n+\tshift; shift;\n+\t;;\n+\n+    --tmp-dir)\n+\tTMP=$2\n+\tshift; shift;\n+\t;;\n+\n+    *)  # Parse unidentified arguments based on position\n+        POSITIONAL+=(\"$1\")\n+        shift # past argument\n+        ;;\n+esac\n+done\n+set -- \"${POSITIONAL[@]}\" # restore positional parameters\n+\n+ABI_DIR=${ABI_DIR:-abi}\n+TMP=${TMP:-\"$ABI_DIR/tmp/\"}\n+\n+mkdir -p \"$ABI_DIR\"\n+mkdir -p \"$TMP\"\n+\n+dbg () {\n+\techo \"$@\" >> /dev/stderr\n+}\n+\n+die () {\n+\techo \"$NAME: $*\" >> /dev/stderr\n+\texit 128\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+describe () {\n+\tgit describe --tags \"$@\" \\\n+\t\t|| die \"Failed to describe $1\"\n+}\n+\n+# Make sure we exit on errors during argument parsing\n+set -Eeuo pipefail\n+\n+# Check HEAD against previous 'release'\n+if test $# -eq 0;\n+then\n+\tFROM=$(prev_release HEAD)\n+\tTO=$(describe HEAD)\n+fi\n+\n+# Check COMMIT against previous release\n+if test $# -eq 1;\n+then\n+\tFROM=$(prev_release \"$1\")\n+\tTO=$(describe \"$1\")\n+fi\n+\n+# Check ABI between FROM and TO explicitly\n+if test $# -eq 2;\n+then\n+\tFROM=$(describe \"$1\")\n+\tTO=$(describe \"$2\")\n+fi\n+\n+echo \"Validating ABI compatibility between $FROM and $TO\"\n+\n+# Generate an abi-compliance-checker xml description file\n+# $PREFIX is assumed to be /usr/local/\n+create_xml() {\n+\t# $1: Output file\n+\t# $2: Version\n+\t# $3: Install root\n+\n+\techo \"<version>$2</version>\" > \"$1\"\n+\techo \"<headers>$3/usr/local/include/</headers>\" >> \"$1\"\n+\techo \"<libs>$3/usr/local/lib/</libs>\" >> \"$1\"\n+}\n+\n+# Check if an ABI dump file exists, and if not create one\n+# by building a minimal configuration of libcamera at the specified\n+# version using a clean worktree.\n+create_abi_dump() {\n+\tVERSION=\"$1\"\n+\tABI_FILE=\"$ABI_DIR/$VERSION.abi.dump\"\n+\tWORKTREE=\"$TMP/$VERSION\"\n+\tBUILD=\"$TMP/$VERSION-build\"\n+\n+\t# Use a fully qualified path when calling ninja -C\n+\tINSTALL=$(realpath \"$TMP/$VERSION-install\")\n+\n+\tif test ! -e \"$ABI_FILE\";\n+\tthen\n+\t\tdbg \"Creating ABI dump for $VERSION in $ABI_DIR\"\n+\t\tgit worktree add \"$WORKTREE\" \"$VERSION\"\n+\n+\t\tmeson setup \"$BUILD\" \"$WORKTREE\" \\\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+\n+\t\t# We currently have warnings produced that we can ignore\n+\t\t# While we have pipefail set, finish with || true\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\" || true\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+\t;\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+killall abi-compliance-checker 2>/dev/null\n","prefixes":["libcamera-devel","v2","1/2"]}