summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/manifest_builder.cxx71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/manifest_builder.cxx b/src/manifest_builder.cxx
new file mode 100644
index 0000000..ec60028
--- /dev/null
+++ b/src/manifest_builder.cxx
@@ -0,0 +1,71 @@
+//
+// main.cpp
+// buildme
+//
+// Created by Amlal on 6/20/24.
+//
+
+#include <sstream>
+#include <iostream>
+#include <fstream>
+
+#include <manifest_builder.hxx>
+
+#include <json.hxx>
+
+using json = nlohmann::json;
+
+int ManifestBuilder::buildJson(int argc, const char * argv[])
+{
+ std::cout << "buildme: ";
+ std::string path;
+
+ if (argc == 1)
+ {
+ std::cout << "no files, defaulting to build.json\n";
+ path = "./build.json";
+ }
+ else
+ {
+ path = argv[1];
+ }
+
+ try
+ {
+ std::ifstream fJson(path);
+ json buildme = json::parse(fJson);
+
+ std::string compiler = buildme["compiler_path"].get<std::string>();
+ std::cout << "choose toolchain: " << compiler << std::endl;
+
+ json headerSearchPath = buildme["headers_path"];
+ std::cout << "search path: " << headerSearchPath.dump() << std::endl;
+
+ json sourceFiles = buildme["sources_path"];
+ std::cout << "source files: " << sourceFiles.dump() << std::endl;
+
+ std::string cmdLine = compiler + " ";
+
+ for (auto sources : sourceFiles)
+ {
+ cmdLine += sources.get<std::string>() + " ";
+ }
+
+ for (auto sources : sourceFiles)
+ {
+ cmdLine += "-include=" + sources.get<std::string>() + " ";
+ }
+
+ cmdLine += "-std=" + buildme["compiler_std"].get<std::string>() + " ";
+
+ std::cout << "running: " << cmdLine << std::endl;
+
+ std::system(cmdLine.c_str());
+ }
+ catch (...)
+ {
+ return 1;
+ }
+
+ return 0;
+}