diff --git a/bin/tools/foamGrepExeTargets b/bin/tools/foamGrepExeTargets index 081692305e..a615a87523 100755 --- a/bin/tools/foamGrepExeTargets +++ b/bin/tools/foamGrepExeTargets @@ -6,7 +6,7 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2016 OpenCFD Ltd. +# Copyright (C) 2016-2025 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, distributed under GPL-3.0-or-later. @@ -22,22 +22,25 @@ # Confirm that all available EXE targets have actually been created: # # foamGrepExeTargets > targets-available -# foamGrepExeTargets -appbin > targets-created +# foamGrepExeTargets -bin > targets-created # diff -uw targets-available targets-created # #------------------------------------------------------------------------------ -usage() { - exec 1>&2 - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<&2 + else + echo "No directory: $dir" 1>&2 + continue + fi + + if [ -d "$FOAM_GIT_DIR" ] + then + git grep --cached -H -P '^\s*EXE\s*=' "$dir" 2>/dev/null + else + # Filesystem find (not quite as fast) + for i in $(find "$dir" -name files) + do + grep -H -P '^\s*EXE\s*=' "$i" 2>/dev/null + done + fi +done | sed -ne 's@/Make/files:.*$@@p' | sed -e 's@.*/@@' | sort | uniq # ----------------------------------------------------------------------------- diff --git a/bin/tools/foamGrepLibTargets b/bin/tools/foamGrepLibTargets new file mode 100755 index 0000000000..c2960f647c --- /dev/null +++ b/bin/tools/foamGrepLibTargets @@ -0,0 +1,125 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | www.openfoam.com +# \\/ M anipulation | +#------------------------------------------------------------------------------ +# Copyright (C) 2025 OpenCFD Ltd. +#------------------------------------------------------------------------------ +# License +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. +# +# Script +# foamGrepLibTargets +# +# Description +# List library targets (contain "LIB_LIBS =") +# +#------------------------------------------------------------------------------ +# Locations +FOAM_GIT_DIR="$WM_PROJECT_DIR/.git" + +printHelp() { + cat<&2 + echo + echo "Error encountered:" + while [ "$#" -ge 1 ]; do echo " $1"; shift; done + echo + echo "See '${0##*/} -help' for usage" + echo + exit 1 +} + +#------------------------------------------------------------------------------ +unset locations + +# Parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help* | --help*) + printHelp + ;; + + -app) + locations="$locations applications/solvers applications/utilities" + ;; + + -src) + locations="$locations src" + ;; + + -no-git) + unset FOAM_GIT_DIR + ;; + *) + die "unknown option/argument: '$1'" + ;; + esac + shift +done + +# Check environment variables +[ -d "$WM_PROJECT_DIR" ] || \ + die "Bad or unset environment variable: \$WM_PROJECT_DIR" + +# Fallback to all locations +if [ -z "$locations" ] +then + locations="applications/solvers applications/utilities src" +fi + +set -- $locations + +if [ "$#" -eq 0 ] +then + die "No search locations" +fi + +# Run from top-level directory - otherwise the grep is quite difficult + +cd "$WM_PROJECT_DIR" || die "No project directory: $WM_PROJECT_DIR" + +for dir in "$@" +do + if [ -d "$dir" ] + then + echo "Checking: $dir" 1>&2 + else + echo "No directory: $dir" 1>&2 + continue + fi + + if [ -d "$FOAM_GIT_DIR" ] + then + git grep --cached -H -P '^\s*LIB_LIBS\s*=' "$dir" 2>/dev/null + else + # Filesystem find (not quite as fast) + for i in $(find "$dir" -name options) + do + grep -H -P '^\s*LIB_LIBS\s*=' "$i" 2>/dev/null + done + fi +done | sed -ne 's@/Make/options:.*$@@p' | sort | uniq + +# -----------------------------------------------------------------------------