summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:33:21 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-24 02:34:02 +0100
commit64b8a6bf04095d80b1ca52415ea954b933f47098 (patch)
tree0fdeb080c08113558b6550cf06b81ba67d9c9348 /dev
parentfab2f2a4b616b9bd763b154605685733c74d7321 (diff)
feat! breaking changes, merging to stable.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/BuildKit/Defines.h34
-rw-r--r--dev/BuildKit/IManifestBuilder.h39
-rw-r--r--dev/BuildKit/Imports.h23
-rw-r--r--dev/BuildKit/JSONManifestBuilder.h39
-rw-r--r--dev/BuildKit/TOMLManifestBuilder.h39
-rw-r--r--dev/cli/AppMain.cc83
-rw-r--r--dev/src/IManifestBuilder.cc6
-rw-r--r--dev/src/JSONManifestBuilder.cc111
-rw-r--r--dev/src/TOMLManifestBuilder.cc115
9 files changed, 0 insertions, 489 deletions
diff --git a/dev/BuildKit/Defines.h b/dev/BuildKit/Defines.h
deleted file mode 100644
index 1c88ceb..0000000
--- a/dev/BuildKit/Defines.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#pragma once
-
-#include <BuildKit/Imports.h>
-
-/// =========================================================== ///
-/// @brief Defines file
-/// =========================================================== ///
-
-#define LIKELY(ARG) ((ARG) ? assert(false) : ((void) 0))
-#define UNLIKELY(ARG) LIKELY(!(ARG))
-
-#define LIBNEBUILD_VERSION "v0.0.7-buildkit"
-
-#define LIBNEBUILD_VERSION_BCD 0x0007
-
-#define LIBNEBUILD_VERSION_MAJOR 1
-#define LIBNEBUILD_VERSION_MINOR 1
-#define LIBNEBUILD_VERSION_PATCH 0
-
-#define LIBNEBUILD_UNUSED(X) ((void) X)
-
-namespace NeBuild::Logger {
-/// @brief replacement for std::cout for NeBuild logging.
-inline std::ostream& info() noexcept {
- auto& out = std::cout;
- out << rang::fg::red << "nebuild: " << rang::style::reset;
- return out;
-}
-} // namespace NeBuild::Logger
diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h
deleted file mode 100644
index abb389f..0000000
--- a/dev/BuildKit/IManifestBuilder.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#pragma once
-
-#include <BuildKit/Defines.h>
-
-#define NEBUILD_MANIFEST_BUILDER : public ::NeBuild::IManifestBuilder
-
-namespace NeBuild {
-/// =========================================================== ///
-/// @brief Builder interface class.
-/// @note This class is meant to be used as an interface.
-/// =========================================================== ///
-class IManifestBuilder {
- public:
- IManifestBuilder() = default;
- virtual ~IManifestBuilder() = default;
-
- IManifestBuilder& operator=(const IManifestBuilder&) = default;
- IManifestBuilder(const IManifestBuilder&) = default;
-
- /// =========================================================== ///
- /// @brief Builds a TOML target from a file.
- /// @param arg_sz filename size (must be 1 or greater).
- /// @param arg_val filename path (must be a valid language file).
- /// @retval true building has succeeded.
- /// @retval false fail to build, see error message.
- /// =========================================================== ///
- virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0;
-
- /// =========================================================== ///
- /// @brief Returns the build system name.
- /// =========================================================== ///
- virtual const char* BuildSystem() = 0;
-};
-} // namespace NeBuild \ No newline at end of file
diff --git a/dev/BuildKit/Imports.h b/dev/BuildKit/Imports.h
deleted file mode 100644
index 33e1e31..0000000
--- a/dev/BuildKit/Imports.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#ifndef NEBUILD_INCLUDES_H
-#define NEBUILD_INCLUDES_H
-
-/// =========================================================== ///
-/// @brief Imports file
-/// =========================================================== ///
-
-#include <rang/rang.h>
-#include <cassert>
-#include <cstddef>
-#include <cstdio>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <thread>
-
-#endif // NEBUILD_INCLUDES_H
diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h
deleted file mode 100644
index 438bdab..0000000
--- a/dev/BuildKit/JSONManifestBuilder.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#pragma once
-
-#include <BuildKit/IManifestBuilder.h>
-#include <json/json.h>
-
-/// @file JSONManifestBuilder.h
-/// @brief JSON manifest builder header file.
-
-namespace NeBuild {
-/// @brief JSON builder
-class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER {
- public:
- JSONManifestBuilder() = default;
- ~JSONManifestBuilder() override = default;
-
- JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default;
- JSONManifestBuilder(const JSONManifestBuilder&) = default;
-
- public:
- /// =========================================================== ///
- /// @brief Builds a JSON target from a JSON file.
- /// @param arg_sz filename size (must be 1 or greater).
- /// @param arg_val filename path (must be a valid JSON file).
- /// @retval true building has succeeded.
- /// @retval false fail to build, see error message.
- /// =========================================================== ///
- bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
-
- /// =========================================================== ///
- /// @brief Returns the build system name.
- /// =========================================================== ///
- const char* BuildSystem() override;
-};
-} // namespace NeBuild \ No newline at end of file
diff --git a/dev/BuildKit/TOMLManifestBuilder.h b/dev/BuildKit/TOMLManifestBuilder.h
deleted file mode 100644
index 7c508fc..0000000
--- a/dev/BuildKit/TOMLManifestBuilder.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#pragma once
-
-#include <BuildKit/IManifestBuilder.h>
-#include <toml++/toml.hpp>
-
-/// @file TOMLManifestBuilder.h
-/// @brief TOML manifest builder header file.
-
-namespace NeBuild {
-/// @brief TOML builder
-class TOMLManifestBuilder final NEBUILD_MANIFEST_BUILDER {
- public:
- TOMLManifestBuilder() = default;
- ~TOMLManifestBuilder() override = default;
-
- TOMLManifestBuilder& operator=(const TOMLManifestBuilder&) = default;
- TOMLManifestBuilder(const TOMLManifestBuilder&) = default;
-
- public:
- /// =========================================================== ///
- /// @brief Builds a TOML target from a TOML file.
- /// @param arg_sz filename size (must be 1 or greater).
- /// @param arg_val filename path (must be a valid TOML file).
- /// @retval true building has succeeded.
- /// @retval false fail to build, see error message.
- /// =========================================================== ///
- bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
-
- /// =========================================================== ///
- /// @brief Returns the build system name.
- /// =========================================================== ///
- const char* BuildSystem() override;
-};
-} // namespace NeBuild \ No newline at end of file
diff --git a/dev/cli/AppMain.cc b/dev/cli/AppMain.cc
deleted file mode 100644
index afd912e..0000000
--- a/dev/cli/AppMain.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#include <BuildKit/JSONManifestBuilder.h>
-#include <BuildKit/TOMLManifestBuilder.h>
-
-static bool kFailed = false;
-static bool kDryRun = false;
-
-int main(int argc, char** argv) {
- if (argc <= 1) return EXIT_FAILURE;
-
- for (size_t index = 1; index < argc; ++index) {
- std::string index_path = argv[index];
-
- if (index_path == "-v" || index_path == "-version") {
- NeBuild::Logger::info() << "NeKernel Build.\n";
- NeBuild::Logger::info()
- << "Bugs or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n";
-
- return EXIT_SUCCESS;
- } else if (index_path == "-dry-run" || index_path == "-n") {
- kDryRun = true;
- continue;
- } else if (index_path == "-h" || index_path == "-help") {
- NeBuild::Logger::info() << "usage: nebuild <file>\n";
-
- return EXIT_SUCCESS;
- }
-
- if (index_path.starts_with("-")) {
- NeBuild::Logger::info() << "error: unknown option '" << index_path << "'\n";
-
- return EXIT_FAILURE;
- }
-
- std::thread job_build_thread(
- [](std::string index_path) -> void {
- NeBuild::IManifestBuilder* builder = nullptr;
-
- const auto kJsonExtension = ".json";
-
- if (index_path.ends_with(kJsonExtension)) {
- builder = new NeBuild::JSONManifestBuilder();
-
- if (!builder) {
- kFailed = true;
- return;
- }
- } else {
- const auto kTomlExtension = ".toml";
- builder = new NeBuild::TOMLManifestBuilder();
-
- if (index_path.ends_with(kTomlExtension)) {
- goto end;
- } else {
- NeBuild::Logger::info()
- << "error: file '" << index_path << "' is not a manifest file!" << std::endl;
- kFailed = true;
- return;
- }
- }
-
- end:
- NeBuild::Logger::info() << "building manifest: " << index_path << std::endl;
-
- if (builder && !builder->BuildTarget(index_path, kDryRun)) {
- kFailed = true;
- }
-
- delete builder;
- builder = nullptr;
- },
- index_path);
-
- job_build_thread.join();
- }
-
- return kFailed ? EXIT_FAILURE : EXIT_SUCCESS;
-}
diff --git a/dev/src/IManifestBuilder.cc b/dev/src/IManifestBuilder.cc
deleted file mode 100644
index 745e81d..0000000
--- a/dev/src/IManifestBuilder.cc
+++ /dev/null
@@ -1,6 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#include <BuildKit/IManifestBuilder.h>
diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc
deleted file mode 100644
index d54653b..0000000
--- a/dev/src/JSONManifestBuilder.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#include <BuildKit/JSONManifestBuilder.h>
-
-using namespace NeBuild;
-using namespace nlohmann;
-
-using JSON = json;
-namespace FS = std::filesystem;
-
-/// =========================================================== ///
-/// @brief Builds a JSON target from a JSON file.
-/// @param arg_sz filename size (must be 1 or greater).
-/// @param arg_val filename path (must be a valid JSON file).
-/// @retval true building has succeeded.
-/// @retval false fail to build, see error message.
-/// =========================================================== ///
-bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) {
- std::string path;
-
- if (argv_val.empty()) {
- NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl;
- return false;
- } else {
- path = argv_val;
-
- if (!FS::exists(path)) {
- NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist"
- << std::endl;
- return false;
- }
- }
-
- try {
- std::ifstream json(path);
-
- if (!json.good()) {
- NeBuild::Logger::info() << "nebuild: error: file '" << path << "' is not a valid JSON"
- << std::endl;
- return false;
- }
-
- JSON json_obj = JSON::parse(json);
-
- std::string compiler = json_obj["compiler_path"].get<std::string>();
-
- std::string command = compiler + " ";
-
- JSON header_search_path = json_obj["compiler_headers_path"];
-
- for (auto& headers : header_search_path) {
- command += "-I" + headers.get<std::string>() + " ";
- }
-
- JSON headers_path = json_obj["headers_path"];
-
- for (auto& headers : headers_path) {
- command += "-I" + headers.get<std::string>() + " ";
- }
-
- JSON sources_files = json_obj["sources_path"];
-
- for (auto& sources : sources_files) {
- command += sources.get<std::string>() + " ";
- }
-
- JSON macros_list = json_obj["cpp_macros"];
-
- for (auto& macro : macros_list) {
- command += "-D" + macro.get<std::string>() + " ";
- }
-
- JSON compiler_flags = json_obj["compiler_flags"];
-
- for (auto& flag : compiler_flags) {
- command += flag.get<std::string>() + " ";
- }
-
- if (json_obj["compiler_std"].is_string())
- command += "-std=" + json_obj["compiler_std"].get<std::string>() + " ";
-
- command += "-o " + json_obj["output_name"].get<std::string>();
-
- auto target = json_obj["output_name"].get<std::string>();
-
- NeBuild::Logger::info() << "output path: " << target << "\n";
-
- auto ret_exec = std::system(command.c_str());
-
- if (ret_exec > 0) {
- NeBuild::Logger::info() << "error: exit with message: " << std::strerror(ret_exec) << ""
- << std::endl;
- return false;
- }
- } catch (std::runtime_error& err) {
- NeBuild::Logger::info() << "error: exit with message: " << err.what() << "" << std::endl;
- return false;
- }
-
- return true;
-}
-
-/// =========================================================== ///
-/// @brief Returns the build system name.
-/// =========================================================== ///
-const char* JSONManifestBuilder::BuildSystem() {
- return "NeBuild (JSON)";
-}
diff --git a/dev/src/TOMLManifestBuilder.cc b/dev/src/TOMLManifestBuilder.cc
deleted file mode 100644
index 49de8eb..0000000
--- a/dev/src/TOMLManifestBuilder.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-// ============================================================= //
-// nebuild
-// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license.
-// ============================================================= //
-
-#include <BuildKit/TOMLManifestBuilder.h>
-#include <filesystem>
-
-using namespace NeBuild;
-
-namespace FS = std::filesystem;
-
-/// =========================================================== ///
-/// @brief Builds a TOML target from a TOML file.
-/// @param arg_sz filename size (must be 1 or greater).
-/// @param arg_val filename path (must be a valid TOML file).
-/// @retval true building has succeeded.
-/// @retval false fail to build, see error message.
-/// =========================================================== ///
-bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) {
- std::string path;
-
- if (argv_val.empty()) {
- NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl;
- return false;
- } else {
- path = argv_val;
-
- if (!FS::exists(path)) {
- NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist"
- << std::endl;
- return false;
- }
- }
-
- try {
- auto toml_file = toml::parse_file(path);
-
- std::string compiler = toml_file["compiler_path"].as_string()->get();
-
- std::string command = compiler + " ";
-
- auto header_search_path = toml_file["compiler_headers_path"].as_array();
-
- if (header_search_path) {
- for (auto& headers : *header_search_path) {
- command += "-I" + headers.as_string()->get() + " ";
- }
- }
-
- auto headers_path = toml_file["headers_path"].as_array();
-
- if (headers_path) {
- for (auto& headers : *headers_path) {
- command += "-I" + headers.as_string()->get() + " ";
- }
- }
-
- auto sources_files = toml_file["sources_path"].as_array();
-
- if (sources_files) {
- for (auto& sources : *sources_files) {
- command += sources.as_string()->get() + " ";
- }
- }
-
- auto macros_list = toml_file["cpp_macros"].as_array();
-
- if (macros_list) {
- for (auto& macro : *macros_list) {
- command += "-D" + macro.as_string()->get() + " ";
- }
- }
-
- auto compiler_flags = toml_file["compiler_flags"].as_array();
-
- if (compiler_flags) {
- for (auto& flag : *compiler_flags) {
- command += flag.as_string()->get() + " ";
- }
- }
-
- if (!toml_file["compiler_std"].is_string()) return false;
-
- command += "-std=" + toml_file["compiler_std"].as_string()->get() + " ";
-
- if (toml_file["output_name"].as_string() == nullptr) return false;
-
- command += "-o " + toml_file["output_name"].as_string()->get();
-
- auto target = toml_file["output_name"].as_string()->get();
-
- NeBuild::Logger::info() << "output: " << target << "\n";
-
- auto ret_exec = std::system(command.c_str());
-
- if (ret_exec > 0) {
- NeBuild::Logger::info() << "error: exit with message: " << std::strerror(ret_exec) << ""
- << std::endl;
- return false;
- }
- } catch (std::runtime_error& err) {
- NeBuild::Logger::info() << "error: exit with message: " << err.what() << "" << std::endl;
- return false;
- }
-
- return true;
-}
-
-/// =========================================================== ///
-/// @brief Returns the build system name.
-/// =========================================================== ///
-const char* TOMLManifestBuilder::BuildSystem() {
- return "NeBuild (TOML)";
-}