targets and names
This commit is contained in:
parent
4843fcc77f
commit
cc4d8d1fc3
4 changed files with 160 additions and 36 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <functional>
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
#include <set>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "loggable.h"
|
||||
|
@ -39,33 +40,38 @@ public:
|
|||
Component(
|
||||
const std::filesystem::path& path,
|
||||
Collection* collection,
|
||||
const std::shared_ptr<Logger>& logger
|
||||
const std::shared_ptr<Logger>& logger,
|
||||
const std::string& name = ""
|
||||
);
|
||||
|
||||
Type getType() const;
|
||||
State getState() const;
|
||||
std::filesystem::path getLocation() const;
|
||||
std::string getLibrariesPath() const;
|
||||
std::string getName() const;
|
||||
bool successfullyRead() const;
|
||||
bool successfullyBuilt() const;
|
||||
|
||||
void read();
|
||||
void build(const std::filesystem::path& destination, const std::string& target);
|
||||
void build(const std::filesystem::path& destination, const std::string& target, bool useName = true);
|
||||
|
||||
private:
|
||||
void tryReadingBuildScenarios();
|
||||
bool tryReadingBuildScenarios();
|
||||
bool readAsMason();
|
||||
bool errorScenario(const std::string& message);
|
||||
|
||||
void buildAsFile(const std::filesystem::path& destination);
|
||||
void buildAsDirectory(const std::filesystem::path& destination);
|
||||
void buildAsMason(const std::filesystem::path& destination, const std::string& target);
|
||||
void buildAsMason(const std::filesystem::path& destination, std::string target);
|
||||
|
||||
bool readMasonDependencies(const nlohmann::json& deps, const std::string& manifestPath);
|
||||
void copyFile(const std::filesystem::path& from, const std::filesystem::path& to) const;
|
||||
|
||||
std::string validateMasonTarget(std::string target) const;
|
||||
void masonFilesArray(const nlohmann::json& files, const std::filesystem::path& destination);
|
||||
bool allowedForTarget(const nlohmann::json& object, const std::string& target) const;
|
||||
bool masonFileObject(const nlohmann::json& object, const std::filesystem::path& destination);
|
||||
bool allowedForMasonTarget(const nlohmann::json& object, const std::string& target) const;
|
||||
void getMasonTargets(const nlohmann::json& object, std::set<std::string>& out) const;
|
||||
|
||||
std::optional<std::string> getFileSource(const nlohmann::json& object) const;
|
||||
std::optional<std::string> getFileTarget(const nlohmann::json& object) const;
|
||||
|
@ -78,6 +84,7 @@ private:
|
|||
Collection* collection;
|
||||
std::filesystem::path location;
|
||||
std::optional<nlohmann::json> manifest;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class Component::WrongState : public std::runtime_error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue