Pārlūkot izejas kodu

Merge pull request #15644 from ghalliday/ecloptions

HPCC-26947 Add --fetchrepos and --updaterepos to ecl command

Reviewed-By: Anthony Fishbeck <anthony.fishbeck@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 3 gadi atpakaļ
vecāks
revīzija
5909f9a347

+ 4 - 4
ecl/eclcc/eclcc.hpp

@@ -85,12 +85,12 @@ const char * const helpText[] = {
     "!   -brk <n>      Trigger a break point in eclcc after nth allocation",
 #endif
     "!   -Dname=value  Override the definition of a global attribute 'name'",
-    "!   --defaultgitprefix <prefix>  The default prefix used to access git repos when not specified in package.json",
+    "?!  --defaultgitprefix <prefix>  The default prefix used to access git repos when not specified in package.json",
     "!   --deny=all    Disallow use of all named features not specifically allowed using --allow",
     "!   --deny=str    Disallow use of named feature",
     "!   --expand <path> Expand the contents of an archive to a directory",
     "?!  --fastsyntax  Delay expanding functions when parsing.  May speed up processing for some queries",
-    "    --fetchrepos  Automatically download missing repositories associated with dependencies",
+    "?   --fetchrepos  Automatically download missing repositories associated with dependencies",
     "    -help, --help Display this message",
     "    -help -v      Display verbose help message",
     "!   --ignoresimplified Do not use simplified expressions when syntax checking",
@@ -118,13 +118,13 @@ const char * const helpText[] = {
 #endif
     "!   -P <path>     Specify the path of the output files (only with -b option)",
     "!   --prunearchive Do not include plugins and standard library in the archive (defaults on)",
-    "    -R<repo>[#version]=path Resolve repository references in directory 'path'",
+    "?   -R<repo>[#version]=path Resolve repository references in directory 'path'",
     "!   --regeneratecache Force regeneration of cache (overwrite existing cache)",
     "!   -showpaths    Print information about the searchpaths eclcc is using",
     "    -specs file   Read eclcc configuration from specified file",
     "!   -split m:n    Process a subset m of n input files (only with -b option)",
     "!   --tracecache  Add details of whether cache entries are up to date to the log file",
-    "    --updaterepos Automatically update repositories associated with dependencies",
+    "?   --updaterepos Automatically update repositories associated with dependencies",
     "    -v --verbose  Output additional tracing information while compiling",
     "    -wxxxx=level  Set the severity for a particular warning code or category",
     "!                 -wall sets default severity for all warnings",

+ 10 - 0
ecl/eclcmd/eclcmd_common.cpp

@@ -434,6 +434,8 @@ public:
             cmdLine.append(" --nostdinc");
         if (cmd.optDebug)
             cmdLine.append(" -g");
+        ForEachItemIn(i, cmd.extraOptions)
+            cmdLine.append(" ").append(cmd.extraOptions.item(i));
         appendOptPath(cmdLine, 'I', cmd.optImpPath.str());
         appendOptPath(cmdLine, 'L', cmd.optLibPath.str());
         if (cmd.optAttributePath.length())
@@ -685,6 +687,14 @@ eclCmdOptionMatchIndicator EclCmdWithEclTarget::matchCommandLineOption(ArgvItera
         return EclCmdOptionMatch;
     if (iter.matchOption(optTargetCluster, ECLOPT_CLUSTER_DEPRECATED)||iter.matchOption(optTargetCluster, ECLOPT_CLUSTER_DEPRECATED_S))
         return EclCmdOptionMatch;
+    //Process options which should be passed straight through to eclcc
+    StringBuffer temp;
+    if (iter.matchOptionText(temp, ECLOPT_FETCH_REPOS, true, false) || iter.matchOptionText(temp, ECLOPT_UPDATE_REPOS, true, false) ||
+        iter.matchOptionText(temp, ECLOPT_DEFAULT_GIT_PREFIX, false, false) || iter.matchOptionText(temp, ECLOPT_REPO_MAPPING, false, true))
+    {
+        extraOptions.append(temp);
+        return EclCmdOptionMatch;
+    }
     StringAttr target;
     if (iter.matchOption(target, ECLOPT_TARGET)||iter.matchOption(target, ECLOPT_TARGET_S))
     {

+ 6 - 0
ecl/eclcmd/eclcmd_common.hpp

@@ -193,6 +193,11 @@ typedef IEclCommand *(*EclCommandFactory)(const char *cmdname);
 #define ECLOPT_DEBUG_DASH "-g"
 #define ECLOPT_FAST_SYNTAX "--fastsyntax"
 #define ECLOPT_NO_STD_INC "--nostdinc"
+#define ECLOPT_FETCH_REPOS "--fetchrepos"
+#define ECLOPT_UPDATE_REPOS "--updaterepos"
+#define ECLOPT_DEFAULT_GIT_PREFIX "--defaultgitprefix"
+
+#define ECLOPT_REPO_MAPPING "-R"
 
 #define ECLOPT_VERBOSE "--verbose"
 #define ECLOPT_VERBOSE_S "-v"
@@ -355,6 +360,7 @@ public:
     bool optCheckDirty;
     bool optFastSyntax = false;
     bool optNoStdInc = false;
+    StringArray extraOptions;
 };
 
 class EclCmdWithQueryTarget : public EclCmdCommon

+ 40 - 0
system/jlib/jargv.cpp

@@ -218,3 +218,43 @@ bool ArgvIterator::matchPathFlag(StringBuffer & option, const char * name)
 }
 
 
+bool ArgvIterator::matchOptionText(StringBuffer & option, const char * name, bool isBoolFlag, bool isShortOption)
+{
+    const char * arg = query();
+    size_t len = strlen(name);
+    if (memcmp(arg, name, len) != 0)
+        return false;
+
+    switch (arg[len])
+    {
+    case '+':
+    case '-':
+    case '=':
+        option.append(arg);
+        return true;
+    case '\0':
+        break;
+    default:
+        // -Ix or -I x
+        if (isShortOption)
+        {
+            option.append(arg);
+            return true;
+        }
+        return false;
+    }
+
+    //Boolean flags don't check the next argument, options do if there was no =...
+    if (!isBoolFlag)
+    {
+        if (!hasMore(1))
+            return false;
+
+        next();
+        option.append(arg).append(" ").append(query());
+    }
+    else
+        option.append(arg);
+
+    return true;
+}

+ 4 - 1
system/jlib/jargv.hpp

@@ -39,11 +39,14 @@ public:
     }
 
     bool matchFlag(StringAttr & value, const char * name);                  //-Xvalue, -X option
-    bool matchFlag(bool & value, const char * name);                            //-X -X-
+    bool matchFlag(bool & value, const char * name);                        //-X -X-
     bool matchOption(StringAttr & value, const char * name);                //-option[=value], -option value
     bool matchOption(unsigned & value, const char * name);                  //-option[=value], -option value
     bool matchPathFlag(StringBuffer & option, const char * name);           //-Ivalue, -I value
 
+    // Extract the entire option if it matches.  isBoolFlag indicates a boolean option isShortOption for -I etc.
+    bool matchOptionText(StringBuffer & option, const char * name, bool isBoolFlag, bool isShortOption);
+
     inline const char * query() { return cur < argc ? argv[cur] : NULL; }
     inline bool hasMore(int num) { return (cur + num) < argc; }
     inline bool first() { cur = 1; return isValid(); }