]> git.tdb.fi Git - builder.git/blob - source/externaltask.h
Add support for capturing output in ExternalTask
[builder.git] / source / externaltask.h
1 #ifndef EXTERNALTASK_H_
2 #define EXTERNALTASK_H_
3
4 #include <string>
5 #include <vector>
6 #include <msp/fs/path.h>
7 #include <msp/io/pipe.h>
8 #include "task.h"
9
10 class ExternalTask: public Task
11 {
12 public:
13         enum Destination
14         {
15                 PASSTHROUGH,
16                 CAPTURE,
17                 IGNORE
18         };
19
20 private:
21         std::vector<std::string> argv;
22         Msp::FS::Path work_dir;
23         int pid;
24         int exit_code;
25         Destination stdout_dest;
26         Destination stderr_dest;
27         Msp::IO::Pipe *capture_pipe;
28         std::string output;
29
30 public:
31         ExternalTask(const std::vector<std::string> &, const Msp::FS::Path &);
32         virtual ~ExternalTask();
33
34         virtual std::string get_command() const;
35         virtual void start();
36         virtual Status check();
37
38         void set_stdout(Destination);
39         void set_stderr(Destination);
40         const std::string &get_output() const { return output; }
41 };
42
43 #endif