From 1b5097d5035cb73a4845e914021851bf81186bfb Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 29 Nov 2025 21:15:44 -0500 Subject: chore: NeBuildKit: Architectural improvements over {Defines+Includes}.h Signed-off-by: Amlal El Mahrouss --- CMakeLists.txt | 1 + ReadMe.md | 22 ++++++++-------- format.sh | 10 -------- include/NeBuildKit/Config.h | 48 +++++++++++++++++++++++++++++++++++ include/NeBuildKit/Defines.h | 34 ------------------------- include/NeBuildKit/IManifestBuilder.h | 2 +- include/NeBuildKit/Imports.h | 23 ----------------- osx-dylib.json | 10 -------- osx.json | 10 -------- posix-dylib.json | 10 -------- posix.json | 10 -------- scripts/format.sh | 10 ++++++++ src/cli/main.cc | 5 ++-- targets/osx-dylib.json | 10 ++++++++ targets/osx.json | 10 ++++++++ targets/posix-dylib.json | 10 ++++++++ targets/posix.json | 10 ++++++++ targets/win64.json | 10 ++++++++ win64.json | 10 -------- 19 files changed, 122 insertions(+), 133 deletions(-) delete mode 100755 format.sh create mode 100644 include/NeBuildKit/Config.h delete mode 100644 include/NeBuildKit/Defines.h delete mode 100644 include/NeBuildKit/Imports.h delete mode 100644 osx-dylib.json delete mode 100644 osx.json delete mode 100644 posix-dylib.json delete mode 100644 posix.json create mode 100755 scripts/format.sh create mode 100644 targets/osx-dylib.json create mode 100644 targets/osx.json create mode 100644 targets/posix-dylib.json create mode 100644 targets/posix.json create mode 100644 targets/win64.json delete mode 100644 win64.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 7311780..78ab417 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ add_executable(nebuild ${NEBUILD_SOURCES}) target_include_directories(nebuild PRIVATE ${CMAKE_SOURCE_DIR}/dev ${CMAKE_SOURCE_DIR}/vendor) option(BUILD_WINDOWS "Produce a Windows executable name (nebuild.exe)" OFF) + if(BUILD_WINDOWS) set_target_properties(nebuild PROPERTIES OUTPUT_NAME "nebuild.exe") endif() diff --git a/ReadMe.md b/ReadMe.md index eb319b6..bb4d4dc 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -10,25 +10,23 @@ ## Guide (GNU Make): -- Run make `build-nebuild-core` and `build-nebuild`. +- Run make `build-nebuild-core` and `build-nebuild` to build from source. ## Guide (NeBuild): -- Run `nebuild` and pass the path to the manifest file. +- Run `nebuild` and pass the path to the manifest file to build from source: -## Guide (CMake): +```sh +nebuild targets/osx.json +``` -```zsh -# out-of-source configure + build (POSIX) -cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -cmake --build build --target nebuild +## Guide (CMake): -# or build the provided custom target -cmake --build build --target build-nebuild +- Use CMake to build `nebuild` from source: -# produce a Windows-style executable name on non-Windows hosts: -cmake -S . -B build -DBUILD_WINDOWS=ON -DCMAKE_BUILD_TYPE=Release -cmake --build build --target nebuild +```zsh +cmake -S . -B build +cmake --build build ``` ###### Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel.org Authors, licensed under the BSD 3 Clause license. diff --git a/format.sh b/format.sh deleted file mode 100755 index f36943c..0000000 --- a/format.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -THIS_PATH="$(realpath "$0")" -THIS_DIR="$(dirname "$THIS_PATH")" - -FILE_LIST="$(find "$THIS_DIR" | grep -E ".*(\.cc|\.c|\.h|\.inl)$")" - -echo -e "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\"" - -clang-format --verbose -i --style=file $FILE_LIST diff --git a/include/NeBuildKit/Config.h b/include/NeBuildKit/Config.h new file mode 100644 index 0000000..00be9de --- /dev/null +++ b/include/NeBuildKit/Config.h @@ -0,0 +1,48 @@ +// ============================================================= // +// nebuild +// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. +// ============================================================= // + +#pragma once + +/// =========================================================== /// +/// @author Amlal El Mahrouss +/// =========================================================== /// + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 0 +#define LIBNEBUILD_VERSION_MINOR 0 +#define LIBNEBUILD_VERSION_PATCH 7 + +#define LIBNEBUILD_EXPORT_C extern "C" + +#define LIBNEBUILD_UNUSED(X) ((void) X) + +namespace NeBuild {} + +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/include/NeBuildKit/Defines.h b/include/NeBuildKit/Defines.h deleted file mode 100644 index 06d936f..0000000 --- a/include/NeBuildKit/Defines.h +++ /dev/null @@ -1,34 +0,0 @@ -// ============================================================= // -// nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under BSD-3 license. -// ============================================================= // - -#pragma once - -#include - -/// =========================================================== /// -/// @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/include/NeBuildKit/IManifestBuilder.h b/include/NeBuildKit/IManifestBuilder.h index 96c80c3..7d3101c 100644 --- a/include/NeBuildKit/IManifestBuilder.h +++ b/include/NeBuildKit/IManifestBuilder.h @@ -5,7 +5,7 @@ #pragma once -#include +#include #define NEBUILD_MANIFEST_BUILDER : public ::NeBuild::IManifestBuilder diff --git a/include/NeBuildKit/Imports.h b/include/NeBuildKit/Imports.h deleted file mode 100644 index 33e1e31..0000000 --- a/include/NeBuildKit/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 -#include -#include -#include -#include -#include -#include -#include -#include - -#endif // NEBUILD_INCLUDES_H diff --git a/osx-dylib.json b/osx-dylib.json deleted file mode 100644 index d5b87bc..0000000 --- a/osx-dylib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["include", "vendor"], - "sources_path": ["src/lib/*.cc"], - "output_name": "libNeBuildKit.dylib", - "compiler_flags": ["-fPIC", "-shared"], - "cpp_macros": ["NEBUILD_DYLIB", "NEBUILD_OSX"], - "run_after_build": false -} diff --git a/osx.json b/osx.json deleted file mode 100644 index bdcab49..0000000 --- a/osx.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["include", "vendor"], - "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], - "output_name": "nebuild", - "compiler_flags": ["-fPIC"], - "cpp_macros": ["NEBUILD_POSIX", "NEBUILD_OSX"], - "run_after_build": false -} diff --git a/posix-dylib.json b/posix-dylib.json deleted file mode 100644 index 3326b3e..0000000 --- a/posix-dylib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["include/", "vendor"], - "sources_path": ["src/lib/*.cc"], - "output_name": "libNeBuildKit.so", - "compiler_flags": ["-fPIC", "-shared"], - "cpp_macros": ["NEBUILD_POSIX", "NEBUILD_DYLIB"], - "run_after_build": false -} diff --git a/posix.json b/posix.json deleted file mode 100644 index 679296c..0000000 --- a/posix.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["include/", "vendor"], - "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], - "output_name": "nebuild", - "compiler_flags": ["-fPIC"], - "cpp_macros": ["NEBUILD_POSIX"], - "run_after_build": false -} diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 0000000..f36943c --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +THIS_PATH="$(realpath "$0")" +THIS_DIR="$(dirname "$THIS_PATH")" + +FILE_LIST="$(find "$THIS_DIR" | grep -E ".*(\.cc|\.c|\.h|\.inl)$")" + +echo -e "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\"" + +clang-format --verbose -i --style=file $FILE_LIST diff --git a/src/cli/main.cc b/src/cli/main.cc index cbce3c0..02889ff 100644 --- a/src/cli/main.cc +++ b/src/cli/main.cc @@ -6,7 +6,6 @@ #include #include -#include "NeBuildKit/Defines.h" static bool kFailed = false; static bool kDryRun = false; @@ -18,9 +17,9 @@ int main(int argc, char** argv) { std::string index_path = argv[index]; if (index_path == "-v" || index_path == "-version") { - NeBuild::Logger::info() << "NeKernel Build.\n"; + NeBuild::Logger::info() << "NeBuild (" << LIBNEBUILD_VERSION << ")\n"; NeBuild::Logger::info() - << "Bugs, Issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; + << "Bugs, issues? https://github.com/nekernel-org/nebuild/issues\n"; return EXIT_SUCCESS; } else if (index_path == "-dry-run" || index_path == "-n") { diff --git a/targets/osx-dylib.json b/targets/osx-dylib.json new file mode 100644 index 0000000..d5b87bc --- /dev/null +++ b/targets/osx-dylib.json @@ -0,0 +1,10 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["include", "vendor"], + "sources_path": ["src/lib/*.cc"], + "output_name": "libNeBuildKit.dylib", + "compiler_flags": ["-fPIC", "-shared"], + "cpp_macros": ["NEBUILD_DYLIB", "NEBUILD_OSX"], + "run_after_build": false +} diff --git a/targets/osx.json b/targets/osx.json new file mode 100644 index 0000000..bdcab49 --- /dev/null +++ b/targets/osx.json @@ -0,0 +1,10 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["include", "vendor"], + "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], + "output_name": "nebuild", + "compiler_flags": ["-fPIC"], + "cpp_macros": ["NEBUILD_POSIX", "NEBUILD_OSX"], + "run_after_build": false +} diff --git a/targets/posix-dylib.json b/targets/posix-dylib.json new file mode 100644 index 0000000..3326b3e --- /dev/null +++ b/targets/posix-dylib.json @@ -0,0 +1,10 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["include/", "vendor"], + "sources_path": ["src/lib/*.cc"], + "output_name": "libNeBuildKit.so", + "compiler_flags": ["-fPIC", "-shared"], + "cpp_macros": ["NEBUILD_POSIX", "NEBUILD_DYLIB"], + "run_after_build": false +} diff --git a/targets/posix.json b/targets/posix.json new file mode 100644 index 0000000..679296c --- /dev/null +++ b/targets/posix.json @@ -0,0 +1,10 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["include/", "vendor"], + "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], + "output_name": "nebuild", + "compiler_flags": ["-fPIC"], + "cpp_macros": ["NEBUILD_POSIX"], + "run_after_build": false +} diff --git a/targets/win64.json b/targets/win64.json new file mode 100644 index 0000000..75c025a --- /dev/null +++ b/targets/win64.json @@ -0,0 +1,10 @@ +{ + "compiler_path": "x86_64-w64-mingw32-g++.exe", + "compiler_std": "c++20", + "headers_path": ["include", "vendor"], + "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], + "output_name": "nebuild.exe", + "compiler_flags": ["-fPIC"], + "cpp_macros": ["NEBUILD_WINDOWS"], + "run_after_build": false +} diff --git a/win64.json b/win64.json deleted file mode 100644 index 75c025a..0000000 --- a/win64.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compiler_path": "x86_64-w64-mingw32-g++.exe", - "compiler_std": "c++20", - "headers_path": ["include", "vendor"], - "sources_path": ["src/lib/*.cc", "src/cli/*.cc"], - "output_name": "nebuild.exe", - "compiler_flags": ["-fPIC"], - "cpp_macros": ["NEBUILD_WINDOWS"], - "run_after_build": false -} -- cgit v1.2.3