sources as different names, explicit targets
This commit is contained in:
parent
cc4d8d1fc3
commit
1d9a6ec3f8
10 changed files with 252 additions and 62 deletions
|
@ -42,7 +42,7 @@ Component::Component(
|
|||
const std::filesystem::path& path,
|
||||
Collection* collection,
|
||||
const std::shared_ptr<Logger>& logger,
|
||||
const std::string& name
|
||||
const std::optional<std::string>& name
|
||||
):
|
||||
Loggable(logger),
|
||||
state(initial),
|
||||
|
@ -64,14 +64,14 @@ void Component::read() {
|
|||
case std::filesystem::file_type::directory:
|
||||
type = directory;
|
||||
state = ready;
|
||||
if (!tryReadingBuildScenarios() && name.empty())
|
||||
if (!tryReadingBuildScenarios() && !name.has_value())
|
||||
name = location.filename();
|
||||
|
||||
break;
|
||||
case std::filesystem::file_type::regular:
|
||||
type = file;
|
||||
state = ready;
|
||||
if (name.empty())
|
||||
if (!name.has_value())
|
||||
name = location.filename();
|
||||
|
||||
break;
|
||||
|
@ -115,12 +115,12 @@ bool Component::readAsMason() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (name.empty()) {
|
||||
if (!name.has_value()) {
|
||||
std::optional<std::string> manifestName = tryStringValue(mnfst, "name");
|
||||
if (manifestName.has_value())
|
||||
name = manifestName.value();
|
||||
|
||||
if (name.empty()) {
|
||||
if (!name.has_value()) {
|
||||
major("Couldn't define name of the project at " + location.string() + ", using directory name as project name");
|
||||
name = location.filename();
|
||||
}
|
||||
|
@ -141,18 +141,14 @@ bool Component::readMasonDependencies(const nlohmann::json& deps, const std::str
|
|||
for (const nlohmann::json& dep : deps) {
|
||||
switch (dep.type()) {
|
||||
case nlohmann::json::value_t::string:
|
||||
collection->addSource(dep);
|
||||
collection->addSource({dep});
|
||||
break;
|
||||
case nlohmann::json::value_t::object: {
|
||||
nlohmann::json::const_iterator ditr = dep.find("path");
|
||||
if (ditr == dep.end())
|
||||
std::optional<std::string> path = tryStringValue(dep, "path");
|
||||
if (!path.has_value())
|
||||
return errorScenario(manifestPath + " object of unexpected format in dependecies");
|
||||
|
||||
nlohmann::json path = *ditr;
|
||||
if (!path.is_string())
|
||||
return errorScenario(manifestPath + " object of unexpected format in dependecies");
|
||||
|
||||
collection->addSource(path);
|
||||
collection->addSource({path.value(), tryStringValue(dep, "target"), tryStringValue(dep, "name")});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -181,20 +177,20 @@ void Component::build(const std::filesystem::path& destination, const std::strin
|
|||
switch (type) {
|
||||
case file:
|
||||
if (useName)
|
||||
buildAsFile(destination/name);
|
||||
buildAsFile(destination/name.value());
|
||||
else
|
||||
buildAsFile(destination);
|
||||
|
||||
break;
|
||||
case directory:
|
||||
if (useName)
|
||||
buildAsDirectory(destination/name);
|
||||
buildAsDirectory(destination/name.value());
|
||||
else
|
||||
buildAsDirectory(destination);
|
||||
break;
|
||||
case mason:
|
||||
if (useName)
|
||||
buildAsMason(destination/name, target);
|
||||
buildAsMason(destination/name.value(), target);
|
||||
else
|
||||
buildAsMason(destination, target);
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue