From fc5bab30ba4d77a5c040f2c461aa8b2dd5361482 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 24 Nov 2025 02:42:00 +0100 Subject: feat: system and CI improvements. Signed-off-by: Amlal El Mahrouss --- .github/workflows/system-ci.yml | 6 ++- README.md | 6 ++- compile_flags.txt | 3 +- dev/neboot | 2 +- dev/nebuild | 2 +- include/.keep | 0 lib/libocl | 2 +- lib/libsteps/dev/.keep | 0 lib/libsteps/dev/lib/defines.hpp | 13 ------- lib/libsteps/dev/lib/steps.hpp | 61 ------------------------------ lib/libsteps/include/.keep | 0 lib/libsteps/include/steps/config.hpp | 17 +++++++++ lib/libsteps/include/steps/steps.hpp | 71 +++++++++++++++++++++++++++++++++++ tools/StepsTool.cc | 36 ++++++++++++++++++ tools/steps.cc | 35 ----------------- tools/steps.toml | 2 +- 16 files changed, 138 insertions(+), 118 deletions(-) create mode 100644 include/.keep delete mode 100644 lib/libsteps/dev/.keep delete mode 100644 lib/libsteps/dev/lib/defines.hpp delete mode 100644 lib/libsteps/dev/lib/steps.hpp create mode 100644 lib/libsteps/include/.keep create mode 100644 lib/libsteps/include/steps/config.hpp create mode 100644 lib/libsteps/include/steps/steps.hpp create mode 100644 tools/StepsTool.cc delete mode 100644 tools/steps.cc diff --git a/.github/workflows/system-ci.yml b/.github/workflows/system-ci.yml index a8f19dc..17ac932 100644 --- a/.github/workflows/system-ci.yml +++ b/.github/workflows/system-ci.yml @@ -15,6 +15,8 @@ jobs: - uses: actions/checkout@v4 - name: Install Packages run: sudo apt-get install libboost-all-dev - - name: Build SuperNE + - name: Build SystemNe run: | - cd tools \ No newline at end of file + cd tools + nebuild steps.toml + ./steps.o --install-sysroot \ No newline at end of file diff --git a/README.md b/README.md index 947a4fd..b07ac6e 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,12 @@ The purpose is the following: - Hold the codebase in a single repository, it is way more maintable than a fragmented one. - Easier paths based on the `system` path, i.e (../nekernel -> /system/dev/nekernel) -- One system release is easier than releasing each component on its own. +- One central system release is easier than releasing each component on its own. -## Note: +## Notes - `dev` stands for develop, not the device directory. +- `include` is for libSystem and other installed library headers. +- `devices` and `network` are for network and standard devices on NeKernel. ###### Copyright 2025 - Amlal El Mahrouss & NeKernel.org Contributors. Licensed under Apache 2.0. diff --git a/compile_flags.txt b/compile_flags.txt index 6f5638b..fe075c4 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -5,5 +5,6 @@ -Idev/nebuild/dev -Idev/nekernel/dev -Idev/necti/dev --Ilib/libocl/dev/ +-Ilib/libsteps/include/ +-Ilib/libocl/include/ocl -I/opt/homebrew/Cellar/boost/1.89.0/include diff --git a/dev/neboot b/dev/neboot index 21aee2b..7625c62 160000 --- a/dev/neboot +++ b/dev/neboot @@ -1 +1 @@ -Subproject commit 21aee2b17cdd45c0dea247e0bf26a95767bc4470 +Subproject commit 7625c62c53fef869915499ed6332ded5d47608a0 diff --git a/dev/nebuild b/dev/nebuild index 28e3d9b..978e187 160000 --- a/dev/nebuild +++ b/dev/nebuild @@ -1 +1 @@ -Subproject commit 28e3d9b250a11cc1167683e6388d8cca715bb593 +Subproject commit 978e187043902c1e87a6e9c3d244dabdf6f749c7 diff --git a/include/.keep b/include/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/libocl b/lib/libocl index 9a70f32..85f89ee 160000 --- a/lib/libocl +++ b/lib/libocl @@ -1 +1 @@ -Subproject commit 9a70f32ddaec0eef99efbf7ff5597c2adf08f45a +Subproject commit 85f89ee4bb137100cbeffcbc10168eb8ea52e6cc diff --git a/lib/libsteps/dev/.keep b/lib/libsteps/dev/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/libsteps/dev/lib/defines.hpp b/lib/libsteps/dev/lib/defines.hpp deleted file mode 100644 index 4c7c38b..0000000 --- a/lib/libsteps/dev/lib/defines.hpp +++ /dev/null @@ -1,13 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -------------------------------------------- */ - -#pragma once - -#ifdef OCL_USE_UTF8 -#undef OCL_USE_UTF8 -#endif - -#include diff --git a/lib/libsteps/dev/lib/steps.hpp b/lib/libsteps/dev/lib/steps.hpp deleted file mode 100644 index ce6be51..0000000 --- a/lib/libsteps/dev/lib/steps.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -------------------------------------------- */ - -#pragma once - -#include -#include -#include - -#define kStepsExtension ".stp" -#define kStepsStrLen (256U) - -#define kStepsMagic " pls" -#define kStepsMagicLen (4U) -#define kStepsVersion (0x0100) - -namespace ocl::steps { -struct __attribute__((packed)) record final { - ocl::char_type magic[kStepsMagicLen] = {kStepsMagic[0], kStepsMagic[1], - kStepsMagic[2], kStepsMagic[3]}; - ocl::char_type name[kStepsStrLen] = ""; - ocl::char_type company[kStepsStrLen] = ""; - ocl::char_type author[kStepsStrLen] = ""; - int32_t version = 0; - int32_t pages = 0; - int32_t check_page = 0, eula_page = 0; -}; - -inline bool is_valid(record& r) noexcept { - return r.pages > 1 && r.version > 0 && strcmp(r.magic, kStepsMagic) == 0; -} - -namespace operators { -inline std::ifstream &operator>>(std::ifstream &f, record &r) { - f.read((char *)&r, sizeof(r)); - return f; -} - -inline std::ofstream &operator<<(std::ofstream &f, record &r) { - f.write((char *)&r, sizeof(r)); - return f; -} - -/// =========================================================== /// -/// @brief Equal operator for steps records. -/// =========================================================== /// -inline bool operator==(const record &r, const record &l) { - return (std::strncmp(r.magic, l.magic, kStepsMagicLen) == 0); -} - -/// =========================================================== /// -/// @brief Not equal operator for steps records. -/// =========================================================== /// -inline bool operator!=(const record &r, const record &l) { - return (std::strncmp(r.magic, l.magic, kStepsMagicLen) > 0); -} -} // namespace operators -} // namespace ocl::steps diff --git a/lib/libsteps/include/.keep b/lib/libsteps/include/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lib/libsteps/include/steps/config.hpp b/lib/libsteps/include/steps/config.hpp new file mode 100644 index 0000000..6eefe3c --- /dev/null +++ b/lib/libsteps/include/steps/config.hpp @@ -0,0 +1,17 @@ +/* ------------------------------------------- + +Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +------------------------------------------- */ + +#pragma once + +#ifdef OCL_USE_UTF8 +#undef OCL_USE_UTF8 +#endif + +#include + +#include +#include + diff --git a/lib/libsteps/include/steps/steps.hpp b/lib/libsteps/include/steps/steps.hpp new file mode 100644 index 0000000..c524149 --- /dev/null +++ b/lib/libsteps/include/steps/steps.hpp @@ -0,0 +1,71 @@ +/* ------------------------------------------- + +Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. + +------------------------------------------- */ + +#pragma once + +#include + +#define kStepsExtension ".stp" +#define kStepsStrLen (256U) + +#define kStepsMagic " pls" +#define kStepsMagicLen (4U) +#define kStepsVersion (0x0100) + +#ifdef __GNUC__ +#define STEPS_PACKED __attribute__((packed)) +#else +#define STEPS_PACKED +#endif + +namespace ocl::steps { +struct STEPS_PACKED record final { + ocl::char_type magic[kStepsMagicLen] = {kStepsMagic[0], kStepsMagic[1], + kStepsMagic[2], kStepsMagic[3]}; + ocl::char_type name[kStepsStrLen] = ""; + ocl::char_type company[kStepsStrLen] = ""; + ocl::char_type author[kStepsStrLen] = ""; + int32_t version = 0; + int32_t pages = 0; + int32_t check_page = 0, eula_page = 0; +}; + +inline bool is_valid(record& r) noexcept { + return r.pages > 1 && r.version > 0 && strcmp(r.magic, kStepsMagic) == 0; +} + +namespace operators { +/// =========================================================== /// +/// @brief Read operator for steps records. +/// =========================================================== /// +inline std::ifstream &operator>>(std::ifstream &f, record &r) { + f.read((char *)&r, sizeof(r)); + return f; +} + +/// =========================================================== /// +/// @brief Write operator for steps records. +/// =========================================================== /// +inline std::ofstream &operator<<(std::ofstream &f, record &r) { + f.write((char *)&r, sizeof(r)); + return f; +} + +/// =========================================================== /// +/// @brief Equal operator for steps records. +/// =========================================================== /// +inline bool operator==(const record &r, const record &l) { + return (std::strncmp(r.magic, l.magic, kStepsMagicLen) == 0); +} + +/// =========================================================== /// +/// @brief Not equal operator for steps records. +/// =========================================================== /// +inline bool operator!=(const record &r, const record &l) { + return (std::strncmp(r.magic, l.magic, kStepsMagicLen) > 0); +} +} // namespace operators +} // namespace ocl::steps diff --git a/tools/StepsTool.cc b/tools/StepsTool.cc new file mode 100644 index 0000000..ccad634 --- /dev/null +++ b/tools/StepsTool.cc @@ -0,0 +1,36 @@ +/* =========================================================== + + Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license + +=========================================================== */ + +#include +#include + +/// =========================================================== /// +/// Use operators from steps namespace to compare steps records. +/// =========================================================== /// +using namespace ocl::steps::operators; + +const auto kStepsFileRoot = "/system/install.stp"; + +/// =========================================================== /// +/// @brief Main function for running steps on NeKernel. +/// =========================================================== /// +int main(void) { + ocl::io::print("steps: running steps for program...\n"); + + std::ifstream file(kStepsFileRoot); + ocl::steps::record steps; + + file >> steps; + + if (!ocl::steps::is_valid(steps)) + return EXIT_FAILURE; + + /// AMLALE: Read steps from file and process them. + + ocl::io::print("steps: done.\n"); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/tools/steps.cc b/tools/steps.cc deleted file mode 100644 index 6b9a8f7..0000000 --- a/tools/steps.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* =========================================================== - -Copyright (C) 2025, Amlal El Mahrouss, licensed under the Apache 2.0 license. - -=========================================================== */ - -#include -#include - -/// =========================================================== /// -/// Use operators from steps namespace to compare steps records. -/// =========================================================== /// -using namespace ocl::steps::operators; - -const auto kStepsFileRoot = "/system/install.stp"; - -/// =========================================================== /// -/// @brief Main function for running steps on NeKernel. -/// =========================================================== /// -int main(void) { - ocl::io::print("steps: running steps for program...\n"); - - std::ifstream file(kStepsFileRoot); - ocl::steps::record steps; - - file >> steps; - - if (!ocl::steps::is_valid(steps)) return EXIT_FAILURE; - - /// AMLALE: Read steps from file and process them. - - ocl::io::print("steps: done.\n"); - - return EXIT_SUCCESS; -} \ No newline at end of file diff --git a/tools/steps.toml b/tools/steps.toml index f9e3734..4d0de7c 100644 --- a/tools/steps.toml +++ b/tools/steps.toml @@ -1,7 +1,7 @@ compiler_path = "clang++" compiler_std = "c++20" headers_path = [ "../lib", "../lib/libocl/dev/", "/opt/homebrew/Cellar/boost/1.89.0/include" ] -sources_path = [ "steps.cc" ] +sources_path = [ "StepsTool.cc" ] output_name = "steps.o" compiler_flags = [ "-fPIC" ] cpp_macros = [ "__NE_STEPS__" ] -- cgit v1.2.3