From de88c44c68f3941e003ddaf13042875370f10978 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 24 Apr 2025 13:38:05 +0200 Subject: dev, tooling: Improve the tools and frameworks on userspace. Details: - See commit details for more. Signed-off-by: Amlal El Mahrouss --- compile_flags.txt | 8 +- dev/kernel/KernelKit/PEF.h | 1 + dev/user/src/SystemCalls.cc | 1 + .../frameworks/CoreFoundation.fwrk/headers/Array.h | 2 +- public/tools/cc/cc.json | 2 +- public/tools/diutil/diutil.json | 2 +- public/tools/diutil/src/CommandLine.cc | 14 +-- public/tools/fwrkld/.keep | 0 public/tools/fwrkld/dist/.keep | 0 public/tools/fwrkld/fwrkld.json | 12 --- public/tools/fwrkld/src/CommandLine.cc | 14 --- public/tools/ld.dyn/.keep | 0 public/tools/ld.dyn/ld.dyn.json | 12 +++ public/tools/ld.dyn/src/CommandLine.cc | 47 ++++++++ public/tools/ld.fwrk/.keep | 0 public/tools/ld.fwrk/ld.fwrk.json | 12 +++ public/tools/ld.fwrk/src/CommandLine.cc | 20 ++++ public/tools/ld/.keep | 0 public/tools/ld/dist/.keep | 0 public/tools/ld/ld.json | 12 --- public/tools/ld/src/CommandLine.cc | 15 --- public/tools/make_app/Common.h | 12 --- public/tools/make_app/Framework.h | 17 --- public/tools/make_app/Steps.h | 32 ------ public/tools/make_app/dist/.keep | 0 public/tools/make_app/make_app.json | 12 --- public/tools/make_app/src/CommandLine.cc | 119 --------------------- public/tools/mk.fwrk/Common.h | 12 +++ public/tools/mk.fwrk/Framework.h | 17 +++ public/tools/mk.fwrk/Steps.h | 32 ++++++ public/tools/mk.fwrk/mk.fwrk.json | 18 ++++ public/tools/mk.fwrk/src/CommandLine.cc | 119 +++++++++++++++++++++ public/tools/mk.hefs/mk.hefs.json | 2 +- public/tools/mk.hefs/src/CommandLine.cc | 2 +- public/tools/mk.nefs/mk.nefs.json | 2 +- public/tools/mk.nefs/src/CommandLine.cc | 2 +- public/tools/open/src/CommandLine.cc | 12 +-- tooling/mk_app.py | 67 ------------ tooling/mk_fwrk.py | 67 ++++++++++++ 39 files changed, 384 insertions(+), 334 deletions(-) delete mode 100644 public/tools/fwrkld/.keep delete mode 100644 public/tools/fwrkld/dist/.keep delete mode 100644 public/tools/fwrkld/fwrkld.json delete mode 100644 public/tools/fwrkld/src/CommandLine.cc create mode 100644 public/tools/ld.dyn/.keep create mode 100644 public/tools/ld.dyn/ld.dyn.json create mode 100644 public/tools/ld.dyn/src/CommandLine.cc create mode 100644 public/tools/ld.fwrk/.keep create mode 100644 public/tools/ld.fwrk/ld.fwrk.json create mode 100644 public/tools/ld.fwrk/src/CommandLine.cc delete mode 100644 public/tools/ld/.keep delete mode 100644 public/tools/ld/dist/.keep delete mode 100644 public/tools/ld/ld.json delete mode 100644 public/tools/ld/src/CommandLine.cc delete mode 100644 public/tools/make_app/Common.h delete mode 100644 public/tools/make_app/Framework.h delete mode 100644 public/tools/make_app/Steps.h delete mode 100644 public/tools/make_app/dist/.keep delete mode 100644 public/tools/make_app/make_app.json delete mode 100644 public/tools/make_app/src/CommandLine.cc create mode 100644 public/tools/mk.fwrk/Common.h create mode 100644 public/tools/mk.fwrk/Framework.h create mode 100644 public/tools/mk.fwrk/Steps.h create mode 100644 public/tools/mk.fwrk/mk.fwrk.json create mode 100644 public/tools/mk.fwrk/src/CommandLine.cc delete mode 100755 tooling/mk_app.py create mode 100755 tooling/mk_fwrk.py diff --git a/compile_flags.txt b/compile_flags.txt index c72b1987..cef28da1 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -4,8 +4,12 @@ -Idev/boot -Idev/ddk -Ipublic/tools --Ipublic/tools/make_app --Ipublic/tools/make_fs +-Ipublic/tools/mk.app +-Ipublic/tools/mk.fwrk +-Ipublic/tools/mk.hefs +-Ipublic/tools/mk.nefs +-Ipublic/tools/ld.dyn +-Ipublic/tools/ld.fwrk -Ipublic/tools/open -Ipublic/frameworks -Idev/boot/BootKit diff --git a/dev/kernel/KernelKit/PEF.h b/dev/kernel/KernelKit/PEF.h index 1cfbfa54..0b2f5cb7 100644 --- a/dev/kernel/KernelKit/PEF.h +++ b/dev/kernel/KernelKit/PEF.h @@ -40,6 +40,7 @@ #define kPefBaseOrigin (0x40000000) #define kPefStart "__ImageStart" +#define kPefMainSymbol "_NeMain" #define kPefForkKind kPefMagic #define kPefForkKindFAT kPefMagicFat diff --git a/dev/user/src/SystemCalls.cc b/dev/user/src/SystemCalls.cc index 20eaa0e0..6b32bd70 100644 --- a/dev/user/src/SystemCalls.cc +++ b/dev/user/src/SystemCalls.cc @@ -103,6 +103,7 @@ IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) return *ret; } +/// @internal IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { if (!expr) diff --git a/public/frameworks/CoreFoundation.fwrk/headers/Array.h b/public/frameworks/CoreFoundation.fwrk/headers/Array.h index 4b8cdbb2..e9a36ac4 100644 --- a/public/frameworks/CoreFoundation.fwrk/headers/Array.h +++ b/public/frameworks/CoreFoundation.fwrk/headers/Array.h @@ -40,7 +40,7 @@ namespace CF { auto cnt = 0UL; - for (auto i = 0; i < N; ++i) + for (auto i = 0UL; i < N; ++i) { if (fArray[i]) ++cnt; diff --git a/public/tools/cc/cc.json b/public/tools/cc/cc.json index a40008ba..9e6da4c6 100644 --- a/public/tools/cc/cc.json +++ b/public/tools/cc/cc.json @@ -1,5 +1,5 @@ { - "compiler_path": "g++", + "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], diff --git a/public/tools/diutil/diutil.json b/public/tools/diutil/diutil.json index 19b845c5..a7a49697 100644 --- a/public/tools/diutil/diutil.json +++ b/public/tools/diutil/diutil.json @@ -1,5 +1,5 @@ { - "compiler_path": "g++", + "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"], "sources_path": ["src/CommandLine.cc", "../../../public/frameworks/DiskImage.fwrk/src/*.cc", "../../../dev/user/src/*.cc"], diff --git a/public/tools/diutil/src/CommandLine.cc b/public/tools/diutil/src/CommandLine.cc index 3e7353e6..ef0aaa2e 100644 --- a/public/tools/diutil/src/CommandLine.cc +++ b/public/tools/diutil/src/CommandLine.cc @@ -9,40 +9,40 @@ #include -static const Char kDiskName[kDIDiskNameLen] = "DISK"; +static const Char kDiskName[kDIDiskNameLen] = "Empty Disk"; static SInt32 kDiskSectorSz = kDISectorSz; static SizeT kDiskSz = gib_cast(4); static const Char kOutDisk[kDIOutNameLen] = "disk.eimg"; /// @brief Disk Utility entrypoint. -int main(int argc, char** argv) +SInt32 _NeMain(SInt32 argc, Char** argv) { for (SInt32 arg = 0; arg < argc; ++arg) { const Char* arg_s = argv[arg]; - if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "--disk-output-name", MmStrLen("--disk-output-name") == 0)) + if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "-diutil-output-name", MmStrLen("-diutil-output-name") == 0)) { if ((arg + 1) < argc) { MmCopyMemory((VoidPtr)kOutDisk, argv[arg + 1], kDIDiskNameLen); } } - else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "--disk-output-size", MmStrLen("--disk-output-size") == 0)) + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "-diutil-output-size", MmStrLen("-diutil-output-size") == 0)) { if ((arg + 1) < argc) { kDiskSz = StrMathToNumber(argv[arg + 1], nullptr, 10); } } - else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "--disk-sector-size", MmStrLen("--disk-sector-size") == 0)) + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "-diutil-sector-size", MmStrLen("-diutil-sector-size") == 0)) { if ((arg + 1) < argc) { kDiskSectorSz = StrMathToNumber(argv[arg + 1], nullptr, 10); } } - else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "--disk-part-name", MmStrLen("--disk-part-name") == 0)) + else if (MmCmpMemory((VoidPtr)arg_s, (VoidPtr) "-diutil-part-name", MmStrLen("-diutil-part-name") == 0)) { if ((arg + 1) < argc) { @@ -51,7 +51,7 @@ int main(int argc, char** argv) } } - // create disk image. + // create disk image, by appending an EPM partition to it. DI::DI_DISK_IMAGE img{}; diff --git a/public/tools/fwrkld/.keep b/public/tools/fwrkld/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/tools/fwrkld/dist/.keep b/public/tools/fwrkld/dist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/tools/fwrkld/fwrkld.json b/public/tools/fwrkld/fwrkld.json deleted file mode 100644 index 940c3a89..00000000 --- a/public/tools/fwrkld/fwrkld.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev"], - "sources_path": ["src/CommandLine.cc"], - "output_name": "./dist/fwrkld", - "cpp_macros": [ - "kLDVersion=0x0100", - "kLDVersionHighest=0x0100", - "kLDVersionLowest=0x0100" - ] -} diff --git a/public/tools/fwrkld/src/CommandLine.cc b/public/tools/fwrkld/src/CommandLine.cc deleted file mode 100644 index f86c0383..00000000 --- a/public/tools/fwrkld/src/CommandLine.cc +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Created on Thu Oct 17 08:00:42 CEST 2024 - * - * Copyright (c) 2024-2025 Amlal El Mahrouss - */ - -#include - -/// @brief This program loads a code framework into Kernel's memory. - -SInt32 main(SInt32 argc, Char* argv[]) -{ - return EXIT_FAILURE; -} diff --git a/public/tools/ld.dyn/.keep b/public/tools/ld.dyn/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/tools/ld.dyn/ld.dyn.json b/public/tools/ld.dyn/ld.dyn.json new file mode 100644 index 00000000..0ace838f --- /dev/null +++ b/public/tools/ld.dyn/ld.dyn.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev"], + "sources_path": ["src/CommandLine.cc"], + "output_name": "./dist/ld.dyn", + "cpp_macros": [ + "kLDVersion=0x0100", + "kLDVersionHighest=0x0100", + "kLDVersionLowest=0x0100" + ] +} diff --git a/public/tools/ld.dyn/src/CommandLine.cc b/public/tools/ld.dyn/src/CommandLine.cc new file mode 100644 index 00000000..90a79796 --- /dev/null +++ b/public/tools/ld.dyn/src/CommandLine.cc @@ -0,0 +1,47 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024-2025 Amlal El Mahrouss + */ + +#include + +/// @brief Library loader. + +#define DYNLIB_FLAG "-dyn" + +SInt32 _NeMain(SInt32 argc, Char* argv[]) +{ + SCI_UNUSED(argc); + SCI_UNUSED(argv); + + PrintOut(nullptr, "%s", "ld.dyn: Dynamic Loader.\n"); + PrintOut(nullptr, "%s", "ld.dyn: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); + + for (SInt32 i = 1U; i < argc; ++i) + { + if (MmStrCmp(argv[i], DYNLIB_FLAG) == 0) + { + UIntPtr ret = RtlSpawnProcess(argv[i], 0, nullptr, nullptr, 0); + + if (0 < ret) + { + return RtlSpawnIB(ret); + } + + PrintOut(nullptr, "%s", "ld.dyn: Failed to load the library.\n"); + PrintOut(nullptr, "%s", "ld.dyn: Make sure the library is valid.\n"); + + break; + } + else + { + PrintOut(nullptr, "%s", "ld.dyn: Invalid argument.\n"); + PrintOut(nullptr, "%s", "ld.dyn: Use -dyn to load a dynamic library.\n"); + + break; + } + } + + return EXIT_FAILURE; +} diff --git a/public/tools/ld.fwrk/.keep b/public/tools/ld.fwrk/.keep new file mode 100644 index 00000000..e69de29b diff --git a/public/tools/ld.fwrk/ld.fwrk.json b/public/tools/ld.fwrk/ld.fwrk.json new file mode 100644 index 00000000..b0a2d0e2 --- /dev/null +++ b/public/tools/ld.fwrk/ld.fwrk.json @@ -0,0 +1,12 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev"], + "sources_path": ["src/CommandLine.cc"], + "output_name": "./dist/ld.fwrk", + "cpp_macros": [ + "kLDVersion=0x0100", + "kLDVersionHighest=0x0100", + "kLDVersionLowest=0x0100" + ] +} diff --git a/public/tools/ld.fwrk/src/CommandLine.cc b/public/tools/ld.fwrk/src/CommandLine.cc new file mode 100644 index 00000000..cdb57133 --- /dev/null +++ b/public/tools/ld.fwrk/src/CommandLine.cc @@ -0,0 +1,20 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024-2025 Amlal El Mahrouss + */ + +#include + +/// @brief This program loads a code framework into Kernel's memory. + +SInt32 _NeMain(SInt32 argc, Char* argv[]) +{ + SCI_UNUSED(argc); + SCI_UNUSED(argv); + + PrintOut(nullptr, "%s", "ld.fwrk: Framework Loader.\n"); + PrintOut(nullptr, "%s", "ld.fwrk: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); + + return EXIT_FAILURE; +} diff --git a/public/tools/ld/.keep b/public/tools/ld/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/tools/ld/dist/.keep b/public/tools/ld/dist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/tools/ld/ld.json b/public/tools/ld/ld.json deleted file mode 100644 index 940c3a89..00000000 --- a/public/tools/ld/ld.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev"], - "sources_path": ["src/CommandLine.cc"], - "output_name": "./dist/fwrkld", - "cpp_macros": [ - "kLDVersion=0x0100", - "kLDVersionHighest=0x0100", - "kLDVersionLowest=0x0100" - ] -} diff --git a/public/tools/ld/src/CommandLine.cc b/public/tools/ld/src/CommandLine.cc deleted file mode 100644 index ace93ed3..00000000 --- a/public/tools/ld/src/CommandLine.cc +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Created on Thu Oct 17 08:00:42 CEST 2024 - * - * Copyright (c) 2024-2025 Amlal El Mahrouss - */ - -#include - -/// @brief Placeholder program. - -SInt32 main(SInt32 argc, Char* argv[]) -{ - PrintOut(nullptr, "ld: A linker to be installed.\rld: This program is present as a placeholder."); - return EXIT_FAILURE; -} diff --git a/public/tools/make_app/Common.h b/public/tools/make_app/Common.h deleted file mode 100644 index 09e374ee..00000000 --- a/public/tools/make_app/Common.h +++ /dev/null @@ -1,12 +0,0 @@ -/** - Sat Oct 26 07:03:28 AM CEST 2024 - (c) Amlal El Mahrouss. -*/ - -#ifndef APPS_COMMON_H -#define APPS_COMMON_H - -#include -#include - -#endif // APPS_COMMON_H diff --git a/public/tools/make_app/Framework.h b/public/tools/make_app/Framework.h deleted file mode 100644 index ab03d0bc..00000000 --- a/public/tools/make_app/Framework.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - Thu Oct 17 07:57:43 CEST 2024 - (c) Amlal El Mahrouss. -*/ - -#ifndef APPS_FRAMEWORK_H -#define APPS_FRAMEWORK_H - -#include - -#define kExecDirectory "bin/" -#define kRsrcDirectory "xml/" -#define kRootDirectory "/" -#define kFKExtension ".fwrk" -#define kAppExtension ".app" - -#endif // !APPS_FRAMEWORK_H diff --git a/public/tools/make_app/Steps.h b/public/tools/make_app/Steps.h deleted file mode 100644 index 51927def..00000000 --- a/public/tools/make_app/Steps.h +++ /dev/null @@ -1,32 +0,0 @@ -/** - Thu Oct 17 07:57:43 CEST 2024 - (c) Amlal El Mahrouss. -*/ - -#ifndef APPS_STEPS_H -#define APPS_STEPS_H - -#include -#include - -#define kStepsExtension ".stp" -#define kStepsStrLen (256U) - -#define kStepsMagic " pls" -#define kStepsMagicLen (4U) -#define kStepsVersion (0x0100) - -#define kStepsMime "ne-application-kind/steps" - -struct STEPS_COMMON_RECORD final -{ - Char magic[kStepsMagicLen]; - Char name[kStepsStrLen]; - Char company[kStepsStrLen]; - Char author[kStepsStrLen]; - SInt32 version; - SInt32 pages; - SInt32 check_page, eula_page; -}; - -#endif // ifndef APPS_STEPS_H \ No newline at end of file diff --git a/public/tools/make_app/dist/.keep b/public/tools/make_app/dist/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/public/tools/make_app/make_app.json b/public/tools/make_app/make_app.json deleted file mode 100644 index f40b9eff..00000000 --- a/public/tools/make_app/make_app.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev"], - "sources_path": ["src/CommandLine.cc"], - "output_name": "./dist/make_app", - "cpp_macros": [ - "kMKFVersion=0x0100", - "kMKFVersionHighest=0x0100", - "kMKFVersionLowest=0x0100" - ] -} diff --git a/public/tools/make_app/src/CommandLine.cc b/public/tools/make_app/src/CommandLine.cc deleted file mode 100644 index c30e02a0..00000000 --- a/public/tools/make_app/src/CommandLine.cc +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Created on Thu Oct 17 08:00:42 CEST 2024 - * - * Copyright (c) 2024-2025 Amlal El Mahrouss - */ - -#include -#include - -#include - -#include - -/// @brief This program makes a framework/app/steps directory for NeKernel OS. - -static Char* kStepsName = "Steps"; -static Char* kStepsAuthor = "John Doe"; -static Char* kStepsCompany = "Company, Inc"; - -int main(int argc, char* argv[]) -{ - CF::CFArray files; - - auto ext = kFKExtension; - - for (SizeT i = 2UL; i < argc; ++i) - { - if (MmStrCmp(argv[i], "-h") == 0) - { - PrintOut(nullptr, "%s", "make_app: Framework/Application Creation Tool.\n"); - PrintOut(nullptr, "%s", "make_app: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); - - PrintOut(nullptr, "%s", "make_app: -a: Application format.\n"); - PrintOut(nullptr, "%s", "make_app: -s: Steps (Setup pages) format.\n"); - PrintOut(nullptr, "%s", "make_app: -f: Framework format.\n"); - - return kErrorSuccess; - } - - if (MmStrCmp(argv[i], "--author") == 0) - { - MmCopyMemory(kStepsAuthor, const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); - continue; - } - - if (MmStrCmp(argv[i], "--company") == 0) - { - MmCopyMemory(kStepsCompany, const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); - continue; - } - - if (MmStrCmp(argv[i], "--name") == 0) - { - MmCopyMemory(kStepsName, const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); - continue; - } - - if (MmStrCmp(argv[i], "-a") == 0) - { - ext = kAppExtension; - continue; - } - else if (MmStrCmp(argv[i], "-s") == 0) - { - ext = kStepsExtension; - continue; - } - else if (MmStrCmp(argv[i], "-f") == 0) - { - ext = kFKExtension; - continue; - } - - files[i] = argv[i]; - } - - auto path = argv[1]; - - if (FsCreateDir(path)) - { - FsCreateDir(StrFmt("{}{}", path, kRootDirectory)); - FsCreateDir(StrFmt("{}{}", path, kExecDirectory)); - - if (MmStrCmp(ext, kStepsExtension) == 0) - { - FsCreateFile(StrFmt("{}{}{}{}", path, kRootDirectory, "_setup")); - - auto handle = IoOpenFile(StrFmt("{}{}{}{}", path, kRootDirectory, "_setup", kStepsExtension), nullptr); - - struct STEPS_COMMON_RECORD record; - - MmFillMemory(&record, sizeof(STEPS_COMMON_RECORD), 0); - - MmCopyMemory(record.name, const_cast(kStepsName), kStepsStrLen); - MmCopyMemory(record.author, const_cast(kStepsAuthor), kStepsStrLen); - MmCopyMemory(record.company, const_cast(kStepsCompany), kStepsStrLen); - - MmCopyMemory(record.magic, const_cast(kStepsMagic), kStepsMagicLen); - - record.version = kStepsVersion; - - IoWriteFile(handle, (void*)&record, sizeof(STEPS_COMMON_RECORD)); - IoCloseFile(handle); - - handle = nullptr; - } - - for (SInt32 i = 0; i < files.Count(); ++i) - { - auto& file = files[i]; - - FsCopy(path, StrFmt("{}{}", path, file)); - } - - return kErrorSuccess; - } - - return kErrorInternal; -} diff --git a/public/tools/mk.fwrk/Common.h b/public/tools/mk.fwrk/Common.h new file mode 100644 index 00000000..09e374ee --- /dev/null +++ b/public/tools/mk.fwrk/Common.h @@ -0,0 +1,12 @@ +/** + Sat Oct 26 07:03:28 AM CEST 2024 + (c) Amlal El Mahrouss. +*/ + +#ifndef APPS_COMMON_H +#define APPS_COMMON_H + +#include +#include + +#endif // APPS_COMMON_H diff --git a/public/tools/mk.fwrk/Framework.h b/public/tools/mk.fwrk/Framework.h new file mode 100644 index 00000000..ab03d0bc --- /dev/null +++ b/public/tools/mk.fwrk/Framework.h @@ -0,0 +1,17 @@ +/** + Thu Oct 17 07:57:43 CEST 2024 + (c) Amlal El Mahrouss. +*/ + +#ifndef APPS_FRAMEWORK_H +#define APPS_FRAMEWORK_H + +#include + +#define kExecDirectory "bin/" +#define kRsrcDirectory "xml/" +#define kRootDirectory "/" +#define kFKExtension ".fwrk" +#define kAppExtension ".app" + +#endif // !APPS_FRAMEWORK_H diff --git a/public/tools/mk.fwrk/Steps.h b/public/tools/mk.fwrk/Steps.h new file mode 100644 index 00000000..51927def --- /dev/null +++ b/public/tools/mk.fwrk/Steps.h @@ -0,0 +1,32 @@ +/** + Thu Oct 17 07:57:43 CEST 2024 + (c) Amlal El Mahrouss. +*/ + +#ifndef APPS_STEPS_H +#define APPS_STEPS_H + +#include +#include + +#define kStepsExtension ".stp" +#define kStepsStrLen (256U) + +#define kStepsMagic " pls" +#define kStepsMagicLen (4U) +#define kStepsVersion (0x0100) + +#define kStepsMime "ne-application-kind/steps" + +struct STEPS_COMMON_RECORD final +{ + Char magic[kStepsMagicLen]; + Char name[kStepsStrLen]; + Char company[kStepsStrLen]; + Char author[kStepsStrLen]; + SInt32 version; + SInt32 pages; + SInt32 check_page, eula_page; +}; + +#endif // ifndef APPS_STEPS_H \ No newline at end of file diff --git a/public/tools/mk.fwrk/mk.fwrk.json b/public/tools/mk.fwrk/mk.fwrk.json new file mode 100644 index 00000000..f7f0ba8c --- /dev/null +++ b/public/tools/mk.fwrk/mk.fwrk.json @@ -0,0 +1,18 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++", + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev", "../../../public/frameworks"], + "sources_path": ["src/CommandLine.cc"], + "compiler_flags": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-fPIC" + ], + "output_name": "./dist/mk.fwrk", + "cpp_macros": [ + "kMKAppVersion=0x0100", + "kMKAppVersionHighest=0x0100", + "kMKAppVersionLowest=0x0100" + ] +} diff --git a/public/tools/mk.fwrk/src/CommandLine.cc b/public/tools/mk.fwrk/src/CommandLine.cc new file mode 100644 index 00000000..8f142dfb --- /dev/null +++ b/public/tools/mk.fwrk/src/CommandLine.cc @@ -0,0 +1,119 @@ +/* + * Created on Thu Oct 17 08:00:42 CEST 2024 + * + * Copyright (c) 2024-2025 Amlal El Mahrouss + */ + +#include +#include + +#include + +#include + +/// @brief This program makes a framework/app/steps directory for NeKernel OS. + +static const Char* kStepsName = "Steps"; +static const Char* kStepsAuthor = "John Doe"; +static const Char* kStepsCompany = "Company, Inc"; + +SInt32 _NeMain(SInt32 argc, Char* argv[]) +{ + CF::CFArray files; + + auto ext = kFKExtension; + + for (SInt32 i = 2UL; i < argc; ++i) + { + if (MmStrCmp(argv[i], "-h") == 0) + { + PrintOut(nullptr, "%s", "make_app: Framework/Application Creation Tool.\n"); + PrintOut(nullptr, "%s", "make_app: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); + + PrintOut(nullptr, "%s", "make_app: -a: Application Directory.\n"); + PrintOut(nullptr, "%s", "make_app: -s: Steps (Setup pages) Directory.\n"); + PrintOut(nullptr, "%s", "make_app: -f: Framework Directory.\n"); + + return kErrorSuccess; + } + + if (MmStrCmp(argv[i], "--author") == 0) + { + MmCopyMemory(const_cast(kStepsAuthor), const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); + continue; + } + + if (MmStrCmp(argv[i], "--company") == 0) + { + MmCopyMemory(const_cast(kStepsCompany), const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); + continue; + } + + if (MmStrCmp(argv[i], "--name") == 0) + { + MmCopyMemory(const_cast(kStepsName), const_cast(argv[i + 1]), MmStrLen(argv[i + 1])); + continue; + } + + if (MmStrCmp(argv[i], "-a") == 0) + { + ext = kAppExtension; + continue; + } + else if (MmStrCmp(argv[i], "-s") == 0) + { + ext = kStepsExtension; + continue; + } + else if (MmStrCmp(argv[i], "-f") == 0) + { + ext = kFKExtension; + continue; + } + + files[i] = argv[i]; + } + + auto path = argv[1]; + + if (FsCreateDir(path)) + { + FsCreateDir(StrFmt("{}{}", path, kRootDirectory)); + FsCreateDir(StrFmt("{}{}", path, kExecDirectory)); + + if (MmStrCmp(ext, kStepsExtension) == 0) + { + FsCreateFile(StrFmt("{}{}{}{}", path, kRootDirectory, "_setup")); + + auto handle = IoOpenFile(StrFmt("{}{}{}{}", path, kRootDirectory, "_setup", kStepsExtension), nullptr); + + struct STEPS_COMMON_RECORD record; + + MmFillMemory(&record, sizeof(STEPS_COMMON_RECORD), 0); + + MmCopyMemory(record.name, const_cast(kStepsName), kStepsStrLen); + MmCopyMemory(record.author, const_cast(kStepsAuthor), kStepsStrLen); + MmCopyMemory(record.company, const_cast(kStepsCompany), kStepsStrLen); + + MmCopyMemory(record.magic, const_cast(kStepsMagic), kStepsMagicLen); + + record.version = kStepsVersion; + + IoWriteFile(handle, (void*)&record, sizeof(STEPS_COMMON_RECORD)); + IoCloseFile(handle); + + handle = nullptr; + } + + for (auto i = 0UL; i < files.Count(); ++i) + { + auto& file = files[i]; + + FsCopy(path, StrFmt("{}{}", path, file)); + } + + return kErrorSuccess; + } + + return kErrorInternal; +} diff --git a/public/tools/mk.hefs/mk.hefs.json b/public/tools/mk.hefs/mk.hefs.json index 03f925cf..9fed938c 100644 --- a/public/tools/mk.hefs/mk.hefs.json +++ b/public/tools/mk.hefs/mk.hefs.json @@ -1,5 +1,5 @@ { - "compiler_path": "g++", + "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], diff --git a/public/tools/mk.hefs/src/CommandLine.cc b/public/tools/mk.hefs/src/CommandLine.cc index 8ce77208..0c30e1b1 100644 --- a/public/tools/mk.hefs/src/CommandLine.cc +++ b/public/tools/mk.hefs/src/CommandLine.cc @@ -8,7 +8,7 @@ /// @brief Placeholder program. -SInt32 main(SInt32 argc, Char* argv[]) +SInt32 _NeMain(SInt32 argc, Char* argv[]) { SCI_UNUSED(argc); SCI_UNUSED(argv); diff --git a/public/tools/mk.nefs/mk.nefs.json b/public/tools/mk.nefs/mk.nefs.json index e92e0b9c..62a4e93c 100644 --- a/public/tools/mk.nefs/mk.nefs.json +++ b/public/tools/mk.nefs/mk.nefs.json @@ -1,5 +1,5 @@ { - "compiler_path": "g++", + "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", "headers_path": ["./", "../../../dev"], "sources_path": ["src/CommandLine.cc"], diff --git a/public/tools/mk.nefs/src/CommandLine.cc b/public/tools/mk.nefs/src/CommandLine.cc index 8ce77208..0c30e1b1 100644 --- a/public/tools/mk.nefs/src/CommandLine.cc +++ b/public/tools/mk.nefs/src/CommandLine.cc @@ -8,7 +8,7 @@ /// @brief Placeholder program. -SInt32 main(SInt32 argc, Char* argv[]) +SInt32 _NeMain(SInt32 argc, Char* argv[]) { SCI_UNUSED(argc); SCI_UNUSED(argv); diff --git a/public/tools/open/src/CommandLine.cc b/public/tools/open/src/CommandLine.cc index 7ba7b7f6..b3779c71 100644 --- a/public/tools/open/src/CommandLine.cc +++ b/public/tools/open/src/CommandLine.cc @@ -13,19 +13,19 @@ #define OPEN_APP_HELP_FLAG "-h" #define OPEN_APP_BASE_PATH "/app/" -SInt32 main(SInt32 argc, Char* argv[]) +SInt32 _NeMain(SInt32 argc, Char* argv[]) { if (argc == 1) return EXIT_FAILURE; - for (SizeT i = 1UL; i < argc; ++i) + PrintOut(nullptr, "open: Open Loader.\n"); + PrintOut(nullptr, "open: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); + + for (SInt32 i = 1U; i < argc; ++i) { if (MmStrCmp(argv[i], OPEN_APP_HELP_FLAG) == 0) { - PrintOut(nullptr, "open: open .app(s) directories.\n"); - PrintOut(nullptr, "open: © 2024-2025 Amlal El Mahrouss, All rights reserved.\n"); - - PrintOut(nullptr, "open: %s: Application is being taken as the input (opens a PEF/PE32+/ELF program depending on the CPU architecture).\n", OPEN_APP_APP_FLAG); + PrintOut(nullptr, "open: %s: Application is being taken as the input (opens a PEF/PE32+ program depending on the CPU architecture).\n", OPEN_APP_APP_FLAG); return EXIT_SUCCESS; } diff --git a/tooling/mk_app.py b/tooling/mk_app.py deleted file mode 100755 index 34a7702e..00000000 --- a/tooling/mk_app.py +++ /dev/null @@ -1,67 +0,0 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- - -import os -import json -import sys - -def create_directory_structure(base_path, project_name): - # Define the directory structure - structure = { - project_name: { - "src": { - ".keep": None - }, - "vendor": { - ".keep": None - }, - ".keep": None, - f"{project_name}.json": {} - } - } - - def create_structure(path, structure): - for name, content in structure.items(): - current_path = os.path.join(path, name) - # Create directories or files based on the content type - if isinstance(content, dict) and current_path.endswith(".json") == False: - os.makedirs(current_path, exist_ok=True) - create_structure(current_path, content) - elif content is None: - # Create an empty file - with open(current_path, 'w') as f: - pass - - # Create the base directory - os.makedirs(base_path, exist_ok=True) - create_structure(base_path, structure) - - # Create the JSON file - diutil_json_path = os.path.join(base_path, project_name, f"{project_name}.json") - manifest = { - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"], - "sources_path": [ - - ], - "output_name": f"./dist/{project_name}", - "cpp_macros": [ - "kSampleVersion=0x0100", - "kSampleVersionHighest=0x0100", - "kSampleVersionLowest=0x0100", - "__NE_SDK__" - ] - } - - with open(diutil_json_path, 'w') as json_file: - json.dump(manifest, json_file, indent=4) - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Usage: mk_app.py ") - sys.exit(1) - - base_path = os.getcwd() # Use the current working directory as the base path - create_directory_structure(base_path, sys.argv[1]) - print("Ne application created successfully.") \ No newline at end of file diff --git a/tooling/mk_fwrk.py b/tooling/mk_fwrk.py new file mode 100755 index 00000000..5f519237 --- /dev/null +++ b/tooling/mk_fwrk.py @@ -0,0 +1,67 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- + +import os +import json +import sys + +def create_directory_structure(base_path, project_name): + # Define the directory structure + structure = { + project_name: { + "src": { + ".keep": None + }, + "vendor": { + ".keep": None + }, + ".keep": None, + f"{project_name}.json": {} + } + } + + def create_structure(path, structure): + for name, content in structure.items(): + current_path = os.path.join(path, name) + # Create directories or files based on the content type + if isinstance(content, dict) and current_path.endswith(".json") == False: + os.makedirs(current_path, exist_ok=True) + create_structure(current_path, content) + elif content is None: + # Create an empty file + with open(current_path, 'w') as f: + pass + + # Create the base directory + os.makedirs(base_path, exist_ok=True) + create_structure(base_path, structure) + + # Create the JSON file + diutil_json_path = os.path.join(base_path, project_name, f"{project_name}.json") + manifest = { + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": ["./", "../../../dev/kernel", "../../../public/frameworks/", "../../../dev/", "./"], + "sources_path": [ + + ], + "output_name": f"./dist/{project_name}", + "cpp_macros": [ + "kSampleVersion=0x0100", + "kSampleVersionHighest=0x0100", + "kSampleVersionLowest=0x0100", + "__NE_SDK__" + ] + } + + with open(diutil_json_path, 'w') as json_file: + json.dump(manifest, json_file, indent=4) + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: mk_fwrk.py ") + sys.exit(1) + + base_path = os.getcwd() # Use the current working directory as the base path + create_directory_structure(base_path, sys.argv[1]) + print("Ne application created successfully.") \ No newline at end of file -- cgit v1.2.3