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
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2008-05-06 16:34:12 +00:00
|
|
|
#ifndef LLVM_TOOLS_LLVMC2_TOOL_H
|
|
|
|
#define LLVM_TOOLS_LLVMC2_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"
|
2008-03-23 08:57:20 +00:00
|
|
|
#include "llvm/System/Path.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
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;
|
2008-03-23 08:57:20 +00:00
|
|
|
typedef std::vector<llvm::sys::Path> PathVector;
|
2008-05-30 06:11:18 +00:00
|
|
|
typedef llvm::StringSet<> InputLanguagesSet;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
2008-05-07 21:50:19 +00:00
|
|
|
/// Tool - A class
|
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() {}
|
|
|
|
|
|
|
|
virtual Action GenerateAction (const PathVector& inFiles,
|
2008-12-07 16:41:11 +00:00
|
|
|
bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
2008-09-22 20:47:46 +00:00
|
|
|
const InputLanguagesSet& InLangs,
|
|
|
|
const LanguageMap& LangMap) const = 0;
|
2008-05-06 17:26:53 +00:00
|
|
|
|
|
|
|
virtual Action GenerateAction (const llvm::sys::Path& inFile,
|
2008-12-07 16:41:11 +00:00
|
|
|
bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
2008-09-22 20:47:46 +00:00
|
|
|
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;
|
|
|
|
virtual const char* OutputLanguage() const = 0;
|
2008-03-23 08:57:20 +00:00
|
|
|
|
|
|
|
virtual bool IsJoin() 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;
|
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
|
|
|
|
2008-12-07 16:41:11 +00:00
|
|
|
Action GenerateAction(bool HasChildren,
|
|
|
|
const llvm::sys::Path& TempDir,
|
2008-09-22 20:47:46 +00:00
|
|
|
const InputLanguagesSet& InLangs,
|
|
|
|
const LanguageMap& LangMap) const {
|
2008-12-07 16:41:11 +00:00
|
|
|
return GenerateAction(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
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:34:12 +00:00
|
|
|
#endif //LLVM_TOOLS_LLVMC2_TOOL_H
|