added specfic git commit or branch dependency

This commit is contained in:
Jorijn van der Graaf 2025-03-29 22:36:43 +01:00
commit 1bfc07db4b
4 changed files with 24 additions and 4 deletions

View file

@ -112,7 +112,17 @@ void Project::Build(Configuration config, fs::path outputDir, fs::path binDir) c
for(std::int_fast32_t i = 0; i < depThreads.size(); i++) {
if(config.dependencies[i].path.ends_with(".git")) {
system(std::format("cd {} && git clone {}", config.buildDir, config.dependencies[i].path).c_str());
std::string branch;
if(!config.dependencies[i].branch.empty()) {
fs::path name = fs::path(config.dependencies[i].path).filename();
name.replace_extension();
branch = std::format(" && cd {} && git switch {}", name.generic_string(), config.dependencies[i].branch);
} else if(!config.dependencies[i].commit.empty()){
fs::path name = fs::path(config.dependencies[i].path).filename();
name.replace_extension();
branch = std::format(" && cd {} && git checkout {}", name.generic_string(), config.dependencies[i].commit);
}
system(std::format("cd {} && git clone {}{}", config.buildDir, config.dependencies[i].path, branch).c_str());
config.dependencies[i].path = fs::path(config.dependencies[i].path).filename().replace_extension();
Project project = Project::LoadFromJSON(fs::path(config.buildDir)/config.dependencies[i].path/"project.json");
libs+=std::format(" -l{}", project.name);