From e1fd8b63b079d72d31bd7e0ea30fb7695891bc98 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 20 Mar 2025 05:04:26 +0100 Subject: META: A bunch of repository update for btb's relevancy. Signed-off-by: Amlal El Mahrouss --- .gitignore | 2 +- BTBKit/IManifestBuilder.h | 30 ----------------- BTBKit/Includes.h | 12 ------- BTBKit/JSONManifestBuilder.h | 30 ----------------- BTBKit/Macros.h | 21 ------------ cli/CommandLine.cc | 79 ++++++++++++++++++++++++++++++++++++++++++++ cli/ToolCLI.cc | 79 -------------------------------------------- compile_flags.txt | 2 +- lib/IManifestBuilder.h | 30 +++++++++++++++++ lib/Includes.h | 12 +++++++ lib/JSONManifestBuilder.h | 30 +++++++++++++++++ lib/Macros.h | 21 ++++++++++++ makefile | 4 +-- posix.json | 2 +- src/IManifestBuilder.cc | 2 +- src/JSONManifestBuilder.cc | 2 +- src/compile_flags.txt | 2 +- tests/posix.json | 2 +- tests/win64.json | 2 +- win64.json | 2 +- 20 files changed, 183 insertions(+), 183 deletions(-) delete mode 100644 BTBKit/IManifestBuilder.h delete mode 100644 BTBKit/Includes.h delete mode 100644 BTBKit/JSONManifestBuilder.h delete mode 100644 BTBKit/Macros.h create mode 100644 cli/CommandLine.cc delete mode 100644 cli/ToolCLI.cc create mode 100644 lib/IManifestBuilder.h create mode 100644 lib/Includes.h create mode 100644 lib/JSONManifestBuilder.h create mode 100644 lib/Macros.h diff --git a/.gitignore b/.gitignore index ddeacca..1511910 100644 --- a/.gitignore +++ b/.gitignore @@ -195,7 +195,7 @@ local.properties *.la *.lo -# Shared objects (BTBKit. Windows DLLs) +# Shared objects (SOs. Windows DLLs) *.dll *.so *.so.* diff --git a/BTBKit/IManifestBuilder.h b/BTBKit/IManifestBuilder.h deleted file mode 100644 index 95d9e88..0000000 --- a/BTBKit/IManifestBuilder.h +++ /dev/null @@ -1,30 +0,0 @@ -// ============================================================= // -// btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. -// ============================================================= // - -#pragma once - -#include -#include - -/// @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; -}; diff --git a/BTBKit/Includes.h b/BTBKit/Includes.h deleted file mode 100644 index 070f80b..0000000 --- a/BTBKit/Includes.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef BTB_INCLUDES_H -#define BTB_INCLUDES_H - -#include -#include -#include -#include -#include -#include -#include - -#endif // BTB_INCLUDES_H diff --git a/BTBKit/JSONManifestBuilder.h b/BTBKit/JSONManifestBuilder.h deleted file mode 100644 index 10d0857..0000000 --- a/BTBKit/JSONManifestBuilder.h +++ /dev/null @@ -1,30 +0,0 @@ -// ============================================================= // -// btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. -// ============================================================= // - -#pragma once - -#include -#include - -/// @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; - -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; -}; diff --git a/BTBKit/Macros.h b/BTBKit/Macros.h deleted file mode 100644 index 64dcd55..0000000 --- a/BTBKit/Macros.h +++ /dev/null @@ -1,21 +0,0 @@ -// ============================================================= // -// btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. -// ============================================================= // - -#pragma once - -#include - -#define LIKELY(ARG) (ARG) ? assert(false) : ((void)0) -#define UNLIKELY(ARG) LIKELY(!(ARG)) - -#define BTBKIT_VERSION "1.2.0" - -#define BTBKIT_VERSION_BCD 0x0120 - -#define BTBKIT_VERSION_MAJOR 1 -#define BTBKIT_VERSION_MINOR 0 -#define BTBKIT_VERSION_PATCH 0 - -#define BTB_UNUSED(X) ((void)X) diff --git a/cli/CommandLine.cc b/cli/CommandLine.cc new file mode 100644 index 0000000..231ee0b --- /dev/null +++ b/cli/CommandLine.cc @@ -0,0 +1,79 @@ + +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#include +#include + +static bool kFailed = false; +static bool kDryRun = false; + +int main(int argc, char** argv) +{ + if (argc <= 1) + return 1; + + for (size_t index = 1; index < argc; ++index) + { + std::string index_path = argv[index]; + + if (index_path == "-v" || + index_path == "--version") + { + std::cout << "Usage: btb \n"; + std::cout << "Check for issues at: theater-quality.com/developer/issues\n"; + + std::cout << "Brought to you by Amlal El Mahrouss.\n"; + std::cout << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n"; + + return EXIT_SUCCESS; + } + else if (index_path == "--dry-run") + { + kDryRun = true; + continue; + } + else if (index_path == "-h" || + index_path == "--help") + { + std::cout << "btb: Build a JSON file: btb .json\n"; + return EXIT_SUCCESS; + } + + std::thread job_build_thread([](std::string index_path) -> void { + IManifestBuilder* builder = nullptr; + + const auto kJsonExtension = ".json"; + + if (index_path.ends_with(kJsonExtension)) + { + builder = new JSONManifestBuilder(); + } + else + { + kFailed = true; + return; + } + + std::cout << "btb: building: " << index_path << std::endl; + + if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun)) + { + kFailed = true; + } + else if (!builder) + { + kFailed = true; + } + + delete builder; + builder = nullptr; + }, index_path); + + job_build_thread.join(); + } + + return kFailed ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/cli/ToolCLI.cc b/cli/ToolCLI.cc deleted file mode 100644 index 01ac73e..0000000 --- a/cli/ToolCLI.cc +++ /dev/null @@ -1,79 +0,0 @@ -// ============================================================= // -// btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. -// ============================================================= // - -#include -#include - -static bool kFailed = false; -static bool kDryRun = false; - -int main(int argc, char** argv) -{ - if (argc <= 1) - return 1; - - for (size_t index = 1; index < argc; ++index) - { - std::string index_path = argv[index]; - - if (index_path == "-v" || - index_path == "--version") - { - std::cout << "Usage: btb \n"; - std::cout << "Check for issues at: el-mahrouss-logic.com/developer/issues\n"; - - std::cout << "Brought to you by Theater Quality Inc.\n"; - std::cout << "© Theater Quality Inc, all rights reserved.\n"; - - return 0; - } - else if (index_path == "--dry-run") - { - kDryRun = true; - continue; - } - else if (index_path == "-h" || - index_path == "--help") - { - std::cout << "btb: Build a JSON file: btb .json\n"; - - return 0; - } - - std::thread job_build_thread([](std::string index_path) -> void { - IManifestBuilder* builder = nullptr; - - const auto kJsonExtension = ".json"; - - if (index_path.ends_with(kJsonExtension)) - { - builder = new JSONManifestBuilder(); - } - else - { - kFailed = true; - return; - } - - std::cout << "btb: building: " << index_path << std::endl; - - if (builder && !builder->buildTarget(index_path.size(), index_path.c_str(), kDryRun)) - { - kFailed = true; - } - else if (!builder) - { - kFailed = true; - } - - delete builder; - builder = nullptr; - }, index_path); - - job_build_thread.join(); - } - - return kFailed ? EXIT_FAILURE : EXIT_SUCCESS; -} diff --git a/compile_flags.txt b/compile_flags.txt index 6a43c77..32eb651 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,3 +1,3 @@ -std=c++20 --IBTBKit +-Ilib -Ivendor \ No newline at end of file diff --git a/lib/IManifestBuilder.h b/lib/IManifestBuilder.h new file mode 100644 index 0000000..2aa45db --- /dev/null +++ b/lib/IManifestBuilder.h @@ -0,0 +1,30 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include +#include + +/// @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; +}; diff --git a/lib/Includes.h b/lib/Includes.h new file mode 100644 index 0000000..070f80b --- /dev/null +++ b/lib/Includes.h @@ -0,0 +1,12 @@ +#ifndef BTB_INCLUDES_H +#define BTB_INCLUDES_H + +#include +#include +#include +#include +#include +#include +#include + +#endif // BTB_INCLUDES_H diff --git a/lib/JSONManifestBuilder.h b/lib/JSONManifestBuilder.h new file mode 100644 index 0000000..ae2d482 --- /dev/null +++ b/lib/JSONManifestBuilder.h @@ -0,0 +1,30 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include +#include + +/// @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; + +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; +}; diff --git a/lib/Macros.h b/lib/Macros.h new file mode 100644 index 0000000..e9adddb --- /dev/null +++ b/lib/Macros.h @@ -0,0 +1,21 @@ +// ============================================================= // +// btb +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#pragma once + +#include + +#define LIKELY(ARG) (ARG) ? assert(false) : ((void)0) +#define UNLIKELY(ARG) LIKELY(!(ARG)) + +#define BTBKIT_VERSION "1.2.0" + +#define BTBKIT_VERSION_BCD 0x0120 + +#define BTBKIT_VERSION_MAJOR 1 +#define BTBKIT_VERSION_MINOR 0 +#define BTBKIT_VERSION_PATCH 0 + +#define BTB_UNUSED(X) ((void)X) diff --git a/makefile b/makefile index 80f4277..4e3abe4 100644 --- a/makefile +++ b/makefile @@ -1,12 +1,12 @@ .PHONY: build-btb build-btb: - sudo g++ -I./BTBKit -I./vendor $(wildcard cli/*.cc) $(wildcard src/*.cc) -std=c++20 -o btb + sudo g++ -I./lib -I./vendor $(wildcard cli/*.cc) $(wildcard src/*.cc) -std=c++20 -o btb sudo cp btb /usr/local/bin .PHONY: build-btb-windows build-btb-windows: - x86_64-w64-mingw32-g++.exe -I./BTBKit -I./vendor $(wildcard cli/*.cc) $(wildcard src/*.cc) -std=c++20 -o btb.exe + x86_64-w64-mingw32-g++.exe -I./lib -I./vendor $(wildcard cli/*.cc) $(wildcard src/*.cc) -std=c++20 -o btb.exe .PHONY: help help: diff --git a/posix.json b/posix.json index f8a9232..f83572b 100644 --- a/posix.json +++ b/posix.json @@ -1,7 +1,7 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["BTBKit", "vendor"], + "headers_path": ["lib", "vendor"], "sources_path": ["src/*.cc", "cli/*.cc"], "output_name": "btb", "compiler_flags": ["-fPIC"], diff --git a/src/IManifestBuilder.cc b/src/IManifestBuilder.cc index c649afe..e3cfc6b 100644 --- a/src/IManifestBuilder.cc +++ b/src/IManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // #include diff --git a/src/JSONManifestBuilder.cc b/src/JSONManifestBuilder.cc index b16ae82..2b37f3e 100644 --- a/src/JSONManifestBuilder.cc +++ b/src/JSONManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, Theater Quality Inc, all rights reserved. +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. // ============================================================= // #include diff --git a/src/compile_flags.txt b/src/compile_flags.txt index b90486b..746d426 100644 --- a/src/compile_flags.txt +++ b/src/compile_flags.txt @@ -1,4 +1,4 @@ -std=c++20 --I../BTBKit +-I../lib -fPIC -shared diff --git a/tests/posix.json b/tests/posix.json index 90a94a1..17a6022 100644 --- a/tests/posix.json +++ b/tests/posix.json @@ -1,7 +1,7 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["BTBKit"], + "headers_path": ["lib"], "sources_path": ["example.cc"], "output_name": "example.elf", "compiler_flags": ["-fPIC"], diff --git a/tests/win64.json b/tests/win64.json index 718c9c5..1712d8b 100644 --- a/tests/win64.json +++ b/tests/win64.json @@ -1,7 +1,7 @@ { "compiler_path": "x86_64-w64-mingw32-g++", "compiler_std": "c++20", - "headers_path": ["BTBKit"], + "headers_path": ["lib"], "sources_path": ["example.cc"], "output_name": "example.elf", "compiler_flags": ["-fPIC"], diff --git a/win64.json b/win64.json index d7c4966..6a2a22e 100644 --- a/win64.json +++ b/win64.json @@ -1,7 +1,7 @@ { "compiler_path": "x86_64-w64-mingw32-g++.exe", "compiler_std": "c++20", - "headers_path": ["BTBKit", "vendor"], + "headers_path": ["lib", "vendor"], "sources_path": ["src/*.cc", "cli/*.cc"], "output_name": "btb.exe", "compiler_flags": ["-fPIC"], -- cgit v1.2.3