1 //===--- Core.h - The LLVM Compiler Driver ----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Core driver abstractions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TOOLS_LLVMCC_CORE_H
15 #define LLVM_TOOLS_LLVMCC_CORE_H
19 #include "llvm/ADT/IntrusiveRefCntPtr.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/System/Path.h"
31 typedef std::vector<llvm::sys::Path> PathVector;
32 typedef llvm::StringMap<std::string> LanguageMap;
36 std::vector<std::string> Args_;
38 Action (std::string const& C,
39 std::vector<std::string> const& A)
40 : Command_(C), Args_(A)
46 class Tool : public llvm::RefCountedBaseVPTR<Tool> {
48 virtual Action GenerateAction (PathVector const& inFiles,
49 llvm::sys::Path const& outFile) const = 0;
51 virtual Action GenerateAction (llvm::sys::Path const& inFile,
52 llvm::sys::Path const& outFile) const = 0;
54 virtual std::string Name() const = 0;
55 virtual std::string InputLanguage() const = 0;
56 virtual std::string OutputLanguage() const = 0;
57 virtual std::string OutputSuffix() const = 0;
59 virtual bool IsLast() const = 0;
60 virtual bool IsJoin() const = 0;
62 // Helper function that is called by the auto-generated code
63 // Splits strings of the form ",-foo,-bar,-baz"
64 // TOFIX: find a better name
65 void UnpackValues (std::string const& from,
66 std::vector<std::string>& to) const;
72 typedef std::vector<llvm::IntrusiveRefCntPtr<Tool> > ToolChain;
73 typedef llvm::StringMap<ToolChain> ToolChainMap;
75 struct CompilationGraph {
76 ToolChainMap ToolChains;
77 LanguageMap ExtsToLangs;
79 int Build(llvm::sys::Path const& tempDir) const;
83 #endif // LLVM_TOOLS_LLVMCC_CORE_H