added CLI
This commit is contained in:
parent
0cf068b896
commit
e108f0859b
3 changed files with 26 additions and 9 deletions
|
|
@ -114,12 +114,16 @@ void Project::Build(std::string configuration) {
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
system(std::format("clang++ {}-o {}/{}", files, config.outputDir, name).c_str());
|
system(std::format("clang++ {}-o {}/{}", files, config.outputDir, name).c_str());
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
throw std::runtime_error("Configuration: " + configuration + " not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Project Project::LoadFromJSON(std::string file) {
|
Project Project::LoadFromJSON(std::string file) {
|
||||||
|
if (!std::filesystem::exists(file)) {
|
||||||
|
throw std::runtime_error("Project file: " + file + " not found.");
|
||||||
|
}
|
||||||
std::ifstream f(file);
|
std::ifstream f(file);
|
||||||
nlohmann::json data = nlohmann::json::parse(f);
|
nlohmann::json data = nlohmann::json::parse(f);
|
||||||
const std::string name = data["name"].get<std::string>();
|
const std::string name = data["name"].get<std::string>();
|
||||||
|
|
|
||||||
7
build.sh
7
build.sh
|
|
@ -1,5 +1,5 @@
|
||||||
rm -rf ./build
|
mkdir build
|
||||||
mkdir build;
|
mkdir bin
|
||||||
clang++ -std=c++26 Crafter.Build-Configuration.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build-Configuration.pcm
|
clang++ -std=c++26 Crafter.Build-Configuration.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build-Configuration.pcm
|
||||||
clang++ -std=c++26 Crafter.Build-Project.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build-Project.pcm
|
clang++ -std=c++26 Crafter.Build-Project.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build-Project.pcm
|
||||||
clang++ -std=c++26 Crafter.Build.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build.pcm
|
clang++ -std=c++26 Crafter.Build.cppm --precompile -fprebuilt-module-path=./build -o ./build/Crafter.Build.pcm
|
||||||
|
|
@ -12,6 +12,3 @@ clang++ -std=c++26 ./build/Crafter.Build-Project.pcm -fprebuilt-module-path=./bu
|
||||||
clang++ -std=c++26 ./build/Crafter.Build-Configuration.pcm -fprebuilt-module-path=./build -c -o ./build/Crafter.Build-Configuration.o
|
clang++ -std=c++26 ./build/Crafter.Build-Configuration.pcm -fprebuilt-module-path=./build -c -o ./build/Crafter.Build-Configuration.o
|
||||||
clang++ -std=c++26 ./build/Crafter.Build.pcm -fprebuilt-module-path=./build -c -o ./build/Crafter.Build.o
|
clang++ -std=c++26 ./build/Crafter.Build.pcm -fprebuilt-module-path=./build -c -o ./build/Crafter.Build.o
|
||||||
clang++ ./build/main.o ./build/Crafter.Build.o ./build/Crafter.Build-Configuration.o ./build/Crafter.Build-Configuration_source.o ./build/Crafter.Build-Project.o ./build/Crafter.Build-Project_source.o -o ./bin/crafter-build
|
clang++ ./build/main.o ./build/Crafter.Build.o ./build/Crafter.Build-Configuration.o ./build/Crafter.Build-Configuration_source.o ./build/Crafter.Build-Project.o ./build/Crafter.Build-Project_source.o -o ./bin/crafter-build
|
||||||
rm -rf ./build
|
|
||||||
mkdir build;
|
|
||||||
#./bin/crafter-build
|
|
||||||
|
|
|
||||||
20
main.cpp
20
main.cpp
|
|
@ -1,10 +1,26 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <print>
|
||||||
#include "json.hpp"
|
#include "json.hpp"
|
||||||
import Crafter.Build;
|
import Crafter.Build;
|
||||||
using namespace Crafter::Build;
|
using namespace Crafter::Build;
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
Project project = Project::LoadFromJSON("/home/jorijn/repos/crafter-build/project.json");
|
if(argc == 1){
|
||||||
project.Build("debug");
|
std::println("No configuration provided, use --help for help");
|
||||||
|
} else if(argc == 2) {
|
||||||
|
if(std::string(argv[1]) == "--help"){
|
||||||
|
std::println("<configuration> to build this configuration with the defualt project filename \"project.json\"\n<configuration> <project> to build this configuration with the specified project filename\nhelp displays this help message");
|
||||||
|
} else {
|
||||||
|
Project project = Project::LoadFromJSON("./project.json");
|
||||||
|
project.Build(argv[1]);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if(argc == 3) {
|
||||||
|
Project project = Project::LoadFromJSON(argv[2]);
|
||||||
|
project.Build(argv[1]);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
std::println("Too many arguments provided");
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue