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