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;
120 const char *PrependArg;
124 llvm::opt::ArgStringList Arguments;
130 std::vector<std::string> OutputFilenames;
134 const char *ResponseFile =
nullptr;
138 llvm::opt::ArgStringList InputFileList;
142 std::string ResponseFileFlag;
145 std::vector<const char *> Environment;
148 std::vector<std::optional<std::string>> RedirectFiles;
151 mutable std::optional<llvm::sys::ProcessStatistics> ProcStat;
163 void writeResponseFile(raw_ostream &OS)
const;
176 const char *PrependArg =
nullptr);
182 virtual void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
186 std::string *ErrMsg,
bool *ExecutionFailed)
const;
196 return ResponseSupport;
205 InputFileList = std::move(List);
218 Arguments = std::move(List);
225 const llvm::opt::ArgStringList &
getArguments()
const {
return Arguments; }
230 return OutputFilenames;
247 const llvm::opt::ArgStringList &Arguments,
250 const char *PrependArg =
nullptr);
252 void Print(llvm::raw_ostream &OS,
const char *Terminator,
bool Quote,
255 int Execute(
ArrayRef<std::optional<StringRef>> Redirects, std::string *ErrMsg,
256 bool *ExecutionFailed)
const override;
266 using iterator = llvm::pointee_iterator<list_type::iterator>;
273 void Print(llvm::raw_ostream &OS,
const char *Terminator,
277 void addJob(std::unique_ptr<Command> J) { Jobs.push_back(std::move(J)); }
284 bool empty()
const {
return Jobs.empty(); }
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Action - Represent an abstract compilation step to perform.
Use the CC1 tool callback when available, to avoid creating a new process.
void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment) override
Sets the environment to be used by the new process.
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const override
int Execute(ArrayRef< std::optional< StringRef > > Redirects, std::string *ErrMsg, bool *ExecutionFailed) const override
Command - An executable path/name and argument vector to execute.
const Action & getSource() const
getSource - Return the Action which caused the creation of this job.
const std::vector< std::string > & getOutputFilenames() const
const Tool & getCreator() const
getCreator - Return the Tool which caused the creation of this job.
const llvm::opt::ArgStringList & getArguments() const
virtual ~Command()=default
void setResponseFile(const char *FileName)
Set to pass arguments via a response file when launching the command.
void setRedirectFiles(const std::vector< std::optional< std::string > > &Redirects)
Command(const Command &)=default
void replaceExecutable(const char *Exe)
void setInputFileList(llvm::opt::ArgStringList List)
Set an input file list, necessary if you specified an RF_FileList response file support.
bool PrintInputFilenames
Whether to print the input filenames when executing.
std::optional< llvm::sys::ProcessStatistics > getProcessStatistics() const
const char * getExecutable() const
virtual void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
const ResponseFileSupport & getResponseFileSupport()
Returns the kind of response file supported by the current invocation.
bool InProcess
Whether the command will be executed in this process or not.
virtual void setEnvironment(llvm::ArrayRef< const char * > NewEnvironment)
Sets the environment to be used by the new process.
void replaceArguments(llvm::opt::ArgStringList List)
void PrintFileNames() const
Optionally print the filenames to be compiled.
const std::vector< InputInfo > & getInputInfos() const
virtual int Execute(ArrayRef< std::optional< StringRef > > Redirects, std::string *ErrMsg, bool *ExecutionFailed) const
JobList - A sequence of jobs to perform.
list_type::size_type size_type
void clear()
Clear the job list.
const_iterator begin() const
const list_type & getJobs() const
void addJob(std::unique_ptr< Command > J)
Add a job to the list (taking ownership).
const_iterator end() const
llvm::pointee_iterator< list_type::iterator > iterator
llvm::pointee_iterator< list_type::const_iterator > const_iterator
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo=nullptr) const
The JSON file list parser is used to communicate input to InstallAPI.
CrashReportInfo(StringRef Filename, StringRef VFSPath)
ResponseFileKind ResponseKind
The level of support for response files.
llvm::sys::WindowsEncodingMethod ResponseEncoding
The encoding to use when writing response files on Windows.
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.
static constexpr ResponseFileSupport AtFileUTF8()
const char * ResponseFlag
What prefix to use for the command-line argument when passing a response file.
static constexpr ResponseFileSupport AtFileCurCP()
static constexpr ResponseFileSupport AtFileUTF16()