From 02fd0b59edbcb2b5c08ab1f36bbffc12ba08a5d3 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 25 Dec 2024 09:58:00 +0100 Subject: IMPL: New tool for ZkaOS 'make_container' Signed-off-by: Amlal El Mahrouss --- public/tools/Common.h | 19 ++++++++++ public/tools/Framework.h | 17 +++++++++ public/tools/Steps.h | 14 +++++++ public/tools/make_application.sh | 3 ++ public/tools/make_container.json | 12 ++++++ public/tools/src/CLI.cc | 81 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 146 insertions(+) create mode 100644 public/tools/Common.h create mode 100644 public/tools/Framework.h create mode 100644 public/tools/Steps.h create mode 100644 public/tools/make_application.sh create mode 100644 public/tools/make_container.json create mode 100644 public/tools/src/CLI.cc (limited to 'public') 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 +#include +#include +#include +#include +#include +#include +#include +#include + +#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 + +#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 +#include + +#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 +#include + +/// @brief This program makes a framework directory for ZKA OS. + +int main(int argc, char* argv[]) +{ + std::vector 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; +} -- cgit v1.2.3