summaryrefslogtreecommitdiffhomepage
path: root/public/tools
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-25 09:58:00 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-12-25 09:58:00 +0100
commit02fd0b59edbcb2b5c08ab1f36bbffc12ba08a5d3 (patch)
tree8999218261cf83ccad14e51bf101827c48ea7ead /public/tools
parentc517a9192a08f40ec6c2c387e98f3ea18bb28f4e (diff)
IMPL: New tool for ZkaOS 'make_container'
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'public/tools')
-rw-r--r--public/tools/Common.h19
-rw-r--r--public/tools/Framework.h17
-rw-r--r--public/tools/Steps.h14
-rw-r--r--public/tools/make_application.sh3
-rw-r--r--public/tools/make_container.json12
-rw-r--r--public/tools/src/CLI.cc81
6 files changed, 146 insertions, 0 deletions
diff --git a/public/tools/Common.h b/public/tools/Common.h
new file mode 100644
index 00000000..2633df38
--- /dev/null
+++ b/public/tools/Common.h
@@ -0,0 +1,19 @@
+/**
+ Sat Oct 26 07:03:28 AM CEST 2024
+ (c) Theater Quality Inc.
+*/
+
+#ifndef APPS_COMMON_H
+#define APPS_COMMON_H
+
+#include <cstdint>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <cstring>
+#include <sstream>
+#include <filesystem>
+#include <cstdlib>
+#include <vector>
+
+#endif // APPS_COMMON_H
diff --git a/public/tools/Framework.h b/public/tools/Framework.h
new file mode 100644
index 00000000..d5d7ac27
--- /dev/null
+++ b/public/tools/Framework.h
@@ -0,0 +1,17 @@
+/**
+ Thu Oct 17 07:57:43 CEST 2024
+ (c) Theater Quality Inc.
+*/
+
+#ifndef APPS_FRAMEWORK_H
+#define APPS_FRAMEWORK_H
+
+#include <Common.h>
+
+#define kExecDirectory "ML/Exec/"
+#define kRsrcDirectory "ML/Resources/"
+#define kRootDirectory "ML/"
+#define kFKExtension ".fwrk"
+#define kAppExtension ".app"
+
+#endif // !APPS_FRAMEWORK_H
diff --git a/public/tools/Steps.h b/public/tools/Steps.h
new file mode 100644
index 00000000..be16b61a
--- /dev/null
+++ b/public/tools/Steps.h
@@ -0,0 +1,14 @@
+/**
+ Thu Oct 17 07:57:43 CEST 2024
+ (c) Theater Quality Inc.
+*/
+
+#ifndef APPS_STEPS_H
+#define APPS_STEPS_H
+
+#include <Common.h>
+#include <Framework.h>
+
+#define kStepsExtension ".steps"
+
+#endif // ifndef APPS_STEPS_H \ No newline at end of file
diff --git a/public/tools/make_application.sh b/public/tools/make_application.sh
new file mode 100644
index 00000000..2878f5b6
--- /dev/null
+++ b/public/tools/make_application.sh
@@ -0,0 +1,3 @@
+# !/bin/sh
+
+cp make_framework.o make_application.o \ No newline at end of file
diff --git a/public/tools/make_container.json b/public/tools/make_container.json
new file mode 100644
index 00000000..1f66e5af
--- /dev/null
+++ b/public/tools/make_container.json
@@ -0,0 +1,12 @@
+{
+ "compiler_path": "g++",
+ "compiler_std": "c++20",
+ "headers_path": ["./"],
+ "sources_path": ["src/CLI.cc"],
+ "output_name": "make_container",
+ "cpp_macros": [
+ "kMKFVersion=0x0100",
+ "kMKFVersionHighest=0x0100",
+ "kMKFVersionLowest=0x0100"
+ ]
+}
diff --git a/public/tools/src/CLI.cc b/public/tools/src/CLI.cc
new file mode 100644
index 00000000..b7f2b853
--- /dev/null
+++ b/public/tools/src/CLI.cc
@@ -0,0 +1,81 @@
+/*
+ * Created on Thu Oct 17 08:00:42 CEST 2024
+ *
+ * Copyright (c) 2024 Theater Quality Inc
+ */
+
+#include <Framework.h>
+#include <Steps.h>
+
+/// @brief This program makes a framework directory for ZKA OS.
+
+int main(int argc, char* argv[])
+{
+ std::vector<std::string> files;
+
+ auto ext = kFKExtension;
+
+ for (size_t i = 2UL; i < argc; ++i)
+ {
+ if (strcmp(argv[i], "-h") == 0)
+ {
+ std::cout << "make_container: Framework/Application Creation Tool.\n";
+ std::cout << "make_container: © Theater Quality Inc, All rights reserved.\n";
+
+ std::cout << "make_container: -app: Application directory.\n";
+ std::cout << "make_container: -steps: Steps directory.\n";
+ std::cout << "make_container: -fwrk: Framework directory.\n";
+
+ return EXIT_SUCCESS;
+ }
+
+ if (strcmp(argv[i], "-app") == 0)
+ {
+ ext = kAppExtension;
+ continue;
+ }
+ else if (strcmp(argv[i], "-steps") == 0)
+ {
+ ext = kStepsExtension;
+ continue;
+ }
+ else if (strcmp(argv[i], "-fwrk") == 0)
+ {
+ ext = kFKExtension;
+ continue;
+ }
+
+
+ files.push_back(argv[i]);
+ }
+
+ auto path = std::string(argv[1]);
+
+ if (!std::filesystem::exists(path))
+ return EXIT_FAILURE;
+
+ std::filesystem::path path_arg = path + ext;
+
+ if (std::filesystem::create_directory(path_arg))
+ {
+ std::filesystem::create_directory(path_arg / kRootDirectory);
+ std::filesystem::create_directory(path_arg / kExecDirectory);
+
+ for (auto& file : files)
+ {
+ std::string file_cpy = file;
+
+ while (file_cpy.find("/") != std::string::npos)
+ {
+ file_cpy.erase(0, file_cpy.find("/"));
+ file_cpy.erase(file_cpy.find("/"), 1);
+ }
+
+ std::filesystem::copy(path, path_arg / kExecDirectory / file_cpy);
+ }
+
+ return EXIT_SUCCESS;
+ }
+
+ return EXIT_FAILURE;
+}