2008-05-30 06:17:29 +00:00
|
|
|
//===--- Action.h - The LLVM Compiler Driver --------------------*- C++ -*-===//
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open
|
|
|
|
// Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-05-06 16:34:12 +00:00
|
|
|
// Action - encapsulates a single shell command.
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_ACTION_H
|
|
|
|
#define LLVM_INCLUDE_COMPILER_DRIVER_ACTION_H
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-06 16:34:12 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-06 18:08:59 +00:00
|
|
|
namespace llvmc {
|
|
|
|
|
2008-05-30 06:17:29 +00:00
|
|
|
typedef std::vector<std::string> StrVector;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-07 21:50:19 +00:00
|
|
|
/// Action - A class that encapsulates a single shell command.
|
2008-05-06 16:34:12 +00:00
|
|
|
class Action {
|
2008-05-07 21:50:19 +00:00
|
|
|
/// Command_ - The actual command (for example, 'ls').
|
2008-05-06 16:34:12 +00:00
|
|
|
std::string Command_;
|
2008-05-30 06:10:19 +00:00
|
|
|
/// Args_ - Command arguments. Stdout redirection ("> file") is allowed.
|
2008-05-06 16:34:12 +00:00
|
|
|
std::vector<std::string> Args_;
|
2008-12-07 16:41:11 +00:00
|
|
|
/// StopCompilation_ - Should we stop compilation after executing
|
|
|
|
/// this action?
|
|
|
|
bool StopCompilation_;
|
|
|
|
/// OutFile_ - The output file name.
|
|
|
|
std::string OutFile_;
|
|
|
|
|
2008-05-06 16:34:12 +00:00
|
|
|
public:
|
2010-07-23 03:42:55 +00:00
|
|
|
void Construct (const std::string& C, const StrVector& A,
|
|
|
|
bool S, const std::string& O) {
|
|
|
|
Command_ = C;
|
|
|
|
Args_ = A;
|
|
|
|
StopCompilation_ = S;
|
|
|
|
OutFile_ = O;
|
|
|
|
}
|
|
|
|
bool IsConstructed () { return (Command_.size() != 0);}
|
2008-05-06 16:34:12 +00:00
|
|
|
|
2010-07-27 11:19:36 +00:00
|
|
|
/// Execute - Executes the command. Returns -1 on error.
|
2008-12-07 16:41:11 +00:00
|
|
|
int Execute () const;
|
|
|
|
bool StopCompilation () const { return StopCompilation_; }
|
|
|
|
const std::string& OutFile() { return OutFile_; }
|
2008-05-06 16:34:12 +00:00
|
|
|
};
|
2008-03-23 08:57:20 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#endif // LLVM_INCLUDE_COMPILER_DRIVER_ACTION_H
|