scripts: auto-generate list of schemas

Since the list of schemas is growing and we already have a directory, it
does not need to be updated manually. Make a script for it and check
that that's been done in CI.

Tested: Using 'meson install', check that schemas are installed like
before.
Script works and updates the files as expected.

Change-Id: Ia1b3d99890477c4077e8e3a52a5338805d810440
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/configurations/meson.build b/configurations/meson.build
index 98c6e46..9d4cecd 100644
--- a/configurations/meson.build
+++ b/configurations/meson.build
@@ -1,5 +1,5 @@
 # This file is auto-generated. Do not edit manually.
-# File content generated with generate_config_list.sh.
+# File content generated with generate_config_list.sh
 configs = [
     '1ux16_riser.json',
     '2ux8_riser.json',
diff --git a/meson.build b/meson.build
index ffef7c8..17671a3 100644
--- a/meson.build
+++ b/meson.build
@@ -92,23 +92,8 @@
     )
 endif
 
-schemas = [
-    'cpld.json',
-    'global.json',
-    'gpio_presence.json',
-    'legacy.json',
-    'openbmc-dbus.json',
-    'ibm.json',
-    'intel.json',
-    'mctp.json',
-    'pid.json',
-    'pid_zone.json',
-    'stepwise.json',
-    'virtual_sensor.json',
-    'satellite_controller.json',
-    'leak_detector.json',
-    'firmware.json',
-]
+# this creates the 'schemas' variable
+subdir('schemas')
 
 foreach s : schemas
     install_data(
diff --git a/schemas/meson.build b/schemas/meson.build
new file mode 100644
index 0000000..647024f
--- /dev/null
+++ b/schemas/meson.build
@@ -0,0 +1,21 @@
+# This file is auto-generated. Do not edit manually.
+# File content generated with generate_schema_list.sh
+schemas = [
+    'cpld.json',
+    'exposes_record.json',
+    'firmware.json',
+    'global.json',
+    'gpio_presence.json',
+    'ibm.json',
+    'intel.json',
+    'leak_detector.json',
+    'legacy.json',
+    'mctp.json',
+    'nvidia.json',
+    'openbmc-dbus.json',
+    'pid.json',
+    'pid_zone.json',
+    'satellite_controller.json',
+    'stepwise.json',
+    'virtual_sensor.json',
+]
diff --git a/scripts/generate_config_list.sh b/scripts/generate_config_list.sh
index 267e872..5545943 100755
--- a/scripts/generate_config_list.sh
+++ b/scripts/generate_config_list.sh
@@ -1,21 +1,7 @@
 #!/bin/sh
 
 set -eu
-LANG=C
 
-json_files=$(cd configurations; find . -iname "*.json" | sort | sed 's|^\./||')
+self=$(basename "$0")
 
-MESON_FILE=configurations/meson.build
-
-SELF=$(basename "$0")
-
-# Generate the Meson file
-{
-    echo "# This file is auto-generated. Do not edit manually."
-    echo "# File content generated with ${SELF}."
-    echo "configs = ["
-    for file in $json_files; do
-        echo "    '${file}',"
-    done
-    echo "]"
-} > "$MESON_FILE"
+./scripts/generate_meson_array.sh configurations configs "${self}"
diff --git a/scripts/generate_meson_array.sh b/scripts/generate_meson_array.sh
new file mode 100755
index 0000000..39d3127
--- /dev/null
+++ b/scripts/generate_meson_array.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -eu
+LANG=C
+
+if [ "$#" -ne 3 ]; then
+    echo "Usage: $0 <directory> <meson_array_name> <script_name>" >&2
+    exit 1
+fi
+
+dir="$1"
+array_name="$2"
+script_name="$3"
+meson_file="${dir}/meson.build"
+
+json_files=$(cd "$dir"; find . -regex "[\./]?[\/a-zA-Z0-9_\-]+.json" | sort | sed 's|^\./||')
+
+{
+    echo "# This file is auto-generated. Do not edit manually."
+    echo "# File content generated with ${script_name}"
+    echo "${array_name} = ["
+    for file in $json_files; do
+        echo "    '${file}',"
+    done
+    echo "]"
+} > "$meson_file"
+
diff --git a/scripts/generate_schema_list.sh b/scripts/generate_schema_list.sh
new file mode 100755
index 0000000..b319cde
--- /dev/null
+++ b/scripts/generate_schema_list.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -eu
+
+self=$(basename "$0")
+
+./scripts/generate_meson_array.sh schemas schemas "${self}"
diff --git a/scripts/run-ci.sh b/scripts/run-ci.sh
index 9364a97..583a732 100755
--- a/scripts/run-ci.sh
+++ b/scripts/run-ci.sh
@@ -4,6 +4,9 @@
 
 scripts/validate_configs.py -v -k -e test/expected-schema-errors.txt
 
-# fail the script if someone forgot to update the list of configurations
+# fail the script if someone forgot to update the list of configurations or
+# schemas
+
 scripts/generate_config_list.sh
+scripts/generate_schema_list.sh
 git --no-pager diff --exit-code -- .