Go to the documentation of this file.
9 #ifndef LLVM_CLANG_DRIVER_JOB_H
10 #define LLVM_CLANG_DRIVER_JOB_H
14 #include "llvm/ADT/ArrayRef.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/iterator.h"
18 #include "llvm/Option/Option.h"
19 #include "llvm/Support/Program.h"
79 return {
RF_None, llvm::sys::WEM_UTF8,
nullptr};
86 return {
RF_Full, llvm::sys::WEM_UTF8,
"@"};
93 return {
RF_Full, llvm::sys::WEM_CurrentCodePage,
"@"};
100 return {
RF_Full, llvm::sys::WEM_UTF16,
"@"};
117 const char *Executable;
121 llvm::opt::ArgStringList Arguments;
127 std::vector<std::string> OutputFilenames;
131 const char *ResponseFile =
nullptr;
135 llvm::opt::ArgStringList InputFileList;
142 std::vector<const char *> Environment;
145 std::vector<std::optional<std::string>> RedirectFiles;
148 mutable std::optional<llvm::sys::ProcessStatistics> ProcStat;
160 void writeResponseFile(raw_ostream &OS)
const;
178 virtual void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
192 return ResponseSupport;
201 InputFileList = std::move(List);
214 Arguments = std::move(List);
221 const llvm::opt::ArgStringList &
getArguments()
const {
return Arguments; }
226 return OutputFilenames;
243 const llvm::opt::ArgStringList &Arguments,
247 void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
251 bool *ExecutionFailed)
const override;
261 const char *Executable_,
262 const llvm::opt::ArgStringList &Arguments_,
266 void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
270 bool *ExecutionFailed)
const override;
278 using iterator = llvm::pointee_iterator<list_type::iterator>;
285 void Print(llvm::raw_ostream &OS,
const char *Terminator,
289 void addJob(std::unique_ptr<Command> J) { Jobs.push_back(std::move(J)); }
296 bool empty()
const {
return Jobs.empty(); }
307 #endif // LLVM_CLANG_DRIVER_JOB_H
static constexpr ResponseFileSupport AtFileUTF16()
static constexpr ResponseFileSupport AtFileUTF8()
bool PrintInputFilenames
Whether to print the input filenames when executing.
Action - Represent an abstract compilation step to perform.
std::optional< llvm::sys::ProcessStatistics > getProcessStatistics() const
void replaceArguments(llvm::opt::ArgStringList List)
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
Use the CC1 tool callback when available, to avoid creating a new process.
CC1Command(const Action &Source, const Tool &Creator, ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef< InputInfo > Inputs, ArrayRef< InputInfo > Outputs=std::nullopt)
const list_type & getJobs() const
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const override
void clear()
Clear the job list.
bool InProcess
Whether the command will be executed in this process or not.
llvm::sys::WindowsEncodingMethod ResponseEncoding
The encoding to use when writing response files on Windows.
int Execute(ArrayRef< std::optional< StringRef >> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override
const ResponseFileSupport & getResponseFileSupport()
Returns the kind of response file supported by the current invocation.
llvm::pointee_iterator< list_type::const_iterator > const_iterator
CrashReportInfo(StringRef Filename, StringRef VFSPath)
const Tool & getCreator() const
getCreator - Return the Tool which caused the creation of this job.
static constexpr ResponseFileSupport AtFileCurCP()
void PrintFileNames() const
Optionally print the filenames to be compiled.
Like Command, but always pretends that the wrapped command succeeded.
JobList - A sequence of jobs to perform.
virtual int Execute(ArrayRef< std::optional< StringRef >> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const
void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment) override
Sets the environment to be used by the new process.
void setRedirectFiles(const std::vector< std::optional< std::string >> &Redirects)
const std::vector< InputInfo > & getInputInfos() const
void setInputFileList(llvm::opt::ArgStringList List)
Set an input file list, necessary if you specified an RF_FileList response file support.
const char * ResponseFlag
What prefix to use for the command-line argument when passing a response file.
ResponseFileKind ResponseKind
The level of support for response files.
Command - An executable path/name and argument vector to execute.
ForceSuccessCommand(const Action &Source_, const Tool &Creator_, ResponseFileSupport ResponseSupport, const char *Executable_, const llvm::opt::ArgStringList &Arguments_, ArrayRef< InputInfo > Inputs, ArrayRef< InputInfo > Outputs=std::nullopt)
const llvm::opt::ArgStringList & getArguments() const
int Execute(ArrayRef< std::optional< StringRef >> Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override
list_type::size_type size_type
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const override
const std::vector< std::string > & getOutputFilenames() const
void setResponseFile(const char *FileName)
Set to pass arguments via a response file when launching the command.
const Action & getSource() const
getSource - Return the Action which caused the creation of this job.
const char * getExecutable() const
llvm::pointee_iterator< list_type::iterator > iterator
void addJob(std::unique_ptr< Command > J)
Add a job to the list (taking ownership).
const_iterator end() const
void replaceExecutable(const char *Exe)
const_iterator begin() const
virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
Command(const Action &Source, const Tool &Creator, ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef< InputInfo > Inputs, ArrayRef< InputInfo > Outputs=std::nullopt)
virtual void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment)
Sets the environment to be used by the new process.
virtual ~Command()=default
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.