global clone cache
Some checks failed
demo.yaml / global clone cache (push) Failing after 0s

This commit is contained in:
Jorijn van der Graaf 2026-02-27 04:36:51 +01:00
commit 379e5c2028

View file

@ -19,6 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
module;
#include "../lib/json.hpp"
#include <glslang/Public/ShaderLang.h>
#include <stdlib.h>
module Crafter.Build:Configuration_impl;
import :Configuration;
import std;
@ -250,7 +251,7 @@ namespace Crafter {
if(path.string().ends_with(".git")) {
fs::path name = path.filename();
name.replace_extension();
std::string depFolder = name.string() + "-" + configName;
std::string depFolder = name.string();
// if (it.contains("commit")) {
// depFolder += it["commit"].get<std::string>();
@ -258,14 +259,16 @@ namespace Crafter {
// depFolder += it["branch"].get<std::string>();
// }
if (!fs::exists(project.buildDir/depFolder)) {
fs::create_directories(project.buildDir/depFolder);
char self[PATH_MAX];
ssize_t count = readlink("/proc/self/exe", self, PATH_MAX);
if (count == -1) {
throw std::runtime_error("Failed to get executable path");
}
self[count] = '\0';
const fs::path cacheDir = (fs::path(self).parent_path().parent_path() / "cloneCache").string();
std::string cloneCommand = std::format("cd {} && git clone {} {} && cd {}",
project.buildDir.string(),
path.string(),
depFolder,
depFolder);
if (!fs::exists(cacheDir/depFolder)) {
std::string cloneCommand = std::format("cd {} && git clone {} && cd {}", cacheDir.string(), path.string(), depFolder);
if (it.contains("branch")) {
cloneCommand += std::format(" && git switch {}", it["branch"].get<std::string>());
@ -276,11 +279,11 @@ namespace Crafter {
// Execute the clone command
system(cloneCommand.c_str());
} else if (!it.contains("commit")) {
system(std::format("cd {} && git pull", (project.buildDir/depFolder).string()).c_str());
system(std::format("cd {} && git pull", (cacheDir/depFolder).string()).c_str());
}
// Update path to the project.json of the dependency
path = project.buildDir/ depFolder / "project.json";
path = cacheDir / depFolder / "project.json";
}
// Create a Project object for the dependency