14 #ifndef LLVM_SUPPORT_PROGRAM_H
15 #define LLVM_SUPPORT_PROGRAM_H
19 #include <system_error>
28 #if defined(LLVM_ON_UNIX)
29 const char EnvPathSeparator =
':';
30 #elif defined (LLVM_ON_WIN32)
31 const char EnvPathSeparator =
';';
36 #if defined(LLVM_ON_UNIX)
37 typedef pid_t ProcessId;
38 #elif defined(LLVM_ON_WIN32)
39 typedef unsigned long ProcessId;
40 typedef void * HANDLE;
44 #error "ProcessInfo is not defined for this platform!"
97 const char **env =
nullptr,
108 unsigned secondsToWait = 0,
113 unsigned memoryLimit = 0,
117 std::string *ErrMsg =
nullptr,
121 bool *ExecutionFailed =
nullptr);
130 const StringRef **redirects =
nullptr,
unsigned memoryLimit = 0,
131 std::string *ErrMsg =
nullptr,
bool *ExecutionFailed =
nullptr);
180 unsigned SecondsToWait,
184 bool WaitUntilTerminates,
186 std::string *ErrMsg =
nullptr
Represents either an error or a value T.
std::error_code ChangeStdoutToBinary()
UTF-8 is the LLVM native encoding, being the same as "do not perform encoding conversion"...
ProcessInfo ExecuteNoWait(StringRef Program, const char **args, const char **env=nullptr, const StringRef **redirects=nullptr, unsigned memoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
Similar to ExecuteAndWait, but returns immediately.
ProcessId Pid
The process identifier.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
int ExecuteAndWait(StringRef Program, const char **args, const char **env=nullptr, const StringRef **redirects=nullptr, unsigned secondsToWait=0, unsigned memoryLimit=0, std::string *ErrMsg=nullptr, bool *ExecutionFailed=nullptr)
This function executes the program using the arguments provided.
bool commandLineFitsWithinSystemLimits(StringRef Program, ArrayRef< const char * > Args)
Return true if the given arguments fit within system-specific argument length limits.
std::error_code writeFileWithEncoding(StringRef FileName, StringRef Contents, WindowsEncodingMethod Encoding=WEM_UTF8)
Saves the UTF8-encoded contents string into the file FileName using a specific encoding.
WindowsEncodingMethod
File encoding options when writing contents that a non-UTF8 tool will read (on Windows systems)...
int ReturnCode
The return code, set after execution.
std::error_code ChangeStdinToBinary()
This is the OS-specific separator for PATH like environment variables:
ErrorOr< std::string > findProgramByName(StringRef Name, ArrayRef< StringRef > Paths=None)
Find the first executable file Name in Paths.
Provides ErrorOr<T> smart pointer.
StringRef - Represent a constant reference to a string, i.e.
ProcessInfo Wait(const ProcessInfo &PI, unsigned SecondsToWait, bool WaitUntilTerminates, std::string *ErrMsg=nullptr)
This function waits for the process specified by PI to finish.