From a163348561bcdd14feb816e006362639a5862fa9 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 2 Jul 2025 14:43:57 +0200 Subject: [PATCH 01/13] feat: check for `arg_val` if not `nullptr` Signed-off-by: Amlal El Mahrouss --- src/JSONManifestBuilder.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/JSONManifestBuilder.cc b/src/JSONManifestBuilder.cc index 46a8518..50850f5 100644 --- a/src/JSONManifestBuilder.cc +++ b/src/JSONManifestBuilder.cc @@ -14,11 +14,16 @@ using namespace BTB; /// @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 succeeded building. +/// @retval true building has succeeded. /// @retval false fail to build, see error message. bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const bool dry_run) { String path; + if (!arg_val) { + BTB::Logger::info() << "btb: error: file path is empty" << std::endl; + return false; + } + if (arg_sz < 0) { BTB::Logger::info() << "btb: error: file path is empty" << std::endl; return false; From fbd8b25bfd592f71503d33c2fe39b550263c9185 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 2 Jul 2025 14:44:28 +0200 Subject: [PATCH 02/13] fix: check `builder` variable if not `nullptr` (libbtb example) Signed-off-by: Amlal El Mahrouss --- examples/example_02_libbtb/libbtb.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/example_02_libbtb/libbtb.cc b/examples/example_02_libbtb/libbtb.cc index f3d45b8..21e3e17 100644 --- a/examples/example_02_libbtb/libbtb.cc +++ b/examples/example_02_libbtb/libbtb.cc @@ -1,4 +1,5 @@ #include +#include #ifndef _WIN32 static auto kPath = "./posix.json"; @@ -8,5 +9,7 @@ static auto kPath = ".\win64.json"; int main(int argc, char** argv) { auto builder = new BTB::JSONManifestBuilder(); + if (!builder) return EXIT_FAILURE; + return builder->buildTarget(strlen(kPath), kPath); } From f73b80881bf211540af26a401b250cf2a3a74011 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 15 Jul 2025 08:13:21 +0100 Subject: [PATCH 03/13] fix: Update ReadMe.md --- ReadMe.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ReadMe.md b/ReadMe.md index 2edd5ce..3ed5564 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,20 +1,19 @@ -# BTB. +# NeBuild -![CI](https://github.com/amlel-el-mahrouss/btb/actions/workflows/c-cpp.yml/badge.svg) +![CI](https://github.com/nekernel-ort/nebuild/actions/workflows/c-cpp.yml/badge.svg) [![License: GPL-3.0](https://img.shields.io/badge/license-BSD--3.0-blue.svg)](LICENSE) -[![QEMU Tested](https://img.shields.io/badge/QEMU-Tested-success)](#) -## Installation requirements: +## Requirements: - GNU C++ - GNU Make -## Steps (GNU Make): +## Guide (GNU Make): - Run make `build-btb-core` and `build-btb`. -## Steps (BTB): +## Guide (NeBuild): - Run `btb` and pass the path to the manifest file. -###### Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. All rights reserved. +###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, all rights reserved. All rights reserved. From caecbd4e6eb2877b7e9bdd4fb2e4f3e370b336c9 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 15 Jul 2025 08:14:06 +0100 Subject: [PATCH 04/13] fix: Update ReadMe.md copyright notice. --- ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReadMe.md b/ReadMe.md index 3ed5564..46363f3 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -16,4 +16,4 @@ - Run `btb` and pass the path to the manifest file. -###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, all rights reserved. All rights reserved. +###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, all rights reserved. From 20252df698106283d15ddf7d53f4e0dd9462666d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 17 Jul 2025 07:32:30 +0100 Subject: [PATCH 05/13] =?UTF-8?q?refactor!=20Lots=20of=20breaking=20change?= =?UTF-8?q?s=20to=20the=20codebase.=20feat:=20Rename=20=E2=80=98btb?= =?UTF-8?q?=E2=80=98=20to=20=E2=80=98nebuild=E2=80=98=20to=20match=20neker?= =?UTF-8?q?nel.org's=20naming=20scheme.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Amlal El Mahrouss --- .github/workflows/c-cpp.yml | 2 +- .gitignore | 2 +- GNUmakefile | 14 +++++----- ReadMe.md | 4 +-- compile_flags.txt | 2 +- {BTBKit => dev/BuildKit}/IManifestBuilder.h | 6 ++--- {BTBKit => dev/BuildKit}/Includes.h | 2 +- .../BuildKit}/JSONManifestBuilder.h | 4 +-- {BTBKit => dev/BuildKit}/Macros.h | 4 +-- {cli => dev/cli}/CommandLine.cc | 10 +++---- .../example_01_hello_world/hello_world.cc | 0 .../example_01_hello_world/posix.json | 0 .../example_01_hello_world/win64.json | 0 .../examples}/example_02_libbtb/README.md | 0 .../examples}/example_02_libbtb/libbtb.cc | 2 +- .../examples}/example_02_libbtb/posix.json | 0 .../examples}/example_02_libbtb/win64.json | 0 {src => dev/src}/IManifestBuilder.cc | 4 +-- {src => dev/src}/JSONManifestBuilder.cc | 26 ++++++++----------- osx-dylib.json | 6 ++--- osx.json | 6 ++--- posix.json | 6 ++--- win64.json | 6 ++--- 23 files changed, 51 insertions(+), 55 deletions(-) rename {BTBKit => dev/BuildKit}/IManifestBuilder.h (93%) rename {BTBKit => dev/BuildKit}/Includes.h (97%) rename {BTBKit => dev/BuildKit}/JSONManifestBuilder.h (94%) rename {BTBKit => dev/BuildKit}/Macros.h (91%) rename {cli => dev/cli}/CommandLine.cc (92%) rename {examples => dev/examples}/example_01_hello_world/hello_world.cc (100%) rename {examples => dev/examples}/example_01_hello_world/posix.json (100%) rename {examples => dev/examples}/example_01_hello_world/win64.json (100%) rename {examples => dev/examples}/example_02_libbtb/README.md (100%) rename {examples => dev/examples}/example_02_libbtb/libbtb.cc (87%) rename {examples => dev/examples}/example_02_libbtb/posix.json (100%) rename {examples => dev/examples}/example_02_libbtb/win64.json (100%) rename {src => dev/src}/IManifestBuilder.cc (80%) rename {src => dev/src}/JSONManifestBuilder.cc (85%) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 6f7b609..f3f03e1 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -16,4 +16,4 @@ jobs: - name: Install Packages run: sudo apt update && sudo apt install build-essential - name: Build BTB - run: make build-btb \ No newline at end of file + run: make build-nebuild \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1511910..16285f7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ syntax: glob html/ latex/ -btb +nebuild .cmake/ .qtc_clangd/ diff --git a/GNUmakefile b/GNUmakefile index f3c888f..a008b1e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,20 +4,20 @@ GCC_MINGW=x86_64-w64-mingw32-g++ CXXFLAGS=-I./ -I./vendor CXXSTD= -std=c++20 SRC=$(wildcard cli/*.cc) $(wildcard src/*.cc) -OUT=btb +OUT=nebuild CP=cp -.PHONY: build-btb -build-btb: +.PHONY: build-nebuild +build-nebuild: $(SUDO) $(GCC) $(CXXFLAGS) $(SRC) $(CXXSTD) -o $(OUT) $(SUDO) $(CP) $(OUT) /usr/local/bin -.PHONY: build-btb-windows -build-btb-windows: +.PHONY: build-nebuild-windows +build-nebuild-windows: $(GCC_MINGW) $(CXXFLAGS) $(SRC) -o $(OUT).exe .PHONY: help help: @echo "=> help: Show this help message." - @echo "=> build-btb-windows: Build BTB for Windows." - @echo "=> build-btb: Build BTB for POSIX." + @echo "=> build-nebuild-windows: Build BTB for Windows." + @echo "=> build-nebuild: Build BTB for POSIX." diff --git a/ReadMe.md b/ReadMe.md index 46363f3..d3430be 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -10,10 +10,10 @@ ## Guide (GNU Make): -- Run make `build-btb-core` and `build-btb`. +- Run make `build-nebuild-core` and `build-nebuild`. ## Guide (NeBuild): -- Run `btb` and pass the path to the manifest file. +- Run `nebuild` and pass the path to the manifest file. ###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, all rights reserved. diff --git a/compile_flags.txt b/compile_flags.txt index 3edd1b0..bb1d0d2 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,3 +1,3 @@ -std=c++20 --I./ +-Idev/ -Ivendor \ No newline at end of file diff --git a/BTBKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h similarity index 93% rename from BTBKit/IManifestBuilder.h rename to dev/BuildKit/IManifestBuilder.h index e11d431..1c160c4 100644 --- a/BTBKit/IManifestBuilder.h +++ b/dev/BuildKit/IManifestBuilder.h @@ -1,12 +1,12 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // #pragma once -#include -#include +#include +#include #define BTB_MANIFEST_BUILDER : public BTB::IManifestBuilder diff --git a/BTBKit/Includes.h b/dev/BuildKit/Includes.h similarity index 97% rename from BTBKit/Includes.h rename to dev/BuildKit/Includes.h index 3695d53..e321483 100644 --- a/BTBKit/Includes.h +++ b/dev/BuildKit/Includes.h @@ -1,5 +1,5 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // diff --git a/BTBKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h similarity index 94% rename from BTBKit/JSONManifestBuilder.h rename to dev/BuildKit/JSONManifestBuilder.h index f5d874c..a4fe66b 100644 --- a/BTBKit/JSONManifestBuilder.h +++ b/dev/BuildKit/JSONManifestBuilder.h @@ -1,11 +1,11 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // #pragma once -#include +#include #include namespace BTB { diff --git a/BTBKit/Macros.h b/dev/BuildKit/Macros.h similarity index 91% rename from BTBKit/Macros.h rename to dev/BuildKit/Macros.h index c2d6194..1b1613d 100644 --- a/BTBKit/Macros.h +++ b/dev/BuildKit/Macros.h @@ -1,5 +1,5 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // @@ -28,7 +28,7 @@ namespace BTB::Logger { /// @brief replacement for std::cout for BTB logging. inline std::ostream& info() noexcept { auto& out = std::cout; - out << rang::fg::red << "btb: " << rang::style::reset; + out << rang::fg::red << "nebuild: " << rang::style::reset; return out; } } // namespace BTB::Logger diff --git a/cli/CommandLine.cc b/dev/cli/CommandLine.cc similarity index 92% rename from cli/CommandLine.cc rename to dev/cli/CommandLine.cc index 300db6f..e199e61 100644 --- a/cli/CommandLine.cc +++ b/dev/cli/CommandLine.cc @@ -1,11 +1,11 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // -#include -#include +#include +#include static bool kFailed = false; static bool kDryRun = false; @@ -21,14 +21,14 @@ int main(int argc, char** argv) { BTB::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n"; BTB::Logger::info() - << "Bugs, issues? Check out: https://github.com/nekernel-org/btb/issues\n"; + << "Bugs, issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; return EXIT_SUCCESS; } else if (index_path == "--dry-run") { kDryRun = true; continue; } else if (index_path == "-h" || index_path == "--help") { - BTB::Logger::info() << "Usage: btb \n"; + BTB::Logger::info() << "Usage: nebuild \n"; return EXIT_SUCCESS; } diff --git a/examples/example_01_hello_world/hello_world.cc b/dev/examples/example_01_hello_world/hello_world.cc similarity index 100% rename from examples/example_01_hello_world/hello_world.cc rename to dev/examples/example_01_hello_world/hello_world.cc diff --git a/examples/example_01_hello_world/posix.json b/dev/examples/example_01_hello_world/posix.json similarity index 100% rename from examples/example_01_hello_world/posix.json rename to dev/examples/example_01_hello_world/posix.json diff --git a/examples/example_01_hello_world/win64.json b/dev/examples/example_01_hello_world/win64.json similarity index 100% rename from examples/example_01_hello_world/win64.json rename to dev/examples/example_01_hello_world/win64.json diff --git a/examples/example_02_libbtb/README.md b/dev/examples/example_02_libbtb/README.md similarity index 100% rename from examples/example_02_libbtb/README.md rename to dev/examples/example_02_libbtb/README.md diff --git a/examples/example_02_libbtb/libbtb.cc b/dev/examples/example_02_libbtb/libbtb.cc similarity index 87% rename from examples/example_02_libbtb/libbtb.cc rename to dev/examples/example_02_libbtb/libbtb.cc index 21e3e17..0b4d7c4 100644 --- a/examples/example_02_libbtb/libbtb.cc +++ b/dev/examples/example_02_libbtb/libbtb.cc @@ -1,4 +1,4 @@ -#include +#include #include #ifndef _WIN32 diff --git a/examples/example_02_libbtb/posix.json b/dev/examples/example_02_libbtb/posix.json similarity index 100% rename from examples/example_02_libbtb/posix.json rename to dev/examples/example_02_libbtb/posix.json diff --git a/examples/example_02_libbtb/win64.json b/dev/examples/example_02_libbtb/win64.json similarity index 100% rename from examples/example_02_libbtb/win64.json rename to dev/examples/example_02_libbtb/win64.json diff --git a/src/IManifestBuilder.cc b/dev/src/IManifestBuilder.cc similarity index 80% rename from src/IManifestBuilder.cc rename to dev/src/IManifestBuilder.cc index b3f4de8..1397dd4 100644 --- a/src/IManifestBuilder.cc +++ b/dev/src/IManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // -#include +#include diff --git a/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc similarity index 85% rename from src/JSONManifestBuilder.cc rename to dev/src/JSONManifestBuilder.cc index 50850f5..e93bcb7 100644 --- a/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -1,12 +1,13 @@ // ============================================================= // -// btb +// nebuild // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // -#include +#include using String = std::string; using JSON = nlohmann::json; + namespace FS = std::filesystem; using namespace BTB; @@ -19,19 +20,14 @@ using namespace BTB; bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const bool dry_run) { String path; - if (!arg_val) { - BTB::Logger::info() << "btb: error: file path is empty" << std::endl; - return false; - } - - if (arg_sz < 0) { - BTB::Logger::info() << "btb: error: file path is empty" << std::endl; + if (!arg_val || arg_sz < 0) { + BTB::Logger::info() << "nebuild: error: file path is empty" << std::endl; return false; } else { - path = arg_val; + path += arg_val; if (!FS::exists(path)) { - BTB::Logger::info() << "btb: error: file '" << path << "' does not exist" << std::endl; + BTB::Logger::info() << "nebuild: error: file '" << path << "' does not exist" << std::endl; return false; } } @@ -40,7 +36,7 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo std::ifstream json(path); if (!json.good()) { - BTB::Logger::info() << "btb: error: file '" << path << "' is not a valid JSON" << std::endl; + BTB::Logger::info() << "nebuild: error: file '" << path << "' is not a valid JSON" << std::endl; return false; } @@ -112,12 +108,12 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo ss << file.rdbuf(); - if (ss.str()[0] == 'J' && ss.str()[1] == 'o' && ss.str()[2] == 'y' && ss.str()[3] == '!') + if (ss.str()[0] == 'O' && ss.str()[1] == 'p' && ss.str()[2] == 'e' && ss.str()[3] == 'n') BTB::Logger::info() << "error: can't open PEF dynamic library, it mayn't contain an entrypoint" << std::endl; - else if (ss.str()[0] == '!' && ss.str()[1] == 'y' && ss.str()[2] == 'o' && - ss.str()[3] == 'J') + else if (ss.str()[0] == 'n' && ss.str()[1] == 'e' && ss.str()[2] == 'p' && + ss.str()[3] == 'O') BTB::Logger::info() << "error: can't open FEP dynamic library, it mayn't contain an entrypoint" << std::endl; diff --git a/osx-dylib.json b/osx-dylib.json index 80917d2..3c49abb 100644 --- a/osx-dylib.json +++ b/osx-dylib.json @@ -1,10 +1,10 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./", "vendor"], - "sources_path": ["src/*.cc"], + "headers_path": ["dev", "vendor"], + "sources_path": ["dev/src/*.cc"], "output_name": "libBTB.dylib", "compiler_flags": ["-fPIC", "-shared"], - "cpp_macros": ["BTB_POSIX", "BTB_OSX"], + "cpp_macros": ["BTB_DYLIB", "BTB_OSX"], "run_after_build": false } diff --git a/osx.json b/osx.json index 20d513d..b4a860c 100644 --- a/osx.json +++ b/osx.json @@ -1,9 +1,9 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./", "vendor"], - "sources_path": ["src/*.cc", "cli/*.cc"], - "output_name": "btb", + "headers_path": ["dev", "vendor"], + "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], + "output_name": "nebuild", "compiler_flags": ["-fPIC"], "cpp_macros": ["BTB_POSIX", "BTB_OSX"], "run_after_build": false diff --git a/posix.json b/posix.json index e53cc14..540c877 100644 --- a/posix.json +++ b/posix.json @@ -1,9 +1,9 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./", "vendor"], - "sources_path": ["src/*.cc", "cli/*.cc"], - "output_name": "btb", + "headers_path": ["dev/", "vendor"], + "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], + "output_name": "nebuild", "compiler_flags": ["-fPIC"], "cpp_macros": ["BTB_POSIX"], "run_after_build": false diff --git a/win64.json b/win64.json index a4a2ecc..65a42be 100644 --- a/win64.json +++ b/win64.json @@ -1,9 +1,9 @@ { "compiler_path": "x86_64-w64-mingw32-g++.exe", "compiler_std": "c++20", - "headers_path": ["./", "vendor"], - "sources_path": ["src/*.cc", "cli/*.cc"], - "output_name": "btb.exe", + "headers_path": ["dev", "vendor"], + "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], + "output_name": "nebuild.exe", "compiler_flags": ["-fPIC"], "cpp_macros": ["BTB_WINDOWS"], "run_after_build": false From f61f6168ea9da22a1b5a5af62cb4167a7d3018db Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 17 Jul 2025 07:51:31 +0100 Subject: [PATCH 06/13] fix: bootstrap makefile has been refactored according to the new codebase layout. Signed-off-by: Amlal El Mahrouss --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index a008b1e..b298d7d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,9 +1,9 @@ SUDO=sudo GCC=g++ GCC_MINGW=x86_64-w64-mingw32-g++ -CXXFLAGS=-I./ -I./vendor +CXXFLAGS=-I./dev -I./vendor CXXSTD= -std=c++20 -SRC=$(wildcard cli/*.cc) $(wildcard src/*.cc) +SRC=$(wildcard dev/cli/*.cc) $(wildcard dev/src/*.cc) OUT=nebuild CP=cp From bb11d32131e786b40550375005b12bcb31cf25d7 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 23 Jul 2025 09:10:10 +0100 Subject: [PATCH 07/13] feat! NeBuild and BuildKit has been improved and refactored. They now are called 'nebuild' instead of 'btb' Signed-off-by: Amlal El Mahrouss --- dev/BuildKit/IManifestBuilder.h | 2 +- dev/BuildKit/Includes.h | 6 +++--- dev/BuildKit/JSONManifestBuilder.h | 5 ++++- dev/BuildKit/Macros.h | 12 ++++++------ dev/examples/example_02_libbtb/README.md | 2 +- dev/src/JSONManifestBuilder.cc | 2 +- osx-dylib.json | 4 ++-- osx.json | 2 +- posix.json | 2 +- win64.json | 2 +- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h index 1c160c4..065bec3 100644 --- a/dev/BuildKit/IManifestBuilder.h +++ b/dev/BuildKit/IManifestBuilder.h @@ -8,7 +8,7 @@ #include #include -#define BTB_MANIFEST_BUILDER : public BTB::IManifestBuilder +#define NEBUILD_MANIFEST_BUILDER : public BTB::IManifestBuilder namespace BTB { /// @brief Builder interface class. diff --git a/dev/BuildKit/Includes.h b/dev/BuildKit/Includes.h index e321483..4cb3043 100644 --- a/dev/BuildKit/Includes.h +++ b/dev/BuildKit/Includes.h @@ -3,8 +3,8 @@ // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // -#ifndef BTB_INCLUDES_H -#define BTB_INCLUDES_H +#ifndef NEBUILD_INCLUDES_H +#define NEBUILD_INCLUDES_H #include #include @@ -14,4 +14,4 @@ #include #include -#endif // BTB_INCLUDES_H +#endif // NEBUILD_INCLUDES_H diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h index a4fe66b..f7c769d 100644 --- a/dev/BuildKit/JSONManifestBuilder.h +++ b/dev/BuildKit/JSONManifestBuilder.h @@ -8,9 +8,12 @@ #include #include +/// @file JSONManifestBuilder.h +/// @brief JSON manifest builder header file. + namespace BTB { /// @brief JSON builder -class JSONManifestBuilder final BTB_MANIFEST_BUILDER { +class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER { public: JSONManifestBuilder() = default; ~JSONManifestBuilder() override = default; diff --git a/dev/BuildKit/Macros.h b/dev/BuildKit/Macros.h index 1b1613d..98bf891 100644 --- a/dev/BuildKit/Macros.h +++ b/dev/BuildKit/Macros.h @@ -14,15 +14,15 @@ extern "C" { #define LIKELY(ARG) ((ARG) ? assert(false) : ((void) 0)) #define UNLIKELY(ARG) LIKELY(!(ARG)) -#define LIBBTB_VERSION "v0.0.1-libBTB" +#define LIBNEBUILD_VERSION "v0.0.1-libNeBuild" -#define LIBBTB_VERSION_BCD 0x0001 +#define LIBNEBUILD_VERSION_BCD 0x0001 -#define LIBBTB_VERSION_MAJOR 1 -#define LIBBTB_VERSION_MINOR 1 -#define LIBBTB_VERSION_PATCH 0 +#define LIBNEBUILD_VERSION_MAJOR 1 +#define LIBNEBUILD_VERSION_MINOR 1 +#define LIBNEBUILD_VERSION_PATCH 0 -#define LIBBTB_UNUSED(X) ((void) X) +#define LIBNEBUILD_UNUSED(X) ((void) X) namespace BTB::Logger { /// @brief replacement for std::cout for BTB logging. diff --git a/dev/examples/example_02_libbtb/README.md b/dev/examples/example_02_libbtb/README.md index 26ccb72..21e64be 100644 --- a/dev/examples/example_02_libbtb/README.md +++ b/dev/examples/example_02_libbtb/README.md @@ -1,6 +1,6 @@ # Notice for Deployment. -In order to use libBTB, it shall live on the same directory, +In order to use libNeBuild, it shall live on the same directory,
or within a directory recognized in the `$LD_LIBRARY_PATH` or `$DYLD_LIBRARY_PATH` variable. diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc index e93bcb7..aa277c7 100644 --- a/dev/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -130,7 +130,7 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo return true; } -#if defined(BTB_WINDOWS) +#if defined(NEBUILD_WINDOWS) std::system((".\\" + target).c_str()); #else std::system(("./" + target).c_str()); diff --git a/osx-dylib.json b/osx-dylib.json index 3c49abb..7f7648d 100644 --- a/osx-dylib.json +++ b/osx-dylib.json @@ -3,8 +3,8 @@ "compiler_std": "c++20", "headers_path": ["dev", "vendor"], "sources_path": ["dev/src/*.cc"], - "output_name": "libBTB.dylib", + "output_name": "libNeBuild.dylib", "compiler_flags": ["-fPIC", "-shared"], - "cpp_macros": ["BTB_DYLIB", "BTB_OSX"], + "cpp_macros": ["NEBUILD_DYLIB", "NEBUILD_OSX"], "run_after_build": false } diff --git a/osx.json b/osx.json index b4a860c..8e247d9 100644 --- a/osx.json +++ b/osx.json @@ -5,6 +5,6 @@ "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], "output_name": "nebuild", "compiler_flags": ["-fPIC"], - "cpp_macros": ["BTB_POSIX", "BTB_OSX"], + "cpp_macros": ["NEBUILD_POSIX", "NEBUILD_OSX"], "run_after_build": false } diff --git a/posix.json b/posix.json index 540c877..5281d4d 100644 --- a/posix.json +++ b/posix.json @@ -5,6 +5,6 @@ "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], "output_name": "nebuild", "compiler_flags": ["-fPIC"], - "cpp_macros": ["BTB_POSIX"], + "cpp_macros": ["NEBUILD_POSIX"], "run_after_build": false } diff --git a/win64.json b/win64.json index 65a42be..6585723 100644 --- a/win64.json +++ b/win64.json @@ -5,6 +5,6 @@ "sources_path": ["dev/src/*.cc", "dev/cli/*.cc"], "output_name": "nebuild.exe", "compiler_flags": ["-fPIC"], - "cpp_macros": ["BTB_WINDOWS"], + "cpp_macros": ["NEBUILD_WINDOWS"], "run_after_build": false } From a3ea256d00e5aac45574c7c8b076b60630f73a95 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 24 Jul 2025 09:15:17 +0100 Subject: [PATCH 08/13] feat! refactor! Breaking changes of the NeBuild system. Working on a TOML backend, refactored source code namespace. And add 'toml++' vendor library. See commit details. Signed-off-by: Amlal El Mahrouss --- .github/workflows/c-cpp.yml | 2 +- GNUmakefile | 4 +- dev/BuildKit/{Macros.h => Defines.h} | 12 +- dev/BuildKit/IManifestBuilder.h | 9 +- dev/BuildKit/{Includes.h => Imports.h} | 6 + dev/BuildKit/JSONManifestBuilder.h | 6 +- dev/BuildKit/TOMLManifestBuilder.h | 33 + dev/cli/{CommandLine.cc => Tool.cc} | 19 +- dev/examples/example_02_libbtb/libbtb.cc | 2 +- dev/examples/example_02_libbtb/posix.json | 2 +- dev/examples/example_02_libbtb/win64.json | 2 +- dev/src/JSONManifestBuilder.cc | 26 +- vendor/.keep | 0 vendor/{ => json}/json.h | 0 vendor/{ => json}/json_fwd.h | 0 vendor/toml++/impl/array.hpp | 1790 ++++++++ vendor/toml++/impl/array.inl | 382 ++ vendor/toml++/impl/at_path.hpp | 97 + vendor/toml++/impl/at_path.inl | 290 ++ vendor/toml++/impl/date_time.hpp | 468 +++ vendor/toml++/impl/formatter.hpp | 194 + vendor/toml++/impl/formatter.inl | 523 +++ vendor/toml++/impl/forward_declarations.hpp | 1097 +++++ vendor/toml++/impl/header_end.hpp | 13 + vendor/toml++/impl/header_start.hpp | 15 + vendor/toml++/impl/json_formatter.hpp | 142 + vendor/toml++/impl/json_formatter.inl | 121 + vendor/toml++/impl/key.hpp | 335 ++ vendor/toml++/impl/make_node.hpp | 182 + vendor/toml++/impl/node.hpp | 1115 +++++ vendor/toml++/impl/node.inl | 141 + vendor/toml++/impl/node_view.hpp | 839 ++++ vendor/toml++/impl/parse_error.hpp | 139 + vendor/toml++/impl/parse_result.hpp | 499 +++ vendor/toml++/impl/parser.hpp | 390 ++ vendor/toml++/impl/parser.inl | 3917 ++++++++++++++++++ vendor/toml++/impl/path.hpp | 851 ++++ vendor/toml++/impl/path.inl | 523 +++ vendor/toml++/impl/preprocessor.hpp | 1412 +++++++ vendor/toml++/impl/print_to_stream.hpp | 129 + vendor/toml++/impl/print_to_stream.inl | 490 +++ vendor/toml++/impl/simd.hpp | 35 + vendor/toml++/impl/source_region.hpp | 223 + vendor/toml++/impl/std_except.hpp | 12 + vendor/toml++/impl/std_initializer_list.hpp | 10 + vendor/toml++/impl/std_map.hpp | 11 + vendor/toml++/impl/std_new.hpp | 18 + vendor/toml++/impl/std_optional.hpp | 32 + vendor/toml++/impl/std_string.hpp | 53 + vendor/toml++/impl/std_string.inl | 99 + vendor/toml++/impl/std_utility.hpp | 10 + vendor/toml++/impl/std_variant.hpp | 10 + vendor/toml++/impl/std_vector.hpp | 11 + vendor/toml++/impl/table.hpp | 1996 +++++++++ vendor/toml++/impl/table.inl | 318 ++ vendor/toml++/impl/toml_formatter.hpp | 153 + vendor/toml++/impl/toml_formatter.inl | 405 ++ vendor/toml++/impl/unicode.hpp | 197 + vendor/toml++/impl/unicode.inl | 60 + vendor/toml++/impl/unicode_autogenerated.hpp | 182 + vendor/toml++/impl/value.hpp | 1270 ++++++ vendor/toml++/impl/version.hpp | 13 + vendor/toml++/impl/yaml_formatter.hpp | 139 + vendor/toml++/impl/yaml_formatter.inl | 165 + vendor/toml++/toml.h | 7 + vendor/toml++/toml.hpp | 231 ++ 66 files changed, 21832 insertions(+), 45 deletions(-) rename dev/BuildKit/{Macros.h => Defines.h} (81%) rename dev/BuildKit/{Includes.h => Imports.h} (88%) create mode 100644 dev/BuildKit/TOMLManifestBuilder.h rename dev/cli/{CommandLine.cc => Tool.cc} (71%) create mode 100644 vendor/.keep rename vendor/{ => json}/json.h (100%) rename vendor/{ => json}/json_fwd.h (100%) create mode 100644 vendor/toml++/impl/array.hpp create mode 100644 vendor/toml++/impl/array.inl create mode 100644 vendor/toml++/impl/at_path.hpp create mode 100644 vendor/toml++/impl/at_path.inl create mode 100644 vendor/toml++/impl/date_time.hpp create mode 100644 vendor/toml++/impl/formatter.hpp create mode 100644 vendor/toml++/impl/formatter.inl create mode 100644 vendor/toml++/impl/forward_declarations.hpp create mode 100644 vendor/toml++/impl/header_end.hpp create mode 100644 vendor/toml++/impl/header_start.hpp create mode 100644 vendor/toml++/impl/json_formatter.hpp create mode 100644 vendor/toml++/impl/json_formatter.inl create mode 100644 vendor/toml++/impl/key.hpp create mode 100644 vendor/toml++/impl/make_node.hpp create mode 100644 vendor/toml++/impl/node.hpp create mode 100644 vendor/toml++/impl/node.inl create mode 100644 vendor/toml++/impl/node_view.hpp create mode 100644 vendor/toml++/impl/parse_error.hpp create mode 100644 vendor/toml++/impl/parse_result.hpp create mode 100644 vendor/toml++/impl/parser.hpp create mode 100644 vendor/toml++/impl/parser.inl create mode 100644 vendor/toml++/impl/path.hpp create mode 100644 vendor/toml++/impl/path.inl create mode 100644 vendor/toml++/impl/preprocessor.hpp create mode 100644 vendor/toml++/impl/print_to_stream.hpp create mode 100644 vendor/toml++/impl/print_to_stream.inl create mode 100644 vendor/toml++/impl/simd.hpp create mode 100644 vendor/toml++/impl/source_region.hpp create mode 100644 vendor/toml++/impl/std_except.hpp create mode 100644 vendor/toml++/impl/std_initializer_list.hpp create mode 100644 vendor/toml++/impl/std_map.hpp create mode 100644 vendor/toml++/impl/std_new.hpp create mode 100644 vendor/toml++/impl/std_optional.hpp create mode 100644 vendor/toml++/impl/std_string.hpp create mode 100644 vendor/toml++/impl/std_string.inl create mode 100644 vendor/toml++/impl/std_utility.hpp create mode 100644 vendor/toml++/impl/std_variant.hpp create mode 100644 vendor/toml++/impl/std_vector.hpp create mode 100644 vendor/toml++/impl/table.hpp create mode 100644 vendor/toml++/impl/table.inl create mode 100644 vendor/toml++/impl/toml_formatter.hpp create mode 100644 vendor/toml++/impl/toml_formatter.inl create mode 100644 vendor/toml++/impl/unicode.hpp create mode 100644 vendor/toml++/impl/unicode.inl create mode 100644 vendor/toml++/impl/unicode_autogenerated.hpp create mode 100644 vendor/toml++/impl/value.hpp create mode 100644 vendor/toml++/impl/version.hpp create mode 100644 vendor/toml++/impl/yaml_formatter.hpp create mode 100644 vendor/toml++/impl/yaml_formatter.inl create mode 100644 vendor/toml++/toml.h create mode 100644 vendor/toml++/toml.hpp diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index f3f03e1..f9b8e2a 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -15,5 +15,5 @@ jobs: - uses: actions/checkout@v4 - name: Install Packages run: sudo apt update && sudo apt install build-essential - - name: Build BTB + - name: Build NeBuild run: make build-nebuild \ No newline at end of file diff --git a/GNUmakefile b/GNUmakefile index b298d7d..a195f86 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -19,5 +19,5 @@ build-nebuild-windows: .PHONY: help help: @echo "=> help: Show this help message." - @echo "=> build-nebuild-windows: Build BTB for Windows." - @echo "=> build-nebuild: Build BTB for POSIX." + @echo "=> build-nebuild-windows: Build NeBuild for Windows." + @echo "=> build-nebuild: Build NeBuild for POSIX." diff --git a/dev/BuildKit/Macros.h b/dev/BuildKit/Defines.h similarity index 81% rename from dev/BuildKit/Macros.h rename to dev/BuildKit/Defines.h index 98bf891..d408058 100644 --- a/dev/BuildKit/Macros.h +++ b/dev/BuildKit/Defines.h @@ -5,11 +5,7 @@ #pragma once -extern "C" { -#include -} - -#include +#include #define LIKELY(ARG) ((ARG) ? assert(false) : ((void) 0)) #define UNLIKELY(ARG) LIKELY(!(ARG)) @@ -24,11 +20,11 @@ extern "C" { #define LIBNEBUILD_UNUSED(X) ((void) X) -namespace BTB::Logger { -/// @brief replacement for std::cout for BTB logging. +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 BTB::Logger +} // namespace NeBuild::Logger diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h index 065bec3..a0e5d85 100644 --- a/dev/BuildKit/IManifestBuilder.h +++ b/dev/BuildKit/IManifestBuilder.h @@ -5,12 +5,11 @@ #pragma once -#include -#include +#include -#define NEBUILD_MANIFEST_BUILDER : public BTB::IManifestBuilder +#define NEBUILD_MANIFEST_BUILDER : public NeBuild::IManifestBuilder -namespace BTB { +namespace NeBuild { /// @brief Builder interface class. /// @note This class is meant to be used as an interface. class IManifestBuilder { @@ -29,4 +28,4 @@ class IManifestBuilder { virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) = 0; virtual const char* buildSystem() = 0; }; -} // namespace BTB \ No newline at end of file +} // namespace NeBuild \ No newline at end of file diff --git a/dev/BuildKit/Includes.h b/dev/BuildKit/Imports.h similarity index 88% rename from dev/BuildKit/Includes.h rename to dev/BuildKit/Imports.h index 4cb3043..b365dca 100644 --- a/dev/BuildKit/Includes.h +++ b/dev/BuildKit/Imports.h @@ -14,4 +14,10 @@ #include #include +extern "C" { +#include +} + +#include + #endif // NEBUILD_INCLUDES_H diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h index f7c769d..ba34a69 100644 --- a/dev/BuildKit/JSONManifestBuilder.h +++ b/dev/BuildKit/JSONManifestBuilder.h @@ -6,12 +6,12 @@ #pragma once #include -#include +#include /// @file JSONManifestBuilder.h /// @brief JSON manifest builder header file. -namespace BTB { +namespace NeBuild { /// @brief JSON builder class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER { public: @@ -30,4 +30,4 @@ class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER { bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override; const char* buildSystem() override; }; -} // namespace BTB \ No newline at end of file +} // namespace NeBuild \ No newline at end of file diff --git a/dev/BuildKit/TOMLManifestBuilder.h b/dev/BuildKit/TOMLManifestBuilder.h new file mode 100644 index 0000000..5037967 --- /dev/null +++ b/dev/BuildKit/TOMLManifestBuilder.h @@ -0,0 +1,33 @@ +// ============================================================= // +// nebuild +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include +#include + +/// @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. + /// @param arg_sz filename size + /// @param arg_val filename path. + /// @retval true build succeeded. + /// @retval false failed to build. + bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override; + const char* buildSystem() override; +}; +} // namespace NeBuild \ No newline at end of file diff --git a/dev/cli/CommandLine.cc b/dev/cli/Tool.cc similarity index 71% rename from dev/cli/CommandLine.cc rename to dev/cli/Tool.cc index e199e61..07aa220 100644 --- a/dev/cli/CommandLine.cc +++ b/dev/cli/Tool.cc @@ -4,7 +4,6 @@ // Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // -#include #include static bool kFailed = false; @@ -17,10 +16,10 @@ int main(int argc, char** argv) { std::string index_path = argv[index]; if (index_path == "-v" || index_path == "--version") { - BTB::Logger::info() << "Brought to you by Amlal El Mahrouss for the NeKernel project.\n"; - BTB::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n"; + NeBuild::Logger::info() << "Brought to you by Amlal El Mahrouss for NeKernel.org.\n"; + NeBuild::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n"; - BTB::Logger::info() + NeBuild::Logger::info() << "Bugs, issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; return EXIT_SUCCESS; @@ -28,38 +27,38 @@ int main(int argc, char** argv) { kDryRun = true; continue; } else if (index_path == "-h" || index_path == "--help") { - BTB::Logger::info() << "Usage: nebuild \n"; + NeBuild::Logger::info() << "Usage: nebuild \n"; return EXIT_SUCCESS; } if (index_path.starts_with("-")) { - BTB::Logger::info() << "error: unknown option '" << index_path << "'\n"; + NeBuild::Logger::info() << "error: unknown option '" << index_path << "'\n"; return EXIT_FAILURE; } std::thread job_build_thread( [](std::string index_path) -> void { - BTB::IManifestBuilder* builder = nullptr; + NeBuild::IManifestBuilder* builder = nullptr; const auto kJsonExtension = ".json"; if (index_path.ends_with(kJsonExtension)) { - builder = new BTB::JSONManifestBuilder(); + builder = new NeBuild::JSONManifestBuilder(); if (!builder) { kFailed = true; return; } } else { - BTB::Logger::info() << "error: file '" << index_path << "' is not a JSON file!" + NeBuild::Logger::info() << "error: file '" << index_path << "' is not a JSON file!" << std::endl; kFailed = true; return; } - BTB::Logger::info() << "building manifest: " << index_path << std::endl; + NeBuild::Logger::info() << "building manifest: " << index_path << std::endl; if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun)) { kFailed = true; diff --git a/dev/examples/example_02_libbtb/libbtb.cc b/dev/examples/example_02_libbtb/libbtb.cc index 0b4d7c4..e6e489d 100644 --- a/dev/examples/example_02_libbtb/libbtb.cc +++ b/dev/examples/example_02_libbtb/libbtb.cc @@ -8,7 +8,7 @@ static auto kPath = ".\win64.json"; #endif int main(int argc, char** argv) { - auto builder = new BTB::JSONManifestBuilder(); + auto builder = new NeBuild::JSONManifestBuilder(); if (!builder) return EXIT_FAILURE; return builder->buildTarget(strlen(kPath), kPath); diff --git a/dev/examples/example_02_libbtb/posix.json b/dev/examples/example_02_libbtb/posix.json index 871712e..47f08ba 100644 --- a/dev/examples/example_02_libbtb/posix.json +++ b/dev/examples/example_02_libbtb/posix.json @@ -11,7 +11,7 @@ "output_name": "libbtb.elf", "compiler_flags": [ "-L/usr/local/lib", - "-lBTB" + "-lNeBuild" ], "cpp_macros": [ "FOO_MACRO" diff --git a/dev/examples/example_02_libbtb/win64.json b/dev/examples/example_02_libbtb/win64.json index 658ee0f..a873f5d 100644 --- a/dev/examples/example_02_libbtb/win64.json +++ b/dev/examples/example_02_libbtb/win64.json @@ -10,7 +10,7 @@ ], "output_name": "libbtb.exe", "compiler_flags": [ - "-lBTB" + "-lNeBuild" ], "cpp_macros": [ "FOO_MACRO" diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc index aa277c7..6b72ff0 100644 --- a/dev/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -10,7 +10,7 @@ using JSON = nlohmann::json; namespace FS = std::filesystem; -using namespace BTB; +using namespace NeBuild; /// @brief Builds a JSON target from a JSON file. /// @param arg_sz filename size (must be 1 or greater). @@ -21,13 +21,13 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo String path; if (!arg_val || arg_sz < 0) { - BTB::Logger::info() << "nebuild: error: file path is empty" << std::endl; + NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl; return false; } else { path += arg_val; if (!FS::exists(path)) { - BTB::Logger::info() << "nebuild: error: file '" << path << "' does not exist" << std::endl; + NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist" << std::endl; return false; } } @@ -36,7 +36,7 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo std::ifstream json(path); if (!json.good()) { - BTB::Logger::info() << "nebuild: error: file '" << path << "' is not a valid JSON" << std::endl; + NeBuild::Logger::info() << "nebuild: error: file '" << path << "' is not a valid JSON" << std::endl; return false; } @@ -76,8 +76,8 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo auto target = json_obj["output_name"].get(); - BTB::Logger::info() << "output path: " << target << "\n"; - BTB::Logger::info() << "command: " << command << "\n"; + NeBuild::Logger::info() << "output path: " << target << "\n"; + NeBuild::Logger::info() << "command: " << command << "\n"; try { if (json_obj["dry_run"].get()) return true; @@ -91,14 +91,14 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo auto ret_exec = std::system(command.c_str()); if (ret_exec > 0) { - BTB::Logger::info() << "error: exit with message: " << std::strerror(ret_exec) << "" << std::endl; + NeBuild::Logger::info() << "error: exit with message: " << std::strerror(ret_exec) << "" << std::endl; return false; } try { if (json_obj["run_after_build"].get()) { if (target.ends_with(".so")) { - BTB::Logger::info() << "error: can't open dynamic library, it mayn't have an entrypoint" + NeBuild::Logger::info() << "error: can't open dynamic library, it mayn't have an entrypoint" << std::endl; return true; @@ -109,20 +109,20 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo ss << file.rdbuf(); if (ss.str()[0] == 'O' && ss.str()[1] == 'p' && ss.str()[2] == 'e' && ss.str()[3] == 'n') - BTB::Logger::info() + NeBuild::Logger::info() << "error: can't open PEF dynamic library, it mayn't contain an entrypoint" << std::endl; else if (ss.str()[0] == 'n' && ss.str()[1] == 'e' && ss.str()[2] == 'p' && ss.str()[3] == 'O') - BTB::Logger::info() + NeBuild::Logger::info() << "error: can't open FEP dynamic library, it mayn't contain an entrypoint" << std::endl; else if (ss.str()[0] == 'M' && ss.str()[1] == 'Z') - BTB::Logger::info() + NeBuild::Logger::info() << "error: can't open MZ dynamic library, it mayn't contain an entrypoint" << std::endl; else if (ss.str()[0] == 0x7F && ss.str()[1] == 'E') { - BTB::Logger::info() + NeBuild::Logger::info() << "error: can't open ELF dynamic library, it mayn't contain an entrypoint" << std::endl; } @@ -140,7 +140,7 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo return true; } } catch (std::runtime_error& err) { - BTB::Logger::info() << "error: " << err.what() << std::endl; + NeBuild::Logger::info() << "error: " << err.what() << std::endl; return false; } diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000..e69de29 diff --git a/vendor/json.h b/vendor/json/json.h similarity index 100% rename from vendor/json.h rename to vendor/json/json.h diff --git a/vendor/json_fwd.h b/vendor/json/json_fwd.h similarity index 100% rename from vendor/json_fwd.h rename to vendor/json/json_fwd.h diff --git a/vendor/toml++/impl/array.hpp b/vendor/toml++/impl/array.hpp new file mode 100644 index 0000000..ad79379 --- /dev/null +++ b/vendor/toml++/impl/array.hpp @@ -0,0 +1,1790 @@ +//# This file is a part of toml++ and is subject to the the terms of the MIT license. +//# Copyright (c) Mark Gillard +//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. +// SPDX-License-Identifier: MIT +#pragma once + +#include "std_utility.hpp" +#include "std_vector.hpp" +#include "std_initializer_list.hpp" +#include "value.hpp" +#include "make_node.hpp" +#include "header_start.hpp" + +#ifndef TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN +#if TOML_GCC && TOML_GCC <= 7 +#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 1 +#else +#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN 0 +#endif +#endif + +#if TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN && !defined(TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED) +#define TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_MESSAGE \ + "If you're seeing this error it's because you're using one of toml++'s for_each() functions on a compiler with " \ + "known bugs in that area (e.g. GCC 7). On these compilers returning a bool (or bool-convertible) value from the " \ + "for_each() callable causes spurious compilation failures, while returning nothing (void) works fine. " \ + "If you believe this message is incorrect for your compiler, you can try your luck by #defining " \ + "TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN as 0 and recompiling - if it works, great! Let me know at " \ + "https://github.com/marzer/tomlplusplus/issues. Alternatively, if you don't have any need for early-exiting from " \ + "for_each(), you can suppress this error by #defining TOML_RETURN_BOOL_FROM_FOR_EACH_BROKEN_ACKNOWLEDGED " \ + "and moving on with your life." +#endif + +/// \cond +TOML_IMPL_NAMESPACE_START +{ + template + class TOML_TRIVIAL_ABI array_iterator + { + private: + template + friend class array_iterator; + + using mutable_vector_iterator = std::vector::iterator; + using const_vector_iterator = std::vector::const_iterator; + using vector_iterator = std::conditional_t; + + mutable vector_iterator iter_; + + public: + using value_type = std::conditional_t; + using reference = value_type&; + using pointer = value_type*; + using difference_type = ptrdiff_t; + using iterator_category = typename std::iterator_traits::iterator_category; + + TOML_NODISCARD_CTOR + array_iterator() noexcept = default; + + TOML_NODISCARD_CTOR + explicit array_iterator(mutable_vector_iterator iter) noexcept // + : iter_{ iter } + {} + + TOML_CONSTRAINED_TEMPLATE(C, bool C = IsConst) + TOML_NODISCARD_CTOR + explicit array_iterator(const_vector_iterator iter) noexcept // + : iter_{ iter } + {} + + TOML_CONSTRAINED_TEMPLATE(C, bool C = IsConst) + TOML_NODISCARD_CTOR + array_iterator(const array_iterator& other) noexcept // + : iter_{ other.iter_ } + {} + + TOML_NODISCARD_CTOR + array_iterator(const array_iterator&) noexcept = default; + + array_iterator& operator=(const array_iterator&) noexcept = default; + + array_iterator& operator++() noexcept // ++pre + { + ++iter_; + return *this; + } + + array_iterator operator++(int) noexcept // post++ + { + array_iterator out{ iter_ }; + ++iter_; + return out; + } + + array_iterator& operator--() noexcept // --pre + { + --iter_; + return *this; + } + + array_iterator operator--(int) noexcept // post-- + { + array_iterator out{ iter_ }; + --iter_; + return out; + } + + TOML_PURE_INLINE_GETTER + reference operator*() const noexcept + { + return *iter_->get(); + } + + TOML_PURE_INLINE_GETTER + pointer operator->() const noexcept + { + return iter_->get(); + } + + TOML_PURE_INLINE_GETTER + explicit operator const vector_iterator&() const noexcept + { + return iter_; + } + + TOML_CONSTRAINED_TEMPLATE(!C, bool C = IsConst) + TOML_PURE_INLINE_GETTER + explicit operator const const_vector_iterator() const noexcept + { + return iter_; + } + + array_iterator& operator+=(ptrdiff_t rhs) noexcept + { + iter_ += rhs; + return *this; + } + + array_iterator& operator-=(ptrdiff_t rhs) noexcept + { + iter_ -= rhs; + return *this; + } + + TOML_NODISCARD + friend array_iterator operator+(const array_iterator& lhs, ptrdiff_t rhs) noexcept + { + return array_iterator{ lhs.iter_ + rhs }; + } + + TOML_NODISCARD + friend array_iterator operator+(ptrdiff_t lhs, const array_iterator& rhs) noexcept + { + return array_iterator{ rhs.iter_ + lhs }; + } + + TOML_NODISCARD + friend array_iterator operator-(const array_iterator& lhs, ptrdiff_t rhs) noexcept + { + return array_iterator{ lhs.iter_ - rhs }; + } + + TOML_PURE_INLINE_GETTER + friend ptrdiff_t operator-(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ - rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator==(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ == rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator!=(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ != rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator<(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ < rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator<=(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ <= rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator>(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ > rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + friend bool operator>=(const array_iterator& lhs, const array_iterator& rhs) noexcept + { + return lhs.iter_ >= rhs.iter_; + } + + TOML_PURE_INLINE_GETTER + reference operator[](ptrdiff_t idx) const noexcept + { + return *(iter_ + idx)->get(); + } + }; + + struct array_init_elem + { + mutable node_ptr value; + + template + TOML_NODISCARD_CTOR + array_init_elem(T&& val, value_flags flags = preserve_source_value_flags) // + : value{ make_node(static_cast(val), flags) } + {} + }; +} +TOML_IMPL_NAMESPACE_END; +/// \endcond + +TOML_NAMESPACE_START +{ + /// \brief A RandomAccessIterator for iterating over elements in a toml::array. + using array_iterator = POXY_IMPLEMENTATION_DETAIL(impl::array_iterator); + + /// \brief A RandomAccessIterator for iterating over const elements in a toml::array. + using const_array_iterator = POXY_IMPLEMENTATION_DETAIL(impl::array_iterator); + + /// \brief A TOML array. + /// + /// \detail The interface of this type is modeled after std::vector, with some + /// additional considerations made for the heterogeneous nature of a + /// TOML array. + /// + /// \godbolt{sjK4da} + /// + /// \cpp + /// + /// toml::table tbl = toml::parse(R"( + /// arr = [1, 2, 3, 4, 'five'] + /// )"sv); + /// + /// // get the element as an array + /// toml::array& arr = *tbl.get_as("arr"); + /// std::cout << arr << "\n"; + /// + /// // increment each element with visit() + /// for (auto&& elem : arr) + /// { + /// elem.visit([](auto&& el) noexcept + /// { + /// if constexpr (toml::is_number) + /// (*el)++; + /// else if constexpr (toml::is_string) + /// el = "six"sv; + /// }); + /// } + /// std::cout << arr << "\n"; + /// + /// // add and remove elements + /// arr.push_back(7); + /// arr.push_back(8.0f); + /// arr.push_back("nine"sv); + /// arr.erase(arr.cbegin()); + /// std::cout << arr << "\n"; + /// + /// // emplace elements + /// arr.emplace_back("ten"); + /// arr.emplace_back(11, 12.0); + /// std::cout << arr << "\n"; + /// \ecpp + /// + /// \out + /// [ 1, 2, 3, 4, 'five' ] + /// [ 2, 3, 4, 5, 'six' ] + /// [ 3, 4, 5, 'six', 7, 8.0, 'nine' ] + /// [ 3, 4, 5, 'six', 7, 8.0, 'nine', 'ten', [ 11, 12.0 ] ] + /// \eout + class TOML_EXPORTED_CLASS array : public node + { + private: + /// \cond + + using vector_type = std::vector; + using vector_iterator = typename vector_type::iterator; + using const_vector_iterator = typename vector_type::const_iterator; + vector_type elems_; + + TOML_NODISCARD_CTOR + TOML_EXPORTED_MEMBER_FUNCTION + array(const impl::array_init_elem*, const impl::array_init_elem*); + + TOML_NODISCARD_CTOR + array(std::false_type, std::initializer_list elems) // + : array{ elems.begin(), elems.end() } + {} + + TOML_EXPORTED_MEMBER_FUNCTION + void preinsertion_resize(size_t idx, size_t count); + + TOML_EXPORTED_MEMBER_FUNCTION + void insert_at_back(impl::node_ptr&&); + + TOML_EXPORTED_MEMBER_FUNCTION + vector_iterator insert_at(const_vector_iterator, impl::node_ptr&&); + + template + void emplace_back_if_not_empty_view(T&& val, value_flags flags) + { + if constexpr (is_node_view) + { + if (!val) + return; + } + insert_at_back(impl::make_node(static_cast(val), flags)); + } + + TOML_NODISCARD + TOML_EXPORTED_MEMBER_FUNCTION + size_t total_leaf_count() const noexcept; + + TOML_EXPORTED_MEMBER_FUNCTION + void flatten_child(array&& child, size_t& dest_index) noexcept; + + /// \endcond + + public: + using value_type = node; + using size_type = size_t; + using difference_type = ptrdiff_t; + using reference = node&; + using const_reference = const node&; + + /// \brief Default constructor. + TOML_NODISCARD_CTOR + TOML_EXPORTED_MEMBER_FUNCTION + array() noexcept; + + TOML_EXPORTED_MEMBER_FUNCTION + ~array() noexcept; + + /// \brief Copy constructor. + TOML_NODISCARD_CTOR + TOML_EXPORTED_MEMBER_FUNCTION + array(const array&); + + /// \brief Move constructor. + TOML_NODISCARD_CTOR + TOML_EXPORTED_MEMBER_FUNCTION + array(array&& other) noexcept; + + /// \brief Constructs an array with one or more initial elements. + /// + /// \detail \cpp + /// auto arr = toml::array{ 1, 2.0, "three"sv, toml::array{ 4, 5 } }; + /// std::cout << arr << "\n"; + /// \ecpp + /// + /// \out + /// [ 1, 2.0, 'three', [ 4, 5 ] ] + /// \eout + /// + /// \remark \parblock If you need to construct an array with one child array element, the array's move constructor + /// will take precedence and perform a move-construction instead. You can use toml::inserter to + /// suppress this behaviour: \cpp + /// // desired result: [ [ 42 ] ] + /// auto bad = toml::array{ toml::array{ 42 } } + /// auto good = toml::array{ toml::inserter{ toml::array{ 42 } } } + /// std::cout << "bad: " << bad << "\n"; + /// std::cout << "good:" << good << "\n"; + /// \ecpp + /// + /// \out + /// bad: [ 42 ] + /// good: [ [ 42 ] ] + /// \eout + /// + /// \endparblock + /// + /// \tparam ElemType One of the TOML node or value types (or a type promotable to one). + /// \tparam ElemTypes One of the TOML node or value types (or a type promotable to one). + /// \param val The node or value used to initialize element 0. + /// \param vals The nodes or values used to initialize elements 1...N. + TOML_CONSTRAINED_TEMPLATE((sizeof...(ElemTypes) > 0 || !std::is_same_v, array>), + typename ElemType, + typename... ElemTypes) + TOML_NODISCARD_CTOR + explicit array(ElemType&& val, ElemTypes&&... vals) + : array{ std::false_type{}, + std::initializer_list{ static_cast(val), + static_cast(vals)... } } + {} + + /// \brief Copy-assignment operator. + TOML_EXPORTED_MEMBER_FUNCTION + array& operator=(const array&); + + /// \brief Move-assignment operator. + TOML_EXPORTED_MEMBER_FUNCTION + array& operator=(array&& rhs) noexcept; + + /// \name Type checks + /// @{ + + /// \brief Returns #toml::node_type::array. + TOML_CONST_INLINE_GETTER + node_type type() const noexcept final + { + return node_type::array; + } + + TOML_PURE_GETTER + TOML_EXPORTED_MEMBER_FUNCTION + bool is_homogeneous(node_type ntype) const noexcept final; + + TOML_PURE_GETTER + TOML_EXPORTED_MEMBER_FUNCTION + bool is_homogeneous(node_type ntype, node*& first_nonmatch) noexcept final; + + TOML_PURE_GETTER + TOML_EXPORTED_MEMBER_FUNCTION + bool is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept final; + + /// \cond + template + TOML_PURE_GETTER + bool is_homogeneous() const noexcept + { + using type = impl::remove_cvref>; + static_assert(std::is_void_v || toml::is_value || toml::is_container, + "The template type argument of array::is_homogeneous() must be void or one " + "of:" TOML_SA_UNWRAPPED_NODE_TYPE_LIST); + + return is_homogeneous(impl::node_type_of); + } + /// \endcond + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_table() const noexcept final + { + return false; + } + + /// \brief Returns `true`. + TOML_CONST_INLINE_GETTER + bool is_array() const noexcept final + { + return true; + } + + /// \brief Returns `true` if the array contains only tables. + TOML_PURE_GETTER + bool is_array_of_tables() const noexcept final + { + return is_homogeneous(node_type::table); + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_value() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_string() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_integer() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_floating_point() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_number() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_boolean() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_date() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_time() const noexcept final + { + return false; + } + + /// \brief Returns `false`. + TOML_CONST_INLINE_GETTER + bool is_date_time() const noexcept final + { + return false; + } + + /// @} + + /// \name Type casts + /// @{ + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + table* as_table() noexcept final + { + return nullptr; + } + + /// \brief Returns a pointer to the array. + TOML_CONST_INLINE_GETTER + array* as_array() noexcept final + { + return this; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value* as_string() noexcept final + { + return nullptr; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value* as_integer() noexcept final + { + return nullptr; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value* as_floating_point() noexcept final + { + return nullptr; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value* as_boolean() noexcept final + { + return nullptr; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value* as_date() noexcept final + { + return nullptr; + } + + /// \brief Returns `nullptr`. + TOML_CONST_INLINE_GETTER + toml::value