fix
This commit is contained in:
parent
cbc7b45b8d
commit
72effdee9b
3 changed files with 18 additions and 11 deletions
|
|
@ -37,6 +37,8 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
type = static_cast<ConfigurationType>(-1);
|
||||||
|
debug = static_cast<bool>(2);
|
||||||
if(config.contains("extends")) {
|
if(config.contains("extends")) {
|
||||||
const std::vector<std::string> extends = config["extends"].get<std::vector<std::string>>();
|
const std::vector<std::string> extends = config["extends"].get<std::vector<std::string>>();
|
||||||
for(const std::string& extendName : extends) {
|
for(const std::string& extendName : extends) {
|
||||||
|
|
@ -60,6 +62,8 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
if(config.contains("debug")) {
|
if(config.contains("debug")) {
|
||||||
debug = config["debug"].get<bool>();
|
debug = config["debug"].get<bool>();
|
||||||
|
} else if(static_cast<int>(debug) == 2) {
|
||||||
|
debug = false;
|
||||||
}
|
}
|
||||||
if(config.contains("type")) {
|
if(config.contains("type")) {
|
||||||
std::string typeString = config["type"].get<std::string>();
|
std::string typeString = config["type"].get<std::string>();
|
||||||
|
|
@ -72,6 +76,8 @@ namespace Crafter {
|
||||||
} else {
|
} else {
|
||||||
throw std::invalid_argument("Unknown type: " + typeString);
|
throw std::invalid_argument("Unknown type: " + typeString);
|
||||||
}
|
}
|
||||||
|
} else if(static_cast<int>(type) == -1) {
|
||||||
|
type = CRAFTER_CONFIGURATION_TYPE_EXECUTABLE;
|
||||||
}
|
}
|
||||||
if(config.contains("march")) {
|
if(config.contains("march")) {
|
||||||
march = config["march"].get<std::string>();
|
march = config["march"].get<std::string>();
|
||||||
|
|
|
||||||
|
|
@ -68,17 +68,17 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
void Project::Build(Configuration& config) const {
|
void Project::Build(Configuration& config) const {
|
||||||
if(binDir.empty()) {
|
if(binDir.empty()) {
|
||||||
Build(config, "bin"/fs::path(config.name));
|
Build(config, path/("bin"/fs::path(config.name)));
|
||||||
} else {
|
} else {
|
||||||
Build(config, this->binDir/config.name);
|
Build(config, path/this->binDir/config.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Project::Build(Configuration& config, const fs::path& binDir) const {
|
void Project::Build(Configuration& config, const fs::path& binDir) const {
|
||||||
fs::path buildDir;
|
fs::path buildDir;
|
||||||
if(this->buildDir.empty()) {
|
if(this->buildDir.empty()) {
|
||||||
buildDir = "build"/fs::path(config.name);
|
buildDir = path/("build"/fs::path(config.name));
|
||||||
} else {
|
} else {
|
||||||
buildDir = this->buildDir/config.name;
|
buildDir = path/this->buildDir/config.name;
|
||||||
}
|
}
|
||||||
Build(config, binDir, buildDir, name);
|
Build(config, binDir, buildDir, name);
|
||||||
}
|
}
|
||||||
|
|
@ -112,6 +112,7 @@ namespace Crafter {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
std::string command = "clang++";
|
std::string command = "clang++";
|
||||||
if(!config.target.empty()) {
|
if(!config.target.empty()) {
|
||||||
command += std::format(" -target={}", config.target);
|
command += std::format(" -target={}", config.target);
|
||||||
|
|
@ -202,7 +203,7 @@ clang++ -std=c++26 -Wno-reserved-identifier -Wno-reserved-module-identifier --pr
|
||||||
} else {
|
} else {
|
||||||
depBuildDir = fs::path(config.dependencies[i].path).parent_path()/project.buildDir/depConfig.name;
|
depBuildDir = fs::path(config.dependencies[i].path).parent_path()/project.buildDir/depConfig.name;
|
||||||
}
|
}
|
||||||
project.Build(depConfig, binDir, depBuildDir);
|
project.Build(depConfig, pcmDir, depBuildDir);
|
||||||
libMutex.lock();
|
libMutex.lock();
|
||||||
if (depLibSet.insert(project.name).second) {
|
if (depLibSet.insert(project.name).second) {
|
||||||
libsString+=std::format(" -l{}", project.name);
|
libsString+=std::format(" -l{}", project.name);
|
||||||
|
|
@ -337,15 +338,15 @@ clang++ -std=c++26 -Wno-reserved-identifier -Wno-reserved-module-identifier --pr
|
||||||
TestResult Project::RunTest(Test& test) const {
|
TestResult Project::RunTest(Test& test) const {
|
||||||
fs::path binDir;
|
fs::path binDir;
|
||||||
if(this->binDir.empty()) {
|
if(this->binDir.empty()) {
|
||||||
binDir = "bin"/fs::path(test.config.name);
|
binDir = path/("bin"/fs::path(test.config.name));
|
||||||
} else {
|
} else {
|
||||||
binDir = this->binDir/test.config.name;
|
binDir = path/this->binDir/test.config.name;
|
||||||
}
|
}
|
||||||
fs::path buildDir;
|
fs::path buildDir;
|
||||||
if(this->buildDir.empty()) {
|
if(this->buildDir.empty()) {
|
||||||
buildDir = "build"/fs::path(test.config.name);
|
buildDir = path/("build"/fs::path(test.config.name));
|
||||||
} else {
|
} else {
|
||||||
buildDir = this->buildDir/test.config.name;
|
buildDir = path/this->buildDir/test.config.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ int main(int argc, char* argv[]) {
|
||||||
binDir = std::format("{}/{}", project.binDir.string(), config.name);
|
binDir = std::format("{}/{}", project.binDir.string(), config.name);
|
||||||
}
|
}
|
||||||
if(config.debug) {
|
if(config.debug) {
|
||||||
system(std::format("cd {} && ./{}", (projectPath/fs::path(binDir)).string(), project.name).c_str());
|
system(std::format("cd {} && ./{}", (fs::path(projectPath).parent_path()/binDir).string(), project.name).c_str());
|
||||||
} else {
|
} else {
|
||||||
system(std::format("cd {} && lldb -o run {}", (projectPath/fs::path(binDir)).string(), project.name).c_str());
|
system(std::format("cd {} && lldb -o run {}", (fs::path(projectPath).parent_path()/binDir).string(), project.name).c_str());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue