2008-05-30 06:20:54 +00:00
|
|
|
//===--- Tool.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
|
|
|
// Tool abstract base class - an interface to tool descriptions.
|
2008-03-23 08:57:20 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#ifndef LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
|
|
|
|
#define LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-09-22 20:50:40 +00:00
|
|
|
#include "llvm/CompilerDriver/Action.h"
|
2008-03-23 08:57:20 +00:00
|
|
|
|
|
|
|
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
2008-05-30 06:11:18 +00:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/Path.h"
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2010-02-23 09:04:44 +00:00
|
|
|
#include <string>
|
2008-03-23 08:57:20 +00:00
|
|
|
#include <vector>
|
2010-02-23 09:04:44 +00:00
|
|
|
#include <utility>
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-06 18:08:59 +00:00
|
|
|
namespace llvmc {
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-09-22 20:49:34 +00:00
|
|
|
class LanguageMap;
|
2010-02-23 09:04:44 +00:00
|
|
|
typedef std::vector<std::pair<unsigned, std::string> > ArgsVector;
|
2008-03-23 08:57:20 +00:00
|
|
|
typedef std::vector<llvm::sys::Path> PathVector;
|
2010-02-23 09:04:44 +00:00
|
|
|
typedef std::vector<std::string> StrVector;
|
2008-05-30 06:11:18 +00:00
|
|
|
typedef llvm::StringSet<> InputLanguagesSet;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2010-02-23 09:04:28 +00:00
|
|
|
/// Tool - Represents a single tool.
|
2008-03-23 08:57:20 +00:00
|
|
|
class Tool : public llvm::RefCountedBaseVPTR<Tool> {
|
|
|
|
public:
|
|
|
|
|
2008-05-06 17:26:53 +00:00
|
|
|
virtual ~Tool() {}
|
|
|
|
|
2010-07-27 11:19:36 +00:00
|
|
|
/// GenerateAction - Generate an Action given particular command-line
|
|
|
|
/// options. Returns non-zero value on error.
|
2010-07-23 03:42:55 +00:00
|
|
|
virtual int GenerateAction (Action& Out,
|
|
|
|
const PathVector& inFiles,
|
|
|
|
const bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
|
|
|
const InputLanguagesSet& InLangs,
|
|
|
|
const LanguageMap& LangMap) const = 0;
|
|
|
|
|
2010-07-27 11:19:36 +00:00
|
|
|
/// GenerateAction - Generate an Action given particular command-line
|
|
|
|
/// options. Returns non-zero value on error.
|
2010-07-23 03:42:55 +00:00
|
|
|
virtual int GenerateAction (Action& Out,
|
|
|
|
const llvm::sys::Path& inFile,
|
|
|
|
const bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
|
|
|
const InputLanguagesSet& InLangs,
|
|
|
|
const LanguageMap& LangMap) const = 0;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-30 06:24:49 +00:00
|
|
|
virtual const char* Name() const = 0;
|
|
|
|
virtual const char** InputLanguages() const = 0;
|
2010-09-21 14:59:42 +00:00
|
|
|
virtual const char** OutputLanguages() const = 0;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
|
|
|
virtual bool IsJoin() const = 0;
|
2010-02-23 09:04:28 +00:00
|
|
|
virtual bool WorksOnEmpty() const = 0;
|
2008-12-07 16:41:11 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// OutFileName - Generate the output file name.
|
|
|
|
llvm::sys::Path OutFilename(const llvm::sys::Path& In,
|
|
|
|
const llvm::sys::Path& TempDir,
|
|
|
|
bool StopCompilation,
|
|
|
|
const char* OutputSuffix) const;
|
2010-02-23 09:04:44 +00:00
|
|
|
|
|
|
|
StrVector SortArgs(ArgsVector& Args) const;
|
2008-05-06 17:26:53 +00:00
|
|
|
};
|
|
|
|
|
2008-05-07 21:50:19 +00:00
|
|
|
/// JoinTool - A Tool that has an associated input file list.
|
2008-05-06 17:26:53 +00:00
|
|
|
class JoinTool : public Tool {
|
|
|
|
public:
|
2008-05-06 18:07:48 +00:00
|
|
|
void AddToJoinList(const llvm::sys::Path& P) { JoinList_.push_back(P); }
|
|
|
|
void ClearJoinList() { JoinList_.clear(); }
|
|
|
|
bool JoinListEmpty() const { return JoinList_.empty(); }
|
2008-05-06 17:26:53 +00:00
|
|
|
|
2010-07-23 03:42:55 +00:00
|
|
|
int GenerateAction(Action& Out,
|
|
|
|
const bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
|
|
|
const InputLanguagesSet& InLangs,
|
|
|
|
const LanguageMap& LangMap) const {
|
|
|
|
return GenerateAction(Out, JoinList_, HasChildren, TempDir, InLangs,
|
|
|
|
LangMap);
|
2008-05-30 06:10:19 +00:00
|
|
|
}
|
2008-05-06 18:07:48 +00:00
|
|
|
// We shouldn't shadow base class's version of GenerateAction.
|
2008-05-06 17:26:53 +00:00
|
|
|
using Tool::GenerateAction;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-06 17:26:53 +00:00
|
|
|
private:
|
2008-05-06 18:07:48 +00:00
|
|
|
PathVector JoinList_;
|
2008-03-23 08:57:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-02 09:02:28 +00:00
|
|
|
#endif // LLVM_INCLUDE_COMPILER_DRIVER_TOOL_H
|