summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-19 09:21:46 +0100
committerGitHub <noreply@github.com>2025-11-19 09:21:46 +0100
commitdc87375b9a0103e8c9dd39393abc21113e2dd917 (patch)
tree56863a984b488d880d9968c8af7ba9bcc1c7c400
parent8cf214b3e06556aa0aa18133aac60ddbedebc06e (diff)
parent6132d2c6a751ebffc29f950ca3755a05595dd99e (diff)
Merge pull request #7 from nekernel-org/dev
feat: new documented codebase and improvements.
-rw-r--r--GNUmakefile2
-rw-r--r--dev/BuildKit/Defines.h8
-rw-r--r--dev/BuildKit/IManifestBuilder.h24
-rw-r--r--dev/BuildKit/Imports.h4
-rw-r--r--dev/BuildKit/JSONManifestBuilder.h18
-rw-r--r--dev/BuildKit/TOMLManifestBuilder.h18
-rw-r--r--dev/cli/AppMain.cc (renamed from dev/cli/App.cc)4
-rw-r--r--dev/src/JSONManifestBuilder.cc8
-rw-r--r--dev/src/TOMLManifestBuilder.cc17
-rw-r--r--examples/example_01_hello_world/posix.json2
-rw-r--r--examples/example_02_libnebuild/posix.json2
-rw-r--r--examples/example_03_hello_world_toml/posix.toml2
-rw-r--r--osx-dylib.json2
-rw-r--r--osx.json2
-rw-r--r--posix.json2
15 files changed, 77 insertions, 38 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 44dbfeb..bcdc8e9 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -4,7 +4,7 @@
# // ============================================================= //
SUDO=sudo
-GCC=g++
+GCC=clang++
GCC_MINGW=x86_64-w64-mingw32-g++
CXXFLAGS=-I./dev -I./vendor
CXXSTD= -std=c++20
diff --git a/dev/BuildKit/Defines.h b/dev/BuildKit/Defines.h
index 4774c85..1c88ceb 100644
--- a/dev/BuildKit/Defines.h
+++ b/dev/BuildKit/Defines.h
@@ -7,12 +7,16 @@
#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.1-libNeBuild"
+#define LIBNEBUILD_VERSION "v0.0.7-buildkit"
-#define LIBNEBUILD_VERSION_BCD 0x0001
+#define LIBNEBUILD_VERSION_BCD 0x0007
#define LIBNEBUILD_VERSION_MAJOR 1
#define LIBNEBUILD_VERSION_MINOR 1
diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h
index 8f9b2cf..abb389f 100644
--- a/dev/BuildKit/IManifestBuilder.h
+++ b/dev/BuildKit/IManifestBuilder.h
@@ -7,11 +7,13 @@
#include <BuildKit/Defines.h>
-#define NEBUILD_MANIFEST_BUILDER : public NeBuild::IManifestBuilder
+#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;
@@ -20,12 +22,18 @@ class IManifestBuilder {
IManifestBuilder& operator=(const IManifestBuilder&) = default;
IManifestBuilder(const IManifestBuilder&) = default;
- /// @brief Builds a target using the implemented laguage.
- /// @param arg_sz filename size
- /// @param arg_val filename path.
- /// @retval true succeeded.
- /// @retval false failed.
- virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0;
- virtual const char* BuildSystem() = 0;
+ /// =========================================================== ///
+ /// @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
index e22c933..33e1e31 100644
--- a/dev/BuildKit/Imports.h
+++ b/dev/BuildKit/Imports.h
@@ -6,6 +6,10 @@
#ifndef NEBUILD_INCLUDES_H
#define NEBUILD_INCLUDES_H
+/// =========================================================== ///
+/// @brief Imports file
+/// =========================================================== ///
+
#include <rang/rang.h>
#include <cassert>
#include <cstddef>
diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h
index 81643e3..438bdab 100644
--- a/dev/BuildKit/JSONManifestBuilder.h
+++ b/dev/BuildKit/JSONManifestBuilder.h
@@ -22,12 +22,18 @@ class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER {
JSONManifestBuilder(const JSONManifestBuilder&) = default;
public:
- /// @brief Builds a JSON target.
- /// @param arg_sz filename size
- /// @param arg_val filename path.
- /// @retval true build succeeded.
- /// @retval false failed to build.
- bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
+ /// =========================================================== ///
+ /// @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
index 6baa9f5..7c508fc 100644
--- a/dev/BuildKit/TOMLManifestBuilder.h
+++ b/dev/BuildKit/TOMLManifestBuilder.h
@@ -22,12 +22,18 @@ class TOMLManifestBuilder final NEBUILD_MANIFEST_BUILDER {
TOMLManifestBuilder(const TOMLManifestBuilder&) = default;
public:
- /// @brief Builds a TOML target.
- /// @param arg_sz filename size
- /// @param arg_val filename path.
- /// @retval true build succeeded.
- /// @retval false failed to build.
- bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
+ /// =========================================================== ///
+ /// @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/App.cc b/dev/cli/AppMain.cc
index d78ad69..53cbdf3 100644
--- a/dev/cli/App.cc
+++ b/dev/cli/AppMain.cc
@@ -17,7 +17,7 @@ int main(int argc, char** argv) {
std::string index_path = argv[index];
if (index_path == "-v" || index_path == "--version") {
- NeBuild::Logger::info() << "NeKernel Build Tool.\n";
+ NeBuild::Logger::info() << "NeKernel Build.\n";
NeBuild::Logger::info()
<< "Bugs or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n";
@@ -58,7 +58,7 @@ int main(int argc, char** argv) {
goto end;
} else {
NeBuild::Logger::info()
- << "error: file '" << index_path << "' is not a JSON file!" << std::endl;
+ << "error: file '" << index_path << "' is not a manifest file!" << std::endl;
kFailed = true;
return;
}
diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc
index dba5b37..8eaf20a 100644
--- a/dev/src/JSONManifestBuilder.cc
+++ b/dev/src/JSONManifestBuilder.cc
@@ -10,11 +10,13 @@ namespace FS = std::filesystem;
using namespace NeBuild;
+/// =========================================================== ///
/// @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;
@@ -84,7 +86,6 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
auto target = json_obj["output_name"].get<std::string>();
NeBuild::Logger::info() << "output path: " << target << "\n";
- NeBuild::Logger::info() << "command: " << command << "\n";
auto ret_exec = std::system(command.c_str());
@@ -94,13 +95,16 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
return false;
}
} catch (std::runtime_error& err) {
- NeBuild::Logger::info() << "error: " << err.what() << std::endl;
+ 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
index 53034e8..f264ade 100644
--- a/dev/src/TOMLManifestBuilder.cc
+++ b/dev/src/TOMLManifestBuilder.cc
@@ -9,11 +9,13 @@ namespace FS = std::filesystem;
using namespace NeBuild;
+/// =========================================================== ///
/// @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;
@@ -77,15 +79,17 @@ bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
}
}
- if (toml_file["compiler_std"].is_string())
- command += "-std=" + toml_file["compiler_std"].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 path: " << target << "\n";
- NeBuild::Logger::info() << "command: " << command << "\n";
+ NeBuild::Logger::info() << "output: " << target << "\n";
auto ret_exec = std::system(command.c_str());
@@ -95,13 +99,16 @@ bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
return false;
}
} catch (std::runtime_error& err) {
- NeBuild::Logger::info() << "error: " << err.what() << std::endl;
+ 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)";
}
diff --git a/examples/example_01_hello_world/posix.json b/examples/example_01_hello_world/posix.json
index c3c8151..09cbef7 100644
--- a/examples/example_01_hello_world/posix.json
+++ b/examples/example_01_hello_world/posix.json
@@ -1,5 +1,5 @@
{
- "compiler_path": "g++",
+ "compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": ["lib"],
"sources_path": ["hello_world.cc"],
diff --git a/examples/example_02_libnebuild/posix.json b/examples/example_02_libnebuild/posix.json
index 989e712..b8145bd 100644
--- a/examples/example_02_libnebuild/posix.json
+++ b/examples/example_02_libnebuild/posix.json
@@ -1,5 +1,5 @@
{
- "compiler_path": "g++",
+ "compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": [
"../../dev",
diff --git a/examples/example_03_hello_world_toml/posix.toml b/examples/example_03_hello_world_toml/posix.toml
index 4f71f7d..e8595d4 100644
--- a/examples/example_03_hello_world_toml/posix.toml
+++ b/examples/example_03_hello_world_toml/posix.toml
@@ -1,4 +1,4 @@
-compiler_path = "g++"
+compiler_path = "clang++"
compiler_std = "c++20"
headers_path = [ "lib" ]
sources_path = [ "hello_world.cc" ]
diff --git a/osx-dylib.json b/osx-dylib.json
index 7f7648d..f9e2274 100644
--- a/osx-dylib.json
+++ b/osx-dylib.json
@@ -1,5 +1,5 @@
{
- "compiler_path": "g++",
+ "compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": ["dev", "vendor"],
"sources_path": ["dev/src/*.cc"],
diff --git a/osx.json b/osx.json
index 8e247d9..3819ea7 100644
--- a/osx.json
+++ b/osx.json
@@ -1,5 +1,5 @@
{
- "compiler_path": "g++",
+ "compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": ["dev", "vendor"],
"sources_path": ["dev/src/*.cc", "dev/cli/*.cc"],
diff --git a/posix.json b/posix.json
index 5281d4d..b6dc247 100644
--- a/posix.json
+++ b/posix.json
@@ -1,5 +1,5 @@
{
- "compiler_path": "g++",
+ "compiler_path": "clang++",
"compiler_std": "c++20",
"headers_path": ["dev/", "vendor"],
"sources_path": ["dev/src/*.cc", "dev/cli/*.cc"],