From 72f132b8fb9f2a47b0f723f4dc4eaa4fdb0c45bd Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 23 Apr 2025 08:22:28 +0200 Subject: dev: Improve makefile, add BTB_POSIX, and BTB_WINDOWS macro. - Refactor library code for better maintenance. - Improve code quality by using well known macros for status code. - Don't let the CLI pass when '-' is being passed as argument and is not recognized. Signed-off-by: Amlal El Mahrouss --- lib/IManifestBuilder.h | 35 +++++++++++++++++++---------------- lib/Includes.h | 5 +++++ lib/JSONManifestBuilder.h | 35 +++++++++++++++++++---------------- lib/Macros.h | 13 +++++++------ 4 files changed, 50 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/IManifestBuilder.h b/lib/IManifestBuilder.h index 2aa45db..a48511c 100644 --- a/lib/IManifestBuilder.h +++ b/lib/IManifestBuilder.h @@ -8,23 +8,26 @@ #include #include -/// @brief Builder interface class. -/// @note This class is meant to be used as an interface. -class IManifestBuilder +namespace BTB { -public: - explicit IManifestBuilder() = default; - virtual ~IManifestBuilder() = default; + /// @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; + 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; + /// @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; -}; + virtual const char* buildSystem() = 0; + }; +} // namespace BTB \ No newline at end of file diff --git a/lib/Includes.h b/lib/Includes.h index 070f80b..3f035f3 100644 --- a/lib/Includes.h +++ b/lib/Includes.h @@ -1,3 +1,8 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + #ifndef BTB_INCLUDES_H #define BTB_INCLUDES_H diff --git a/lib/JSONManifestBuilder.h b/lib/JSONManifestBuilder.h index ae2d482..fef5baf 100644 --- a/lib/JSONManifestBuilder.h +++ b/lib/JSONManifestBuilder.h @@ -8,23 +8,26 @@ #include #include -/// @brief JSON builder -class JSONManifestBuilder final : public IManifestBuilder +namespace BTB { -public: - explicit JSONManifestBuilder() = default; - virtual ~JSONManifestBuilder() override = default; + /// @brief JSON builder + class JSONManifestBuilder final : public IManifestBuilder + { + public: + explicit JSONManifestBuilder() = default; + virtual ~JSONManifestBuilder() override = default; - JSONManifestBuilder& operator=(const JSONManifestBuilder&) = default; - JSONManifestBuilder(const JSONManifestBuilder&) = 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; + 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; -}; + virtual const char* buildSystem() override; + }; +} // namespace BTB \ No newline at end of file diff --git a/lib/Macros.h b/lib/Macros.h index 85fb45b..35a44a1 100644 --- a/lib/Macros.h +++ b/lib/Macros.h @@ -12,25 +12,26 @@ extern "C" #include -#define LIKELY(ARG) (ARG) ? assert(false) : ((void)0) +#define LIKELY(ARG) (ARG) ? assert(false) : ((void)0) #define UNLIKELY(ARG) LIKELY(!(ARG)) -#define LIBBTB_VERSION "1.2.0" +#define LIBBTB_VERSION "1.1.0" -#define LIBBTB_VERSION_BCD 0x0120 +#define LIBBTB_VERSION_BCD 0x0110 #define LIBBTB_VERSION_MAJOR 1 -#define LIBBTB_VERSION_MINOR 0 +#define LIBBTB_VERSION_MINOR 1 #define LIBBTB_VERSION_PATCH 0 #define LIBBTB_UNUSED(X) ((void)X) -namespace logger +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 -- cgit v1.2.3