Files
Breeze/source/BreezeCore/include/breeze/Build.hpp
T
2026-10-24 09:53:48 -03:00

56 lines
2.2 KiB
C++

#pragma once
#include <filesystem>
#include <map>
#include <optional>
#include <string>
#include <vector>
#include "breeze/Presets.hpp"
#include "breeze/Project.hpp"
/// Building, installing, running and cleaning a project -- by driving the SDK's own scripts, so the
/// environment they set up (the pinned Ninja, the MSVC environment on Windows) is always the one
/// used. Where a request needs something the scripts don't offer (extra `cmake --build` arguments,
/// skipping the configure), the CLI runs `cmake --build` itself against the build the scripts made.
namespace breeze
{
struct BuildRequest
{
PresetQuery preset;
/// Release, Debug, ReleaseDebugSymbols or MinSizeRel (any case).
std::optional<std::string> mode;
std::optional<int> jobs;
std::vector<std::string> configureArgs;
std::vector<std::string> buildArgs;
bool noConfigure = false;
bool noBuild = false;
};
/// The CMake build type for a mode name; throws Error for an unknown one.
std::string buildTypeFor(const std::string& mode);
/// Values of the project's settings (BUILD_OUTPUT_DIR, DOCS_OUTPUT_DIR, ...) as the SDK
/// computes them. Falls back to the SDK's defaults for a legacy layout that can't be asked.
std::map<std::string, std::string> readConfigVariables(const Project& project,
const std::vector<std::string>& names);
/// The build directory for the preset (or the one built last), as the SDK defines it.
std::filesystem::path buildDirFor(const Project& project,
const std::optional<std::string>& preset);
/// Each returns the exit code of the command that did the work.
int build(const Project& project, const BuildRequest& request);
int install(const Project& project, const BuildRequest& request);
int docs(const Project& project);
int run(const Project& project, const std::optional<std::string>& id, const PresetQuery& where,
const std::vector<std::string>& programArgs);
int setup(const Project& project, bool required, bool all);
/// Removes the build directories (unless keepBuild) and the documentation (if alsoDocs).
/// Returns the paths removed, relative to the project.
std::vector<std::string> clean(const Project& project, bool keepBuild, bool alsoDocs);
}