1 //===--- Compilation.h - Compilation Task Data Structure --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef CLANG_DRIVER_COMPILATION_H_
11 #define CLANG_DRIVER_COMPILATION_H_
13 #include "clang/Driver/Job.h"
14 #include "clang/Driver/Util.h"
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/SmallVector.h"
31 /// Compilation - A set of tasks to perform for a single driver
34 /// The driver we were created by.
37 /// The default tool chain.
38 ToolChain &DefaultToolChain;
40 /// The original (untranslated) input argument list.
43 /// The list of actions.
46 /// The root list of jobs.
49 /// Cache of translated arguments for a particular tool chain.
50 llvm::DenseMap<const ToolChain*, DerivedArgList*> TCArgs;
52 /// Temporary files which should be removed on exit.
53 ArgStringList TempFiles;
55 /// Result files which should be removed on failure.
56 ArgStringList ResultFiles;
59 Compilation(Driver &D, ToolChain &DefaultToolChain, InputArgList *Args);
62 const Driver &getDriver() const { return TheDriver; }
64 const ToolChain &getDefaultToolChain() const { return DefaultToolChain; }
66 const InputArgList &getArgs() const { return *Args; }
68 ActionList &getActions() { return Actions; }
69 const ActionList &getActions() const { return Actions; }
71 JobList &getJobs() { return Jobs; }
73 /// getArgsForToolChain - Return the derived argument list for the
74 /// tool chain \arg TC (or the default tool chain, if TC is not
76 const DerivedArgList &getArgsForToolChain(const ToolChain *TC = 0);
78 /// addTempFile - Add a file to remove on exit, and returns its
80 const char *addTempFile(const char *Name) {
81 TempFiles.push_back(Name);
85 /// addResultFile - Add a file to remove on failure, and returns its
87 const char *addResultFile(const char *Name) {
88 ResultFiles.push_back(Name);
92 /// Execute - Execute the compilation jobs and return an
93 /// appropriate exit code.
97 /// CleanupFileList - Remove the files in the given list.
99 /// \param IssueErrors - Report failures as errors.
100 /// \return Whether all files were removed successfully.
101 bool CleanupFileList(const ArgStringList &Files,
102 bool IssueErrors=false) const;
104 /// PrintJob - Print one job in -### format.
106 /// OS - The stream to print on.
107 /// J - The job to print.
108 /// Terminator - A string to print at the end of the line.
109 /// Quote - Should separate arguments be quoted.
110 void PrintJob(llvm::raw_ostream &OS, const Job &J,
111 const char *Terminator, bool Quote) const;
113 /// ExecuteCommand - Execute an actual command.
115 /// \return The result code of the subprocess.
116 int ExecuteCommand(const Command &C) const;
118 /// ExecuteJob - Execute a single job.
120 /// \return The accumulated result code of the job.
121 int ExecuteJob(const Job &J) const;
124 } // end namespace driver
125 } // end namespace clang