fixed recursive libs
Some checks failed
demo.yaml / fixed recursive libs (push) Failing after 0s

This commit is contained in:
Jorijn van der Graaf 2025-11-16 18:44:41 +01:00
commit 0819baf6d3
8 changed files with 170 additions and 117 deletions

View file

@ -22,6 +22,7 @@ module;
module Crafter.Build:Configuration_impl;
import :Configuration;
import std;
import :Project;
//import :Dependency;
import :Shader;
import :Module;
@ -32,11 +33,11 @@ namespace Crafter {
Configuration::Configuration(std::string&& name) : name(std::move(name)) {
}
Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir) {
SetDataFromJson(configs, config, workingDir);
Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir, const Project& project) {
SetDataFromJson(configs, config, workingDir, project);
}
void Configuration::SetDataFromJson(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir) {
void Configuration::SetDataFromJson(const nlohmann::json& configs, const nlohmann::json& config, fs::path workingDir, const Project& project) {
type = static_cast<ConfigurationType>(-1);
debug = static_cast<bool>(2);
if(config.contains("extends")) {
@ -44,7 +45,7 @@ namespace Crafter {
for(const std::string& extendName : extends) {
for (auto it : configs) {
if(it["name"].get<std::string>() == extendName) {
SetDataFromJson(configs, it, workingDir);
SetDataFromJson(configs, it, workingDir, project);
}
}
}
@ -213,6 +214,11 @@ namespace Crafter {
shaders.emplace_back(workingDir / it["path"].get<std::string>(), it["entrypoint"].get<std::string>(), static_cast<EShLanguage>(it["type"].get<std::uint32_t>()));
}
}
if(config.contains("c_files")) {
for (auto it : config["c_files"]) {
c_files.push_back(workingDir / it.get<std::string>());
}
}
if(config.contains("defines")) {
for (auto it : config["defines"]) {
defines.emplace_back(it["name"].get<std::string>(), it["value"].get<std::string>());
@ -226,15 +232,26 @@ namespace Crafter {
}
if(config.contains("dependencies")) {
for (auto it : config["dependencies"]) {
std::string commit;
std::string branch;
if(it.contains("commit")){
commit = it["commit"].get<std::string>();
fs::path path = it["path"].get<std::string>();
std::string configName = it["configuration"].get<std::string>();
if(path.string().ends_with(".git")) {
fs::path name = path.filename();
name.replace_extension();
if(!fs::exists(project.buildDir/name)) {
if(it.contains("branch")) {
system(std::format("cd {} && git clone {} && cd {} && git switch {}",project.buildDir.string(), path.string(), (project.buildDir/name).string(), it["branch"].get<std::string>()).c_str());
} else if(it.contains("commit")){
system(std::format("cd {} && git clone {} && cd {} && git checkout {}", project.buildDir.string(), path.string(), (project.buildDir/name).string(), it["commit"].get<std::string>()).c_str());
} else {
system(std::format("cd {} && git clone {}", project.buildDir.string(), path.string()).c_str());
}
} else if(!it.contains("commit")) {
system(std::format("cd {} && git pull", (project.buildDir/name).string()).c_str());
}
path = project.buildDir/name/"project.json";
}
if(it.contains("branch")){
branch = it["branch"].get<std::string>();
}
dependencies.emplace_back(it["path"].get<std::string>(), it["configuration"].get<std::string>(), std::move(commit), std::move(branch));
std::unique_ptr<Project> depProject = std::make_unique<Project>(std::move(path), configName);
dependencies.emplace_back(std::move(depProject), depProject->configurations[0]);
}
}
}