mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 10:17:45 +08:00
tools: update uorb graphs script
more debug tools Signed-off-by: Ramon Roche <mrpollo@gmail.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# create uorb graphs and move to docs
|
||||||
|
make uorb_graphs
|
||||||
|
cp Tools/uorb_graph/*.json docs/public/middleware/
|
||||||
|
# create failsafe sim
|
||||||
|
# uorb message docs
|
||||||
|
# parameter metadata
|
||||||
|
# airframe reference
|
||||||
|
# module docs
|
||||||
@@ -3,25 +3,21 @@
|
|||||||
# update_uorb_graphs.sh — generate, compare, and sync uORB graph JSONs
|
# update_uorb_graphs.sh — generate, compare, and sync uORB graph JSONs
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./scripts/update_uorb_graphs.sh [--test-only] [--debug]
|
# ./scripts/update_uorb_graphs.sh [--test-only] [--debug]
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# --test-only Run generation and comparison only; exit 1 if diffs found, without copying files
|
# --test-only Run generation and comparison only; exit 1 if diffs found, without copying files
|
||||||
# --debug Echo debug info for missing or differing files
|
# --debug Echo debug info for missing or differing files and show full make output
|
||||||
#
|
#
|
||||||
# Examples:
|
# Examples:
|
||||||
# # CI mode: fail if docs need updates
|
# # CI mode: fail if docs need updates
|
||||||
# ./scripts/update_uorb_graphs.sh --test-only
|
# ./scripts/update_uorb_graphs.sh --test-only
|
||||||
#
|
#
|
||||||
# # Developer mode: regenerate and sync JSONs
|
# # Developer mode: regenerate and sync JSONs
|
||||||
# ./scripts/update_uorb_graphs.sh
|
# ./scripts/update_uorb_graphs.sh
|
||||||
#
|
#
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Usage:
|
|
||||||
# ./scripts/update_uorb_graphs.sh [--test-only] [--debug]
|
|
||||||
|
|
||||||
# Enable nullglob so patterns with no matches expand to empty list
|
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
|
|
||||||
# Parse flags
|
# Parse flags
|
||||||
@@ -48,9 +44,14 @@ done
|
|||||||
graph_dir="Tools/uorb_graph"
|
graph_dir="Tools/uorb_graph"
|
||||||
dest_dir="docs/public/middleware"
|
dest_dir="docs/public/middleware"
|
||||||
|
|
||||||
# Generate
|
# Generate uORB graphs (conditionally silent)
|
||||||
echo "🔧 Generating uORB message graphs"
|
if [ "$debug" = true ]; then
|
||||||
make uorb_graphs > /dev/null 2>&1
|
echo "🔧 Generating uORB message graphs (verbose output)"
|
||||||
|
make uorb_graphs
|
||||||
|
else
|
||||||
|
echo "🔧 Generating uORB message graphs"
|
||||||
|
make uorb_graphs > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
# Verify generation
|
# Verify generation
|
||||||
src_files=("$graph_dir"/*.json)
|
src_files=("$graph_dir"/*.json)
|
||||||
@@ -59,33 +60,24 @@ if [ ${#src_files[@]} -eq 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare dest
|
|
||||||
echo "🔍 Checking for updated uORB graph JSONs"
|
echo "🔍 Checking for updated uORB graph JSONs"
|
||||||
mkdir -p "$dest_dir"
|
mkdir -p "$dest_dir"
|
||||||
|
|
||||||
changed=()
|
changed=()
|
||||||
# Compare each generated file
|
|
||||||
for src in "${src_files[@]}"; do
|
for src in "${src_files[@]}"; do
|
||||||
name=$(basename "$src")
|
name=$(basename "$src")
|
||||||
dst="$dest_dir/$name"
|
dst="$dest_dir/$name"
|
||||||
|
|
||||||
# missing file
|
|
||||||
if [[ ! -f "$dst" ]]; then
|
if [[ ! -f "$dst" ]]; then
|
||||||
if [ "$debug" = true ]; then
|
[ "$debug" = true ] && echo "DEBUG: $dst missing"
|
||||||
echo "DEBUG: $dst missing"
|
|
||||||
fi
|
|
||||||
changed+=("$name")
|
changed+=("$name")
|
||||||
|
|
||||||
# content differs
|
|
||||||
elif ! cmp -s "$src" "$dst"; then
|
elif ! cmp -s "$src" "$dst"; then
|
||||||
if [ "$debug" = true ]; then
|
[ "$debug" = true ] && echo "DEBUG: cmp -s '$src' '$dst'; echo \$?"
|
||||||
echo "DEBUG: cmp -s '$src' '$dst'; echo \$?"
|
|
||||||
fi
|
|
||||||
changed+=("$name")
|
changed+=("$name")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# No changes? All good.
|
|
||||||
if [ ${#changed[@]} -eq 0 ]; then
|
if [ ${#changed[@]} -eq 0 ]; then
|
||||||
echo "✅ All uORB graph JSONs are already in sync."
|
echo "✅ All uORB graph JSONs are already in sync."
|
||||||
exit 0
|
exit 0
|
||||||
@@ -96,25 +88,19 @@ for name in "${changed[@]}"; do
|
|||||||
echo " - $name"
|
echo " - $name"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Test-only mode: list and exit
|
|
||||||
if [ "$test_only" = true ]; then
|
if [ "$test_only" = true ]; then
|
||||||
echo
|
echo
|
||||||
echo "🚨 uORB graph docs need updating! Rerun without --test-only to apply changes."
|
echo "🚨 uORB graph docs need updating! Rerun without --test-only to apply changes."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy updated files and prompt commit
|
|
||||||
# Note: ensure debug/test flags don't affect copying
|
|
||||||
echo
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "📂 Copying updated files over"
|
echo "📂 Copying updated files over"
|
||||||
for name in "${changed[@]}"; do
|
for name in "${changed[@]}"; do
|
||||||
cp -v "$graph_dir/$name" "$dest_dir/$name"
|
cp -v "$graph_dir/$name" "$dest_dir/$name"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
echo "🚨 uORB graph docs need updating! Review above, then run:"
|
echo "🚨 uORB graph docs need updating! Review above, then run:"
|
||||||
echo " git status -s $dest_dir/"
|
echo " git status -s $dest_dir/"
|
||||||
echo " git add $dest_dir/*.json"
|
echo " git add $dest_dir/*.json"
|
||||||
|
|||||||
Reference in New Issue
Block a user