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