1#!/bin/bash -e 2 3echo "Running \"make fortranbindings\" on previous and current commit to determine differences" 4repo_root="$(git rev-parse --show-toplevel)" 5TMPDIR=$(mktemp -d) 6before=$(git rev-parse HEAD~1) 7after=$(git rev-parse HEAD) 8 9extract_subroutines() { 10 find "$1" -type f \( -name '*.F' -o -name '*.h90' -o -name '*.f' -o -name '*.f90' \) \ 11 -exec grep -hiE '^[[:space:]]*subroutine[[:space:]]+[A-Za-z0-9_]+' {} + | \ 12 awk '{for(i=1;i<=NF;i++) if($i=="subroutine") print $(i+1)}' | sort | uniq 13} 14 15for rev in $before $after; do 16 git worktree add -f "$TMPDIR/wt_$rev" "$rev" 17 ( 18 cd "$TMPDIR/wt_$rev" 19 export PETSC_DIR="$TMPDIR/wt_$rev" 20 ./configure --with-fortran-bindings=1 21 petsc_arch=$(find . -maxdepth 1 -type d -name 'arch-*' | head -n1 | sed 's|^\./||') 22 # make PETSC_DIR="$TMPDIR/wt_$rev" PETSC_ARCH="$petsc_arch" all check 23 cp -r "$petsc_arch/ftn" "$TMPDIR/$rev" 24 ) 25 git worktree remove --force "$TMPDIR/wt_$rev" 26done 27 28DIFF_FILE="fortran_bindings_diff.txt" 29diff -ru "$TMPDIR/$before" "$TMPDIR/$after" > "$DIFF_FILE" || true 30count_before=$(extract_subroutines "$TMPDIR/$before" | wc -l) 31count_after=$(extract_subroutines "$TMPDIR/$after" | wc -l) 32echo "Before ($before): $count_before Fortran stubs" 33echo "After ($after): $count_after Fortran stubs" 34echo "Full diff saved in $DIFF_FILE" 35