scripts: Add abi-dump-formatter

abi-dumper uses perl's Data::Dumper without configuring the formatter,
which defaults to key-aligned indentation. That causes massive diff
churn, so provide a wrapper script to fix the dump formatting.

Change-Id: Id6834d9f2a8be7222036579c86448930633a796c
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/docs/checklists/changes.md b/docs/checklists/changes.md
index 2a69f55..386ebae 100644
--- a/docs/checklists/changes.md
+++ b/docs/checklists/changes.md
@@ -62,7 +62,7 @@
     `docker run --cap-add=sys_admin --rm=true --privileged=true -u $USER -w $(pwd) -v $(pwd):$(pwd) -e MAKEFLAGS= -it openbmc/ubuntu-unit-test:2024-W21-ce361f95ff4fa669`
 - [ ] `CC=gcc CXX=g++; [ $(uname -m) = 'x86_64' ] && meson setup -Dabi=deprecated,stable build`
 - [ ] `meson compile -C build`
-- [ ] `cp build/src/current.dump abi/x86_64/gcc.dump`
+- [ ] `./scripts/abi-dump-formatter < build/src/current.dump > abi/x86_64/gcc.dump`
 
 ## Removing an API
 
diff --git a/scripts/abi-dump-formatter b/scripts/abi-dump-formatter
new file mode 100755
index 0000000..0ac237e
--- /dev/null
+++ b/scripts/abi-dump-formatter
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# Copyright (C) 2013-2020 Andrey Ponomarenko's ABI Laboratory
+# Copyright (C) 2024 Code Construct
+
+# Copied from abi-dumper
+# Written by Andrey Ponomarenko
+sub dumpSorting($)
+{
+    my $Hash = $_[0];
+    return [] if(not $Hash);
+    my @Keys = keys(%{$Hash});
+    return [] if($#Keys<0);
+    if($Keys[0]=~/\A\d+\Z/)
+    { # numbers
+        return [sort {$a<=>$b} @Keys];
+    }
+    else
+    { # strings
+        return [sort {$a cmp $b} @Keys];
+    }
+}
+
+use Data::Dumper;
+
+# Prevent key lengths from changing the indentation
+$Data::Dumper::Indent = 1;
+$Data::Dumper::Sortkeys = \&dumpSorting;
+$/ = undef;
+print Dumper(eval(<>));