blob: b0f0709b0cac8ccf3a27e2ae8cb3cbe4d81577d9 [file] [log] [blame]
// Copyright 2023 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef NINJA_BUILD_CONFIG_H_
#define NINJA_BUILD_CONFIG_H_
#include <string>
#include "depfile_parser.h"
#include "process_utils.h"
/// Options (e.g. verbosity, parallelism) passed to a build.
/// NOTE: This does not include debug flags, stored in global variables :-/
struct BuildConfig {
enum Verbosity {
QUIET, // No output -- used when testing.
NO_STATUS_UPDATE, // just regular output but suppress status update
NORMAL, // regular output and status update
VERBOSE
};
Verbosity verbosity = NORMAL;
bool dry_run = false;
int parallelism = 1;
int failures_allowed = 1;
/// The maximum load average we must not exceed. A negative value
/// means that we do not have any limit.
double max_load_average = -0.0f;
/// Name of the main manifest input file.
std::string input_file = "build.ninja";
DepfileParserOptions depfile_parser_options;
/// The set of environment variables to use when spawning commands.
EnvironmentBlock environment;
/// Retrieve some values from environment variables.
std::string status_format() const;
int status_max_commands() const;
int64_t status_refresh_millis() const;
/// Compare two instances.
bool operator==(const BuildConfig& o) const;
bool operator!=(const BuildConfig& o) const { return !(*this == o); }
/// Encoding/decoding support for IPC.
static BuildConfig FromEncodedString(const std::string& str,
std::string* error);
std::string ToEncodedString() const;
/// Convert to string for debugging.
std::string ToString() const;
};
#endif // NINJA_BUILD_CONFIG_H_