30 assert(prefix.
len_ > 0);
43 int read_fd = 1, write_fd = -1;
45 if (sscanf(pair.c_str(),
"%d,%d", &read_fd, &write_fd) != 2)
51 if (read_fd < 0 || write_fd < 0)
66 return static_cast<uint8_t
>(
value_);
74 if (!makeflags_env || !makeflags_env[0]) {
80 std::vector<StringPiece> args;
81 const char* p = makeflags_env;
83 const char* next_space = strpbrk(p,
" \t");
90 args.emplace_back(p, next_space - p);
140 if (!args.empty() && args[0][0] !=
'-' &&
141 memchr(args[0].str_,
'n', args[0].len_) !=
nullptr) {
146 for (
const auto& arg : args) {
150 if (GetPrefixedValue(arg,
"--jobserver-auth=", &value)) {
151 if (GetFileDescriptorPair(value, config)) {
155 if (GetPrefixedValue(value,
"fifo:", &fifo_path)) {
168 if (GetPrefixedValue(arg,
"--jobserver-fds=", &value)) {
169 if (!GetFileDescriptorPair(value, config)) {
170 *error =
"Invalid file descriptor pair [" + value.
AsString() +
"]";
188 std::string* error) {
193 *error =
"Pipe-based protocol is not supported!";
198 *error =
"FIFO mode is not supported on Windows!";
203 *error =
"Semaphore mode is not supported on Posix!";
A Jobserver::Config models how to access or implement a GNU jobserver implementation.
std::string path
For kModeFifo, this is the path to the Unix FIFO to use.
Mode mode
Implementation mode for the pool.
uint8_t GetExplicitValue() const
Return value of an explicit slot.
bool IsExplicit() const
Return true if this instance represents an explicit job slot.
static constexpr int16_t kImplicitValue
static bool ParseNativeMakeFlagsValue(const char *makeflags_env, Config *config, std::string *error)
A variant of ParseMakeFlagsValue() that will return an error if the parsed result is not compatible w...
static bool ParseMakeFlagsValue(const char *makeflags_env, Config *config, std::string *error)
Parse the value of a MAKEFLAGS environment variable.
StringPiece represents a slice of a string whose memory is managed externally.
std::string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.