ENH: add hook for bear frontend to create json output (#1936)

Example usage,

   wmake -with-bear src/OpenFOAM
   src/Allwmake -with-bear -s -j

- bin/tools/vscode-settings

  Emit some json content suitable for setting up Visual Studio Code
  for use with OpenFOAM.

  For example,
      bin/tools/vscode-settings > .vscode/settings.json

Ideas from Volker Weissman
This commit is contained in:
Mark Olesen
2020-11-25 16:50:33 +01:00
parent fb7afd5f96
commit a50047bbcc
4 changed files with 336 additions and 7 deletions

View File

@ -38,6 +38,13 @@
# -l | -log | -log=FILE
# -prefix=... same as -module-prefix=...
#
# Trapped options
# -with-bear
#
# Note
# Locally handled options (eg, -log) must preceeded trapped options
# such as -with-bear. This is non-intuitive, but not easily fixed.
#
#------------------------------------------------------------------------------
# Check environment
[ -d "$WM_PROJECT_DIR" ] || {
@ -80,6 +87,7 @@ USAGE
#------------------------------------------------------------------------------
unset optDebug optLog optNonRecursive optPrefix optQueue
unset optWmakeFrontend
for arg in "$@"
do
@ -91,6 +99,12 @@ do
usage
;;
-with-bear)
# Everything wrapped via 'bear'
optWmakeFrontend="-with-bear"
break # Stop now, continue with wmake
;;
-no-recurs* | -fromWmake)
# Avoid recursion (eg, if called from wmake)
optNonRecursive=true
@ -183,12 +197,14 @@ if [ -z "$optNonRecursive" ]
then
if [ -z "$optLog" ]
then
exec wmake -all $optDebug $optQueue $*
exec wmake $optWmakeFrontend -all \
$optDebug $optQueue $*
exit $? # Unneeded, but just in case something went wrong
else
echo "Logging wmake -all output to '$optLog'" 1>&2
echo 1>&2
exec wmake -all $optDebug $optQueue $* 2>&1 | /usr/bin/tee $optLog
exec wmake $optWmakeFrontend -all \
$optDebug $optQueue $* 2>&1 | /usr/bin/tee $optLog
# Need to cleanup after the tee
rc=$? # Error code from tee (not wmake), but not entirely important
echo "Done logging to '$optLog'" 1>&2
@ -211,6 +227,7 @@ fi
# Cleanup local variables and functions
#------------------------------------------------------------------------------
unset optWmakeFrontend
unset optNonRecursive optDebug optLog optPrefix optQueue
unset -f usage