diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-22 10:22:16 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-22 10:22:16 +0200 |
| commit | e0b3869075eb6dd4d2d515f80056e2eeb1128fae (patch) | |
| tree | 5158781eb6c8513d69c703e1847e1dd84094c42f /BTBKit | |
| parent | 7927f01e875ef76185535d209c14230fe9be183d (diff) | |
feat(btb)!: Introducing libBTB, better API.
also:
- The Codebase has been improved.
- Error codes are now string messages.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'BTBKit')
| -rw-r--r-- | BTBKit/IManifestBuilder.h | 33 | ||||
| -rw-r--r-- | BTBKit/Includes.h | 17 | ||||
| -rw-r--r-- | BTBKit/JSONManifestBuilder.h | 31 | ||||
| -rw-r--r-- | BTBKit/Macros.h | 34 |
4 files changed, 115 insertions, 0 deletions
diff --git a/BTBKit/IManifestBuilder.h b/BTBKit/IManifestBuilder.h new file mode 100644 index 0000000..41c62df --- /dev/null +++ b/BTBKit/IManifestBuilder.h @@ -0,0 +1,33 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include <BTBKit/Includes.h> +#include <BTBKit/Macros.h> + +#define BTB_MANIFEST_BUILDER : public BTB::IManifestBuilder + +namespace BTB { +/// @brief Builder interface class. +/// @note This class is meant to be used as an interface. +class IManifestBuilder { + public: + explicit IManifestBuilder() = default; + virtual ~IManifestBuilder() = default; + + 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(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 diff --git a/BTBKit/Includes.h b/BTBKit/Includes.h new file mode 100644 index 0000000..3695d53 --- /dev/null +++ b/BTBKit/Includes.h @@ -0,0 +1,17 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#ifndef BTB_INCLUDES_H +#define BTB_INCLUDES_H + +#include <cstddef> +#include <cstdio> +#include <fstream> +#include <iostream> +#include <sstream> +#include <string> +#include <thread> + +#endif // BTB_INCLUDES_H diff --git a/BTBKit/JSONManifestBuilder.h b/BTBKit/JSONManifestBuilder.h new file mode 100644 index 0000000..6654a9b --- /dev/null +++ b/BTBKit/JSONManifestBuilder.h @@ -0,0 +1,31 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include <BTBKit/IManifestBuilder.h> +#include <json.h> + +namespace BTB { +/// @brief JSON builder +class JSONManifestBuilder final BTB_MANIFEST_BUILDER { + public: + explicit JSONManifestBuilder() = default; + virtual ~JSONManifestBuilder() override = default; + + JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default; + 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. + virtual bool buildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override; + + virtual const char* buildSystem() override; +}; +} // namespace BTB
\ No newline at end of file diff --git a/BTBKit/Macros.h b/BTBKit/Macros.h new file mode 100644 index 0000000..9d51a2f --- /dev/null +++ b/BTBKit/Macros.h @@ -0,0 +1,34 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +extern "C" { +#include <assert.h> +} + +#include <rang.h> + +#define LIKELY(ARG) (ARG) ? assert(false) : ((void) 0) +#define UNLIKELY(ARG) LIKELY(!(ARG)) + +#define LIBBTB_VERSION "1.1.0" + +#define LIBBTB_VERSION_BCD 0x0110 + +#define LIBBTB_VERSION_MAJOR 1 +#define LIBBTB_VERSION_MINOR 1 +#define LIBBTB_VERSION_PATCH 0 + +#define LIBBTB_UNUSED(X) ((void) X) + +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; + return out; +} +} // namespace BTB::Logger |
