|
@@ -26,119 +26,6 @@
|
|
|
#include "eclcmd_common.hpp"
|
|
|
#include "eclcmd_core.hpp"
|
|
|
|
|
|
-class ConvertEclParameterToArchive
|
|
|
-{
|
|
|
-public:
|
|
|
- ConvertEclParameterToArchive(EclCmdWithEclTarget &_cmd) : cmd(_cmd)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- void appendOptPath(StringBuffer &cmdLine, const char opt, const char *path)
|
|
|
- {
|
|
|
- if (!path || !*path)
|
|
|
- return;
|
|
|
- if (*path==';')
|
|
|
- path++;
|
|
|
- cmdLine.append(" -").append(opt).append(path);
|
|
|
- }
|
|
|
-
|
|
|
- void buildCmd(StringBuffer &cmdLine)
|
|
|
- {
|
|
|
- cmdLine.set("eclcc -E");
|
|
|
- appendOptPath(cmdLine, 'I', cmd.optImpPath.str());
|
|
|
- appendOptPath(cmdLine, 'L', cmd.optLibPath.str());
|
|
|
- if (cmd.optManifest.length())
|
|
|
- cmdLine.append(" -manifest ").append(cmd.optManifest.get());
|
|
|
- if (streq(cmd.optObj.value.sget(), "stdin"))
|
|
|
- cmdLine.append(" - ");
|
|
|
- else
|
|
|
- cmdLine.append(" ").append(cmd.optObj.value.get());
|
|
|
- }
|
|
|
-
|
|
|
- bool eclcc(StringBuffer &out)
|
|
|
- {
|
|
|
- StringBuffer cmdLine;
|
|
|
- buildCmd(cmdLine);
|
|
|
-
|
|
|
- Owned<IPipeProcess> pipe = createPipeProcess();
|
|
|
- bool hasInput = streq(cmd.optObj.value.sget(), "stdin");
|
|
|
- pipe->run(cmd.optVerbose ? "EXEC" : NULL, cmdLine.str(), NULL, hasInput, true, true);
|
|
|
-
|
|
|
- StringBuffer errors;
|
|
|
- Owned<EclCmdErrorReader> errorReader = new EclCmdErrorReader(pipe, errors);
|
|
|
- errorReader->start();
|
|
|
-
|
|
|
- if (pipe->hasInput())
|
|
|
- {
|
|
|
- pipe->write(cmd.optObj.mb.length(), cmd.optObj.mb.toByteArray());
|
|
|
- pipe->closeInput();
|
|
|
- }
|
|
|
- if (pipe->hasOutput())
|
|
|
- {
|
|
|
- byte buf[4096];
|
|
|
- loop
|
|
|
- {
|
|
|
- size32_t read = pipe->read(sizeof(buf),buf);
|
|
|
- if (!read)
|
|
|
- break;
|
|
|
- out.append(read, (const char *) buf);
|
|
|
- }
|
|
|
- }
|
|
|
- int retcode = pipe->wait();
|
|
|
- errorReader->join();
|
|
|
-
|
|
|
- if (errors.length())
|
|
|
- fprintf(stderr, "%s\n", errors.str());
|
|
|
-
|
|
|
- return (retcode == 0);
|
|
|
- }
|
|
|
-
|
|
|
- bool process()
|
|
|
- {
|
|
|
- if (cmd.optObj.type!=eclObjSource || cmd.optObj.value.isEmpty())
|
|
|
- return false;
|
|
|
-
|
|
|
- StringBuffer output;
|
|
|
- if (eclcc(output) && output.length() && isArchiveQuery(output.str()))
|
|
|
- {
|
|
|
- cmd.optObj.type = eclObjArchive;
|
|
|
- cmd.optObj.mb.clear().append(output.str());
|
|
|
- return true;
|
|
|
- }
|
|
|
- fprintf(stderr,"\nError creating archive\n");
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
-private:
|
|
|
- EclCmdWithEclTarget &cmd;
|
|
|
-
|
|
|
- class EclCmdErrorReader : public Thread
|
|
|
- {
|
|
|
- public:
|
|
|
- EclCmdErrorReader(IPipeProcess *_pipe, StringBuffer &_errs)
|
|
|
- : Thread("EclToArchive::ErrorReader"), pipe(_pipe), errs(_errs)
|
|
|
- {
|
|
|
- }
|
|
|
-
|
|
|
- virtual int run()
|
|
|
- {
|
|
|
- byte buf[4096];
|
|
|
- loop
|
|
|
- {
|
|
|
- size32_t read = pipe->readError(sizeof(buf), buf);
|
|
|
- if (!read)
|
|
|
- break;
|
|
|
- errs.append(read, (const char *) buf);
|
|
|
- }
|
|
|
- return 0;
|
|
|
- }
|
|
|
- private:
|
|
|
- IPipeProcess *pipe;
|
|
|
- StringBuffer &errs;
|
|
|
- };
|
|
|
-};
|
|
|
-
|
|
|
-
|
|
|
|
|
|
bool doDeploy(EclCmdWithEclTarget &cmd, IClientWsWorkunits *client, const char *cluster, const char *name, StringBuffer *wuid, bool noarchive, bool displayWuid=true)
|
|
|
{
|