Explorar o código

Pass ecl command line -foptions to eclcc and to deploy workunit

eclcc doesn't seem to use -foptions when creating an archive, but I will
pass them just in case.  Also passing to WUDeploy which does the actual
compilation.

Signed-off-by: Anthony Fishbeck <Anthony.Fishbeck@lexisnexis.com>
Anthony Fishbeck %!s(int64=13) %!d(string=hai) anos
pai
achega
7af16e4936

+ 32 - 1
ecl/eclcmd/eclcmd_common.cpp

@@ -24,7 +24,6 @@
 #include "build-config.h"
 #include "workunit.hpp"
 
-#include "ws_workunits.hpp"
 #include "eclcmd_common.hpp"
 
 void outputMultiExceptions(const IMultiException &me)
@@ -334,6 +333,18 @@ public:
             if (cmd.optObj.value.get())
                 cmdLine.append(" ").append(streq(cmd.optObj.value.get(), "stdin") ? "- " : cmd.optObj.value.get());
         }
+        if (cmd.debugValues.length())
+        {
+            ForEachItemIn(i, cmd.debugValues)
+            {
+                IEspNamedValue &item = cmd.debugValues.item(i);
+                const char *name = item.getName();
+                const char *value = item.getValue();
+                cmdLine.append(" -f").append(name);
+                if (value)
+                    cmdLine.append('=').append(value);
+            }
+        }
         if ((int)cmd.optResultLimit > 0)
         {
             cmdLine.append(" -fapplyInstantEclTransformations=1");
@@ -424,6 +435,24 @@ private:
     };
 };
 
+bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values)
+{
+    const char *arg = iter.query();
+    if (*arg++!='-' || *arg++!=prefix || !*arg)
+        return false;
+    Owned<IEspNamedValue> nv = createNamedValue();
+    const char *eq = strchr(arg, '=');
+    if (!eq)
+        nv->setName(arg);
+    else
+    {
+        StringAttr name(arg, eq - arg);
+        nv->setName(name.get());
+        nv->setValue(eq+1);
+    }
+    values.append(*nv.getClear());
+    return true;
+}
 eclCmdOptionMatchIndicator EclCmdWithEclTarget::matchCommandLineOption(ArgvIterator &iter, bool finalAttempt)
 {
     const char *arg = iter.query();
@@ -449,6 +478,8 @@ eclCmdOptionMatchIndicator EclCmdWithEclTarget::matchCommandLineOption(ArgvItera
         optObj.set(arg);
         return EclCmdOptionMatch;
     }
+    if (matchVariableOption(iter, 'f', debugValues))
+        return EclCmdOptionMatch;
     if (iter.matchPathFlag(optLibPath, ECLOPT_LIB_PATH_S))
         return EclCmdOptionMatch;
     if (iter.matchPathFlag(optImpPath, ECLOPT_IMP_PATH_S))

+ 6 - 0
ecl/eclcmd/eclcmd_common.hpp

@@ -19,6 +19,8 @@
 #ifndef ECLCMD_COMMON_HPP
 #define ECLCMD_COMMON_HPP
 
+#include "ws_workunits.hpp"
+
 //=========================================================================================
 
 interface IEclCommand : extends IInterface
@@ -98,6 +100,8 @@ 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);
+
 enum eclObjParameterType
 {
     eclObjTypeUnknown = 0x00,
@@ -186,6 +190,7 @@ public:
             "   --main=<definition>    definition to use from legacy ECL repository\n"
             "   --ecl-only             send ecl text to hpcc without generating archive\n"
             "   --limit=<limit>        sets the result limit for the query, defaults to 100\n"
+            "   -f<option>[=value]     set an ECL option (equivalent to #option)\n"
             " eclcc options:\n"
             "   -Ipath                 Add path to locations to search for ecl imports\n"
             "   -Lpath                 Add path to locations to search for system libraries\n"
@@ -198,6 +203,7 @@ public:
     StringBuffer optImpPath;
     StringAttr optManifest;
     StringAttr optAttributePath;
+    IArrayOf<IEspNamedValue> debugValues;
     unsigned optResultLimit;
     bool optNoArchive;
 };

+ 5 - 23
ecl/eclcmd/eclcmd_core.cpp

@@ -180,6 +180,11 @@ bool doDeploy(EclCmdWithEclTarget &cmd, IClientWsWorkunits *client, const char *
     req->setFileName(cmd.optObj.value.sget());
     if ((int)cmd.optResultLimit > 0)
         req->setResultLimit(cmd.optResultLimit);
+    if (cmd.debugValues.length())
+    {
+        req->setDebugValues(cmd.debugValues);
+        cmd.debugValues.kill();
+    }
 
     Owned<IClientWUDeployWorkunitResponse> resp = client->WUDeployWorkunit(req);
     if (resp->getExceptions().ordinality())
@@ -455,25 +460,6 @@ private:
     bool activateSet;
 };
 
-bool matchVariableOption(ArgvIterator &iter, const char prefix, IArrayOf<IEspNamedValue> &values)
-{
-    const char *arg = iter.query();
-    if (*arg++!='-' || *arg++!=prefix || !*arg)
-        return false;
-    Owned<IEspNamedValue> nv = createNamedValue();
-    const char *eq = strchr(arg, '=');
-    if (!eq)
-        nv->setName(arg);
-    else
-    {
-        StringAttr name(arg, eq - arg);
-        nv->setName(name.get());
-        nv->setValue(eq+1);
-    }
-    values.append(*nv.getClear());
-    return true;
-}
-
 class EclCmdRun : public EclCmdWithEclTarget
 {
 public:
@@ -491,8 +477,6 @@ public:
 
         for (; !iter.done(); iter.next())
         {
-            if (matchVariableOption(iter, 'f', debugValues))
-                continue;
             if (matchVariableOption(iter, 'X', variables))
                 continue;
             if (iter.matchOption(optObj.value, ECLOPT_WUID)||iter.matchOption(optObj.value, ECLOPT_WUID_S))
@@ -636,7 +620,6 @@ public:
             "                          (defaults to cluster defined inside workunit)\n"
             "   -n, --name=<val>       job name\n"
             "   -in,--input=<file|xml> file or xml content to use as query input\n"
-            "   -f<option>[=value]     set an ECL option (equivalent to #option)\n"
             "   -X<name>=<value>       sets the stored input value (stored('name'))\n"
             "   --wait=<ms>            time to wait for completion\n",
             stdout);
@@ -647,7 +630,6 @@ private:
     StringAttr optName;
     StringAttr optInput;
     IArrayOf<IEspNamedValue> variables;
-    IArrayOf<IEspNamedValue> debugValues;
     unsigned optWaitTime;
     bool optNoRoot;
 };

+ 1 - 0
esp/scm/ws_workunits.ecm

@@ -296,6 +296,7 @@ ESPrequest [nil_remove] WUDeployWorkunitRequest
     string FileName;
     binary Object;
     int ResultLimit;
+    ESParray<ESPstruct NamedValue> DebugValues;
 };
 
 ESPresponse [exceptions_inline] WUDeployWorkunitResponse

+ 1 - 1
esp/services/ws_workunits/ws_workunitsService.cpp

@@ -3505,7 +3505,7 @@ void deployEclOrArchive(IEspContext &context, IEspWUDeployWorkunitRequest & req,
     wu->commit();
     wu.clear();
 
-    submitWsWorkunit(context, wuid.str(), req.getCluster(), NULL, 0, true, false);
+    submitWsWorkunit(context, wuid.str(), req.getCluster(), NULL, 0, true, false, NULL, NULL, &req.getDebugValues());
     waitForWorkUnitToCompile(wuid.str(), req.getWait());
 
     WsWuInfo winfo(context, wuid.str());