From 166abf70ba6e8c1eea04cb7d0300f44ddcf969a2 Mon Sep 17 00:00:00 2001
From: mark <mark@opencfd>
Date: Fri, 9 Dec 2016 14:44:26 +0000
Subject: [PATCH] ENH: provide log option for top-level builds (issue #333)

---
 wmake/scripts/AllwmakeParseArguments | 35 +++++++++++++++++++---------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/wmake/scripts/AllwmakeParseArguments b/wmake/scripts/AllwmakeParseArguments
index c8bb3ccb71..e4abb9aabc 100644
--- a/wmake/scripts/AllwmakeParseArguments
+++ b/wmake/scripts/AllwmakeParseArguments
@@ -46,6 +46,10 @@ Usage: $Script [OPTIONS]
 Executing $Script is equivalent to
 
    wmake -all [OPTIONS]
+
+With these additional options:
+   -l | -log
+
 USAGE
 
     wmake -help
@@ -57,8 +61,7 @@ USAGE
 # Parse the arguments and options
 #------------------------------------------------------------------------------
 
-fromWmake=
-qOpt=
+unset fromWmake optLog optQueue
 
 for arg in "$@"
 do
@@ -70,17 +73,20 @@ do
             usage
             exit 0
             ;;
-        # Check if called from wmake to avoid recusion
         -fromWmake)
-            fromWmake="fromWmake"
+            # If called from wmake (to avoid recursion)
+            fromWmake=true
+            ;;
+        -l | -log)
+            optLog=true
+            continue    # Permanently remove arg
             ;;
-        -q)
-            qOpt="-q"
-            # Permanently remove arg
-            continue
+        -q | -queue)
+            optQueue="-q"
+            continue    # Permanently remove arg
             ;;
-        # Target type
         lib | libo | libso | dep | objects)
+            # Target type
             targetType=$arg
             ;;
     esac
@@ -96,7 +102,13 @@ done
 
 if [ -z "$fromWmake" ]
 then
-    exec wmake -all $qOpt $*
+    if [ -z "$optLog" ]
+    then
+        exec wmake -all $optQueue $*
+    else
+        echo "logging wmake -all output to 'log.Allwmake'" 1>&2
+        exec wmake -all $optQueue $* 2>&1 | tee log.Allwmake
+    fi
 fi
 
 
@@ -114,7 +126,8 @@ fi
 # Cleanup local variables and functions
 #------------------------------------------------------------------------------
 
-unset Script usage fromWmake
+unset Script fromWmake optLog optQueue
+unset -f usage
 
 
 #------------------------------------------------------------------------------
-- 
GitLab