xref: /openbmc/phosphor-dbus-interfaces/gen/regenerate-meson (revision 0e78828ce927548b4dd679e06fdaf2f294983289)
1#!/bin/bash
2
3REPO_ROOT=$(git rev-parse --show-toplevel)
4
5# Find sdbus++-gen-meson
6#   1. Check $SDBUSPP_GEN_MESON
7#   2. Check in $PATH
8#   3. Check in subprojects/sdbusplus
9if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
10    SDBUSPP_GEN_MESON="$(which sdbus++-gen-meson 2> /dev/null)"
11fi
12if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
13    SDBUSPP_GEN_MESON="$REPO_ROOT/subprojects/sdbusplus/tools/sdbus++-gen-meson"
14fi
15if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
16    echo "Cannot find sdbus++-gen-meson ($SDBUSPP_GEN_MESON)."
17    exit 1
18fi
19
20echo "Generating meson files..."
21$SDBUSPP_GEN_MESON \
22    --command meson \
23    --directory "$REPO_ROOT/yaml" \
24    --output "$REPO_ROOT/gen"
25
26echo "Formatting meson files..."
27find "$REPO_ROOT/gen" -name "meson.build" -exec meson format -i {} +
28