Add project files
This commit is contained in:
commit
f2fe6b8855
114 files changed
+20525
No files matched your search
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "breeze/Project.hpp"
|
||||
|
||||
/// A project's modules: the directories under source/ (and source/tests/, source/examples/) that
|
||||
/// each register one CMake target with one of the SDK's add_*_module macros. They are read from the
|
||||
/// CMakeLists.txt files themselves, so what the CLI shows is what CMake will do, and the files it
|
||||
/// writes are the ones a person would have written.
|
||||
namespace breeze
|
||||
{
|
||||
|
||||
enum class ModuleKind
|
||||
{
|
||||
Exec,
|
||||
Lib,
|
||||
Obj,
|
||||
Test,
|
||||
Example
|
||||
};
|
||||
|
||||
enum class LibType
|
||||
{
|
||||
Unspecified,
|
||||
Static,
|
||||
Shared
|
||||
};
|
||||
|
||||
/// "exec", "lib", "obj", "test" or "example".
|
||||
std::string kindName(ModuleKind kind);
|
||||
|
||||
struct Module
|
||||
{
|
||||
/// The CMake target: what DEPENDS, `breeze run` and `breeze deps` call it.
|
||||
std::string id;
|
||||
/// The directory's name.
|
||||
std::string dirName;
|
||||
std::filesystem::path dir;
|
||||
ModuleKind kind = ModuleKind::Exec;
|
||||
LibType libType = LibType::Unspecified;
|
||||
std::string outputName;
|
||||
std::vector<std::string> deps;
|
||||
/// The macro that registered it, e.g. add_lib_module.
|
||||
std::string macro;
|
||||
};
|
||||
|
||||
/// Every module, main ones first (by directory name), then tests, then examples.
|
||||
std::vector<Module> scanModules(const Project& project);
|
||||
|
||||
/// By id, else by directory name. Null when there is no such module.
|
||||
const Module* findModule(const std::vector<Module>& modules, const std::string& idOrDir);
|
||||
|
||||
struct NewModule
|
||||
{
|
||||
ModuleKind kind = ModuleKind::Exec;
|
||||
std::string name;
|
||||
std::optional<std::string> id;
|
||||
std::vector<std::string> deps;
|
||||
LibType libType = LibType::Unspecified;
|
||||
};
|
||||
|
||||
/// Creates the module's directory, CMakeLists.txt and starter files. Throws Error on anything
|
||||
/// it would have to guess about or overwrite.
|
||||
Module addModule(const Project& project, const NewModule& request);
|
||||
|
||||
/// Removes the module's directory. Refuses while another module still depends on it.
|
||||
void deleteModule(const Project& project, const std::string& idOrDir);
|
||||
|
||||
struct RenameResult
|
||||
{
|
||||
std::string oldId;
|
||||
std::string newId;
|
||||
std::string oldDir;
|
||||
std::string newDir;
|
||||
/// Modules whose CMakeLists.txt had a DEPENDS entry updated.
|
||||
std::vector<std::string> updatedDependents;
|
||||
};
|
||||
|
||||
/// Renames the directory and/or the id, and rewrites DEPENDS entries elsewhere to the new id.
|
||||
RenameResult renameModule(const Project& project, const std::string& idOrDir,
|
||||
const std::optional<std::string>& newName,
|
||||
const std::optional<std::string>& newId);
|
||||
|
||||
/// What `module` depends on, without repeats, in the order met (nearest first). Entries that
|
||||
/// are not modules of the project (fmt::fmt, pthread) are included as they were written.
|
||||
std::vector<std::string> dependenciesOf(const std::vector<Module>& modules,
|
||||
const Module& module, bool recursive);
|
||||
|
||||
/// The modules that depend on `module`, directly or (recursive) through others.
|
||||
std::vector<std::string> dependentsOf(const std::vector<Module>& modules, const Module& module,
|
||||
bool recursive);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user