Переглянути джерело

HPCC-17590 ecl run has problems on "make install" system

Use common function for locating eclcc with the ecl-bundle program.

eclccserver has slightly different needs so I did not common that up, but I
did fix a case that was not checking pipe return value.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 8 роки тому
батько
коміт
09e69c0807

+ 4 - 22
ecl/ecl-bundle/ecl-bundle.cpp

@@ -125,24 +125,6 @@ unsigned doPipeCommand(StringBuffer &output, const char *cmd, const char *args,
     return ret;
 }
 
-static const char *queryEclccPath()
-{
-    if (!eclccpath.length())
-    {
-        const char *envpath = getenv("ECLCC_PATH");
-        if (envpath)
-            eclccpath.append(envpath);
-        else
-        {
-            splitDirTail(queryCurrentProcessPath(), eclccpath);
-            eclccpath.append("eclcc");
-        }
-        if (optVerbose)
-            printf("Using eclcc path %s\n", eclccpath.str());
-    }
-    return eclccpath.str();
-}
-
 static bool platformVersionDone = false;
 static StringBuffer platformVersion;
 
@@ -151,7 +133,7 @@ static const char *queryPlatformVersion()
     if (!platformVersionDone)
     {
         StringBuffer output;
-        doPipeCommand(output, queryEclccPath(), "--nologfile --version", NULL);
+        doPipeCommand(output, queryEclccPath(optVerbose), "--nologfile --version", NULL);
         RegExpr re("_[0-9]+[.][0-9]+[.][0-9]+");
         const char *found = re.find(output);
         if (!found)
@@ -414,7 +396,7 @@ public:
                                     " [ (UTF8) COUNT(b.authors) ] + B.authors + "
                                     " [ (UTF8) COUNT(B.dependsOn) ] + B.dependsOn + "
                                     " [ (UTF8) #IFDEFINED(B.platformVersion, '')]", bundleName.str());
-            if (doPipeCommand(output, queryEclccPath(), eclOpts.str(), bundleCmd) > 0)
+            if (doPipeCommand(output, queryEclccPath(optVerbose), eclOpts.str(), bundleCmd) > 0)
             {
                 if (optVerbose)
                     printf("eclcc reported:\n%s", output.str());
@@ -549,7 +531,7 @@ public:
                                 "#END\n"
                 , cleanName.str());
         StringBuffer output;
-        if (doPipeCommand(output, queryEclccPath(), eclOpts.str(), bundleCmd) > 0)
+        if (doPipeCommand(output, queryEclccPath(optVerbose), eclOpts.str(), bundleCmd) > 0)
         {
             printf("%s\n", output.str());
             printf("%s selftests cannot be compiled\n", cleanName.str());
@@ -1044,7 +1026,7 @@ protected:
     void getCompilerPaths()
     {
         StringBuffer output;
-        unsigned retCode = doPipeCommand(output, queryEclccPath(), "--nologfile -showpaths", NULL);
+        unsigned retCode = doPipeCommand(output, queryEclccPath(optVerbose), "--nologfile -showpaths", NULL);
         if (retCode == START_FAILURE)
             throw makeStringExceptionV(0, "FATAL: Could not locate eclcc command");
         extractValueFromEnvOutput(bundlePath, output, ECLCC_ECLBUNDLE_PATH);

+ 14 - 8
ecl/eclccserver/eclccserver.cpp

@@ -379,7 +379,8 @@ class EclccCompileThread : implements IPooledThread, implements IErrorReporter,
             Owned<ErrorReader> errorReader = new ErrorReader(pipe, this);
             Owned<AbortWaiter> abortWaiter = new AbortWaiter(pipe, workunit);
             eclccCmd.insert(0, eclccProgName);
-            pipe->run(eclccProgName, eclccCmd, ".", true, false, true, 0, true);
+            if (!pipe->run(eclccProgName, eclccCmd, ".", true, false, true, 0, true))
+                throw makeStringExceptionV(999, "Failed to run eclcc command %s", eclccCmd.str());
             errorReader->start();
             abortWaiter->start();
             try
@@ -584,13 +585,18 @@ static void generatePrecompiledHeader()
     {
         Owned<IPipeProcess> pipe = createPipeProcess();
         Owned<ErrorReader> errorReader = new ErrorReader(pipe, NULL);
-        pipe->run("eclcc", "eclcc -pch", ".", false, false, true, 0);
-        errorReader->start();
-        unsigned retcode = pipe->wait();
-        errorReader->join();
-        if (retcode != 0 || errorReader->errCount() != 0)
-            throw MakeStringException(0, "eclcc -pch failed");
-        DBGLOG("Created precompiled header");
+        StringBuffer cmd;
+        splitDirTail(queryCurrentProcessPath(), cmd);
+        cmd.append("eclcc -pch");
+        if (pipe->run("eclcc", cmd, ".", false, false, true, 0))
+        {
+            errorReader->start();
+            unsigned retcode = pipe->wait();
+            errorReader->join();
+            if (retcode != 0 || errorReader->errCount() != 0)
+                throw MakeStringException(0, "eclcc -pch failed");
+            DBGLOG("Created precompiled header");
+        }
     }
     catch (IException * e)
     {

+ 28 - 3
ecl/eclcmd/eclcmd_common.cpp

@@ -27,6 +27,27 @@
 
 #include "eclcmd_common.hpp"
 
+StringBuffer eclccpath;
+
+const char *queryEclccPath(bool optVerbose)
+{
+    if (!eclccpath.length())
+    {
+        const char *envpath = getenv("ECLCC_PATH");
+        if (envpath)
+            eclccpath.append(envpath);
+        else
+        {
+            splitDirTail(queryCurrentProcessPath(), eclccpath);
+            eclccpath.append("eclcc");
+        }
+        if (optVerbose)
+            printf("Using eclcc path %s\n", eclccpath.str());
+    }
+    return eclccpath.str();
+}
+
+
 int outputMultiExceptionsEx(const IMultiException &me)
 {
     if (!me.ordinality())
@@ -429,7 +450,8 @@ public:
 
     void buildCmd(StringBuffer &cmdLine)
     {
-        cmdLine.set("eclcc -E");
+        cmdLine.set(queryEclccPath(cmd.optVerbose));
+        cmdLine.append(" -E");
         if (cmd.optLegacy)
             cmdLine.append(" -legacy");
         if (cmd.optDebug)
@@ -492,8 +514,11 @@ public:
 
         Owned<IPipeProcess> pipe = createPipeProcess();
         bool hasInput = streq(cmd.optObj.value.str(), "stdin");
-        pipe->run(cmd.optVerbose ? "EXEC" : NULL, cmdLine.str(), NULL, hasInput, true, true);
-
+        if (!pipe->run(cmd.optVerbose ? "EXEC" : NULL, cmdLine.str(), NULL, hasInput, true, true))
+        {
+            fprintf(stderr, "Failed to run eclcc command %s\n", cmdLine.str());
+            return false;
+        }
         StringBuffer errors;
         Owned<EclCmdErrorReader> errorReader = new EclCmdErrorReader(pipe, errors);
         errorReader->start();

+ 2 - 0
ecl/eclcmd/eclcmd_common.hpp

@@ -173,6 +173,8 @@ typedef IEclCommand *(*EclCommandFactory)(const char *cmdname);
 #define ECLOPT_VERBOSE "--verbose"
 #define ECLOPT_VERBOSE_S "-v"
 
+const char *queryEclccPath(bool optVerbose);
+
 bool isValidMemoryValue(const char *value);
 bool isValidPriorityValue(const char *value);