blob: 03dc1d14b4a60653be1fd9948fe7ed81b2540660 [file] [log] [blame]
//===-- Command.h ---------------------------------------------------------===//
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Defines the Command class (helper for driver functionality).
#include <string>
#include "llvm/ADT/SmallVector.h"
#include "llvm/Option/ArgList.h"
namespace llvm {
class raw_ostream;
namespace gollvm {
namespace driver {
class Command;
class Action;
class Tool;
// A CommandList contains pointers to Command objects owned by a Compilation.
typedef llvm::SmallVector<Command*, 3> CommandList;
// A Command is a container for the specific command line to be used
// for invoking an external tool to carry out an Action (a specific
// compilation step (for example, the exact set of strings needed to
// exec the assembler). Commands are created by Tools; Commands are
// stored in and owned by a Compilation.
class Command {
Command(const Action &srcAction,
const Tool &creator,
const char *executable,
llvm::opt::ArgStringList &args);
// Execute the command. Returns 0 on success, non-zero on error.
int execute(std::string *errMsg);
// Print to string
void print(llvm::raw_ostream &OS, bool quoteArgs);
// Print for debugging
void dbgPrint();
const Action &action_;
const Tool &creator_;
const char *executable_;
llvm::opt::ArgStringList arguments_;
} // end namespace driver
} // end namespace gollvm