From c51737aad748d7ee00231bb58f61aefe04e480fb Mon Sep 17 00:00:00 2001 From: Amlal Date: Sat, 14 Dec 2024 16:30:27 +0100 Subject: Add dry_run field support. Signed-off-by: Amlal --- BTBKit/IManifestBuilder.h | 2 +- BTBKit/JSONManifestBuilder.h | 2 +- BTBKit/Macros.h | 2 +- ReadMe.md | 11 +++--- cli/ManifestBuilder.cc | 79 -------------------------------------------- cli/ManifestCLI.cc | 79 ++++++++++++++++++++++++++++++++++++++++++++ src/IManifestBuilder.cc | 2 +- src/JSONManifestBuilder.cc | 22 ++++++++---- 8 files changed, 104 insertions(+), 95 deletions(-) delete mode 100644 cli/ManifestBuilder.cc create mode 100644 cli/ManifestCLI.cc diff --git a/BTBKit/IManifestBuilder.h b/BTBKit/IManifestBuilder.h index 48ef3e2..95d9e88 100644 --- a/BTBKit/IManifestBuilder.h +++ b/BTBKit/IManifestBuilder.h @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, ELMH Group, all rights reserved. +// Copyright (C) 2024, Theater Quality Inc, all rights reserved. // ============================================================= // #pragma once diff --git a/BTBKit/JSONManifestBuilder.h b/BTBKit/JSONManifestBuilder.h index 1975a68..10d0857 100644 --- a/BTBKit/JSONManifestBuilder.h +++ b/BTBKit/JSONManifestBuilder.h @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, ELMH Group, all rights reserved. +// Copyright (C) 2024, Theater Quality Inc, all rights reserved. // ============================================================= // #pragma once diff --git a/BTBKit/Macros.h b/BTBKit/Macros.h index 15986fb..64dcd55 100644 --- a/BTBKit/Macros.h +++ b/BTBKit/Macros.h @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, ELMH Group, all rights reserved. +// Copyright (C) 2024, Theater Quality Inc, all rights reserved. // ============================================================= // #pragma once diff --git a/ReadMe.md b/ReadMe.md index 3d9599e..1bea1e4 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -1,17 +1,16 @@ # BTB. -A tool by ELMH Group to build libraries and programs. - ## Installation requirements: -- GNU C++ Compiler. +- GNU C++ +- GNU Make -## Steps (makefile): +## Steps (GNU Make): - Run make `build-btb-core` and `build-btb`. -## Steps (btb): +## Steps (BTB && OpenBTB): - Run `btb` and pass the path to the manifest file. -###### Copyright (C) 2024, ELMH Group, all rights reserved. All rights reserved. \ No newline at end of file +###### Copyright (C) 2024, Theater Quality Inc, all rights reserved. All rights reserved. \ No newline at end of file diff --git a/cli/ManifestBuilder.cc b/cli/ManifestBuilder.cc deleted file mode 100644 index ee05410..0000000 --- a/cli/ManifestBuilder.cc +++ /dev/null @@ -1,79 +0,0 @@ -// ============================================================= // -// btb -// Copyright (C) 2024, ELMH Group, 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: www.el-mahrouss-logic.com/btb/issues\n"; - - std::cout << "Brought to you by ELMH Group.\n"; - std::cout << "© ELMH Group, 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/cli/ManifestCLI.cc b/cli/ManifestCLI.cc new file mode 100644 index 0000000..01ac73e --- /dev/null +++ b/cli/ManifestCLI.cc @@ -0,0 +1,79 @@ +// ============================================================= // +// 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/src/IManifestBuilder.cc b/src/IManifestBuilder.cc index 20604de..c649afe 100644 --- a/src/IManifestBuilder.cc +++ b/src/IManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, ELMH Group, all rights reserved. +// Copyright (C) 2024, Theater Quality Inc, all rights reserved. // ============================================================= // #include diff --git a/src/JSONManifestBuilder.cc b/src/JSONManifestBuilder.cc index d737dcb..358f990 100644 --- a/src/JSONManifestBuilder.cc +++ b/src/JSONManifestBuilder.cc @@ -1,6 +1,6 @@ // ============================================================= // // btb -// Copyright (C) 2024, ELMH Group, all rights reserved. +// Copyright (C) 2024, Theater Quality Inc, all rights reserved. // ============================================================= // #include @@ -86,6 +86,16 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo std::cout << "btb: output path: " << target << "\n"; std::cout << "btb: command: " << command << "\n"; + try + { + if (json_obj["dry_run"].get()) + return true; + } + catch (...) + { + + } + if (dry_run) { return true; @@ -105,7 +115,7 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo { if (target.ends_with(".so")) { - std::cout << "btb: error: can't open DLL/SO, it mayn't contain an entrypoint." << std::endl; + std::cout << "btb: error: can't open dynamic library, it may not have an entrypoint." << std::endl; return true; } else if (target.ends_with(".dll")) @@ -119,19 +129,19 @@ bool JSONManifestBuilder::buildTarget(int arg_sz, const char* arg_val, const boo ss.str()[1] == 'o' && ss.str()[2] == 'y' && ss.str()[3] == '!') - std::cout << "btb: error: can't open Joy! DLL, it maynt't contain an entrypoint." << std::endl; + std::cout << "btb: error: can't open Joy! dynamic library, it maynt't contain an entrypoint." << std::endl; else if (ss.str()[0] == '!' && ss.str()[1] == 'y' && ss.str()[2] == 'o' && ss.str()[3] == 'J') - std::cout << "btb: error: can't open !yoJ DLL, it maynt't contain an entrypoint." << std::endl; + std::cout << "btb: error: can't open !yoJ dynamic library, it maynt't contain an entrypoint." << std::endl; else if (ss.str()[0] == 'M' && ss.str()[1] == 'Z') - std::cout << "btb: error: can't open MZ DLL, it maynt't contain an entrypoint." << std::endl; + std::cout << "btb: error: can't open MZ dynamic library, it maynt't contain an entrypoint." << std::endl; else if (ss.str()[0] == 0x7F && ss.str()[1] == 'E') { - std::cout << "btb: error: can't open ELF DLL, it maynt't contain an entrypoint." << std::endl; + std::cout << "btb: error: can't open ELF dynamic library, it maynt't contain an entrypoint." << std::endl; } return true; -- cgit v1.2.3