Преглед на файлове

HPCC-18308 eclcmd should pass eclcc options as debug values

"ecl run <target> <file> -f-<option>"

Allows arbitrary eclcc options to be passed to the eclcc command line.
Those options should also be passed as workunit debug values formatted
as "eclcc-<option>".

Signed-off-by: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Anthony Fishbeck преди 7 години
родител
ревизия
8e3fb667a3

+ 2 - 1
ecl/eclccserver/eclccserver.cpp

@@ -254,7 +254,8 @@ class EclccCompileThread : implements IPooledThread, implements IErrorReporter,
         {
             //Allow eclcc-xx-<n> so that multiple values can be passed through for the same named debug symbol
             const char * start = option + (*option=='-' ? 1 : 6);
-            const char * dash = strrchr(start, '-');     // position of second dash, if present
+            const char * finger = (*start=='-') ? start+1 : start; //support leading double dash
+            const char * dash = strrchr(finger, '-');     // position of trailing dash, if present
             StringAttr optName;
             if (dash && (dash != start))
                 optName.set(start, dash-start);

+ 14 - 5
ecl/eclcmd/eclcmd_common.cpp

@@ -484,7 +484,10 @@ public:
                 const char *name = item.getName();
                 const char *value = item.getValue();
                 cmdLine.append(' ');
-                if (!name || name[0]!='-')
+
+                if (name && 0==strncmp(name, "eclcc", 5))
+                    name+=5;
+                else
                     cmdLine.append("-f");
                 cmdLine.append(name);
                 if (value)
@@ -619,12 +622,18 @@ void addNamedValue(const char * arg, IArrayOf<IEspNamedValue> &values)
     }
 }
 
-bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values)
+bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values, bool expandEclccOptions)
 {
     const char *arg = iter.query();
     if (*arg++!='-' || *arg++!=prefix || !*arg)
         return false;
-    addNamedValue(arg, values);
+    if (expandEclccOptions && *arg=='-')
+    {
+        VStringBuffer expanded("eclcc%s", arg);
+        addNamedValue(expanded, values);
+    }
+    else
+        addNamedValue(arg, values);
     return true;
 }
 
@@ -669,9 +678,9 @@ eclCmdOptionMatchIndicator EclCmdWithEclTarget::matchCommandLineOption(ArgvItera
             return EclCmdOptionCompletion;
         return EclCmdOptionMatch;
     }
-    if (matchVariableOption(iter, 'f', debugValues))
+    if (matchVariableOption(iter, 'f', debugValues, true))
         return EclCmdOptionMatch;
-    if (matchVariableOption(iter, 'D', definitions))
+    if (matchVariableOption(iter, 'D', definitions, false))
         return EclCmdOptionMatch;
     if (iter.matchPathFlag(optLibPath, ECLOPT_LIB_PATH_S))
         return EclCmdOptionMatch;

+ 1 - 1
ecl/eclcmd/eclcmd_common.hpp

@@ -184,7 +184,7 @@ bool extractEclCmdOption(StringAttr & option, IProperties * globals, const char
 bool extractEclCmdOption(bool & option, IProperties * globals, const char * envName, const char * propertyName, bool defval);
 bool extractEclCmdOption(unsigned & option, IProperties * globals, const char * envName, const char * propertyName, unsigned defval);
 
-bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values);
+bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values, bool expandEclccOptions);
 void addNamedValue(const char * name, const char * value, IArrayOf<IEspNamedValue> &values);
 
 enum eclObjParameterType

+ 1 - 1
ecl/eclcmd/eclcmd_core.cpp

@@ -566,7 +566,7 @@ public:
 
         for (; !iter.done(); iter.next())
         {
-            if (matchVariableOption(iter, 'X', variables))
+            if (matchVariableOption(iter, 'X', variables, false))
                 continue;
             if (iter.matchOption(optObj.value, ECLOPT_WUID)||iter.matchOption(optObj.value, ECLOPT_WUID_S))
                 continue;

+ 4 - 1
esp/services/ws_workunits/ws_workunitsHelpers.cpp

@@ -3118,8 +3118,11 @@ void WsWuHelpers::submitWsWorkunit(IEspContext& context, IConstWorkUnit* cw, con
             IConstNamedValue &item = debugs->item(i);
             const char *name = item.getName();
             const char *value = item.getValue();
-            if (!name || !*name || *name=='-')
+            if (!name || !*name)
                 continue;
+            StringBuffer expanded;
+            if (*name=='-')
+                name=expanded.append("eclcc").append(name).str();
             if (!value)
             {
                 size_t len = strlen(name);

+ 15 - 5
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -557,10 +557,15 @@ bool CWsWorkunitsEx::onWUUpdate(IEspContext &context, IEspWUUpdateRequest &req,
 
         ForEachItemIn(di, req.getDebugValues())
         {
-            IConstDebugValue& item = req.getDebugValues().item(di);
+            IConstDebugValue& item=req.getDebugValues().item(di);
             const char *debugName = item.getName();
-            if (notEmpty(debugName) && *debugName!='-')
-                wu->setDebugValue(item.getName(), item.getValue(), true);
+            if (notEmpty(debugName))
+            {
+                StringBuffer expanded;
+                if (*debugName=='-')
+                    debugName=expanded.append("eclcc").append(debugName).str();
+                wu->setDebugValue(debugName, item.getValue(), true);
+            }
         }
 
         ForEachItemIn(ai, req.getApplicationValues())
@@ -1177,8 +1182,13 @@ bool CWsWorkunitsEx::onWUSyntaxCheckECL(IEspContext &context, IEspWUSyntaxCheckR
         {
             IConstDebugValue& item=req.getDebugValues().item(di);
             const char *debugName = item.getName();
-            if (notEmpty(debugName) && *debugName!='-')
-                wu->setDebugValue(item.getName(), item.getValue(), true);
+            if (notEmpty(debugName))
+            {
+                StringBuffer expanded;
+                if (*debugName=='-')
+                    debugName=expanded.append("eclcc").append(debugName).str();
+                wu->setDebugValue(debugName, item.getValue(), true);
+            }
         }
 
         wu.setQueryText(req.getECL());