Progressing
This commit is contained in:
@@ -9,7 +9,22 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
std::filesystem::path buildDir = "build";
|
||||||
|
std::error_code errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Output {
|
namespace Output {
|
||||||
|
bool checkValidBuildDir() {
|
||||||
|
if (!std::filesystem::exists(buildDir, errorCode) || !std::filesystem::is_directory(buildDir, errorCode)) {
|
||||||
|
fmt::print(fmt::fg(fmt::color::light_coral),
|
||||||
|
"[Lazymake] Cleanup failed. Nothing to clean :(\n"
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void printMenu() {
|
void printMenu() {
|
||||||
fmt::print("Usage: lmake [arguments]\n");
|
fmt::print("Usage: lmake [arguments]\n");
|
||||||
fmt::print("arguments:\n");
|
fmt::print("arguments:\n");
|
||||||
@@ -22,7 +37,7 @@ namespace Output {
|
|||||||
fmt::print(fmt::fg(fmt::color::light_green),
|
fmt::print(fmt::fg(fmt::color::light_green),
|
||||||
" build <extra cmake args> Run cmake and build.\n"
|
" build <extra cmake args> Run cmake and build.\n"
|
||||||
);
|
);
|
||||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
fmt::print(fmt::fg(fmt::color::light_golden_rod_yellow),
|
||||||
" run <optional args> Run build.\n"
|
" run <optional args> Run build.\n"
|
||||||
);
|
);
|
||||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
fmt::print(fmt::fg(fmt::color::light_coral),
|
||||||
@@ -40,34 +55,36 @@ namespace Output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printArgClean() {
|
void printArgClean() {
|
||||||
std::filesystem::path dirPath = "build";
|
// std::filesystem::path dirPath = "build";
|
||||||
std::error_code errorCode;
|
// std::error_code errorCode;
|
||||||
|
|
||||||
if (!std::filesystem::exists(dirPath, errorCode) || !std::filesystem::is_directory(dirPath, errorCode)) {
|
// if (!std::filesystem::exists(buildDir, errorCode) || !std::filesystem::is_directory(buildDir, errorCode)) {
|
||||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
// fmt::print(fmt::fg(fmt::color::light_coral),
|
||||||
"[Lazymake] Cleanup failed. Nothing to clean :(\n"
|
// "[Lazymake] Cleanup failed. Nothing to clean :(\n"
|
||||||
);
|
// );
|
||||||
return;
|
// return;
|
||||||
}
|
|
||||||
|
|
||||||
std::filesystem::remove_all(dirPath, errorCode);
|
|
||||||
|
|
||||||
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
|
|
||||||
// std::filesystem::remove_all(entry.path());
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (errorCode) {
|
if (checkValidBuildDir()) {
|
||||||
fmt::print(fmt::fg(fmt::color::light_coral),
|
std::filesystem::remove_all(buildDir, errorCode);
|
||||||
"[Lazymake] Error! Could not clean up build directory :(\n {}\n", errorCode.message()
|
|
||||||
|
// for (const auto& entry : std::filesystem::directory_iterator(dirPath)) {
|
||||||
|
// std::filesystem::remove_all(entry.path());
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (errorCode) {
|
||||||
|
fmt::print(fmt::fg(fmt::color::light_coral),
|
||||||
|
"[Lazymake] Error! Could not clean up build directory :(\n {}\n", errorCode.message()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::filesystem::create_directory(buildDir, errorCode);
|
||||||
|
|
||||||
|
fmt::print(fmt::fg(fmt::color::light_green),
|
||||||
|
"[Lazymake] Cleaned up build directory :D\n"
|
||||||
);
|
);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::create_directory(dirPath, errorCode);
|
|
||||||
|
|
||||||
fmt::print(fmt::fg(fmt::color::light_green),
|
|
||||||
"[Lazymake] Cleaned up build directory :D\n"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void printArgVersion() {
|
void printArgVersion() {
|
||||||
@@ -106,4 +123,12 @@ namespace Output {
|
|||||||
);
|
);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void runBuild() {
|
||||||
|
if (checkValidBuildDir()) {
|
||||||
|
fmt::print("FOUND BUILD FOLDER\n");
|
||||||
|
std::system("./build/lmake");
|
||||||
|
fmt::print("333FOUND BUILD FOLDER2\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Output {
|
namespace Output {
|
||||||
|
bool checkValidBuildDir();
|
||||||
|
|
||||||
void printMenu();
|
void printMenu();
|
||||||
void printArgClean();
|
void printArgClean();
|
||||||
void printArgVersion();
|
void printArgVersion();
|
||||||
|
|
||||||
int executeCommand(const std::string& command, const std::string& successMsg);
|
int executeCommand(const std::string& command, const std::string& successMsg);
|
||||||
|
void runBuild();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ int main(int argc, char* argv[]) {
|
|||||||
Output::executeCommand("cmkr build", "Cmake build completed :D");
|
Output::executeCommand("cmkr build", "Cmake build completed :D");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (std::string_view(argv[1]) == "run") {
|
||||||
|
Output::runBuild();
|
||||||
|
}
|
||||||
|
|
||||||
if (std::string_view(argv[1]) == "clean") {
|
if (std::string_view(argv[1]) == "clean") {
|
||||||
Output::printArgClean();
|
Output::printArgClean();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user