added specfic git commit or branch dependency
This commit is contained in:
parent
af7eb61c3d
commit
1bfc07db4b
4 changed files with 24 additions and 4 deletions
|
|
@ -80,7 +80,15 @@ Configuration::Configuration(const nlohmann::json& configs, const nlohmann::json
|
|||
outputDir = fullOutputPath.generic_string();
|
||||
} else if(key == "dependencies") {
|
||||
for (auto it : val) {
|
||||
dependencies.emplace_back(it["path"].get<std::string>(), it["configuration"].get<std::string>());
|
||||
std::string commit;
|
||||
std::string branch;
|
||||
if(it.contains("commit")){
|
||||
commit = it["commit"].get<std::string>();
|
||||
}
|
||||
if(it.contains("branch")){
|
||||
branch = it["branch"].get<std::string>();
|
||||
}
|
||||
dependencies.emplace_back(it["path"].get<std::string>(), it["configuration"].get<std::string>(), commit, branch);
|
||||
}
|
||||
} else if(key != "extends") {
|
||||
additionalProperties.insert({key, val});
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ module;
|
|||
module Crafter.Build;
|
||||
using namespace Crafter::Build;
|
||||
|
||||
Dependency::Dependency(std::string path, std::string configuration): path(path), configuration(configuration) {
|
||||
Dependency::Dependency(std::string path, std::string configuration, std::string commit, std::string branch): path(path), configuration(configuration), commit(commit), branch(branch) {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ export namespace Crafter::Build {
|
|||
public:
|
||||
std::string path;
|
||||
std::string configuration;
|
||||
Dependency(std::string path, std::string configuration);
|
||||
std::string commit;
|
||||
std::string branch;
|
||||
Dependency(std::string path, std::string configuration, std::string commit, std::string branch);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue