diff --git a/.gitignore b/.gitignore index bb4160f..ad28d83 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ build/ .idea *.dot +scripts/ diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 0fbcff9..609bf73 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,98 +1,197 @@ { - "version": "2.0.0", - "tasks": [ - { - "label": "Configure: Debug", - "type": "shell", - "command": "./scripts/build_script configure -b debug", - "group": { - "isDefault": false - }, - "problemMatcher": [], - "detail": "Configure Debug" - }, - { - "label": "Build: Debug", - "type": "shell", - "command": "./scripts/build_script build -b debug", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "detail": "Build Debug" - }, - { - "label": "Configure: Relwithdeb", - "type": "shell", - "command": "./scripts/build_script configure -b relwithdeb", - "group": { - "isDefault": false - }, - "problemMatcher": [], - "detail": "Configure Release with debug info" - }, - { - "label": "Build: Relwithdeb", - "type": "shell", - "command": "./scripts/build_script build -b relwithdeb", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "detail": "Build Release with debug info" - }, - { - "label": "Configure: Release", - "type": "shell", - "command": "./scripts/build_script configure -b release", - "group": { - "isDefault": false - }, - "problemMatcher": [], - "detail": "Configure Release" - }, - { - "label": "Build: Release", - "type": "shell", - "command": "./scripts/build_script build -b release", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "detail": "Build Release" - }, - { - "label": "Clean: Debug", - "type": "shell", - "command": "./scripts/build_script clean -b debug", - "group": { - "isDefault": false - }, - "detail": "Clean debug files" - }, - { - "label": "Build: All", - "type": "shell", - "command": "./scripts/build_script build", - "group": { - "kind": "build", - "isDefault": true - }, - "problemMatcher": [], - "detail": "Build all types" - }, - { - "label": "Clean: All", - "type": "shell", - "command": "./scripts/build_script clean", - "group": { - "isDefault": false - }, - "problemMatcher": [], - "detail": "Clean All files" + "version": "2.0.0", + "tasks": [ + { + "label": "Configure: Debug", + "type": "shell", + "command": "./scripts/build_script configure -b debug", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' configure -b debug -v" + ], + "options": { + "cwd": "${workspaceFolder}" } - ] + }, + "group": { + "isDefault": false + }, + "problemMatcher": [], + "detail": "Configure Debug" + }, + { + "label": "Build: Debug", + "type": "shell", + "command": "./scripts/build_script build -b debug", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' build -b debug" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Build Debug" + }, + { + "label": "Configure: Relwithdeb", + "type": "shell", + "command": "./scripts/build_script configure -b relwithdeb", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' configure -b relwithdeb" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "isDefault": false + }, + "problemMatcher": [], + "detail": "Configure Release with debug info" + }, + { + "label": "Build: Relwithdeb", + "type": "shell", + "command": "./scripts/build_script build -b relwithdeb", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' build -b relwithdeb" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Build Release with debug info" + }, + { + "label": "Configure: Release", + "type": "shell", + "command": "./scripts/build_script configure -b release", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' configure -b release" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "isDefault": false + }, + "problemMatcher": [], + "detail": "Configure Release" + }, + { + "label": "Build: Release", + "type": "shell", + "command": "./scripts/build_script build -b release", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' build -b release" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Build Release" + }, + { + "label": "Clean: Debug", + "type": "shell", + "command": "./scripts/build_script clean -b debug", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' clean -b debug" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "isDefault": false + }, + "detail": "Clean debug files" + }, + { + "label": "Build: All", + "type": "shell", + "command": "./scripts/build_script build", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' build" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [], + "detail": "Build all types" + }, + { + "label": "Clean: All", + "type": "shell", + "command": "./scripts/build_script clean", + "windows": { + "command": "powershell.exe", + "args": [ + "-NoProfile", + "-Command", + "& './scripts/build_script.exe' clean" + ], + "options": { + "cwd": "${workspaceFolder}" + } + }, + "group": { + "isDefault": false + }, + "problemMatcher": [], + "detail": "Clean All files" + } + ] } diff --git a/CMakeLists.txt b/CMakeLists.txt index ce943a3..aeaa32c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,12 +9,12 @@ add_compile_options(-Wno-deprecated-declarations) file(GLOB REQUIRED_CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.required.cmake") foreach (cmake_file ${REQUIRED_CMAKE_FILES}) - include(${cmake_file}) + include(${cmake_file}) endforeach () file(GLOB CMAKE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake") foreach (cmake_file ${CMAKE_FILES}) - include(${cmake_file}) + include(${cmake_file}) endforeach () include_directories(src/) diff --git a/src/app.h b/src/app.h index e8708e2..19accd5 100644 --- a/src/app.h +++ b/src/app.h @@ -35,6 +35,7 @@ class Application { void deleteDir(const std::filesystem::path& path); void createDir(const std::filesystem::path& path); + void checkDir(std::string path); void checkBuildDirs(); int runCmd(std::string cmd); diff --git a/src/commands.cpp b/src/commands.cpp index f5d96d8..856dad2 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -63,7 +63,7 @@ void Application::buildProject() { auto configureDirTask = m_Taskflow .emplace( - [this]() { this->configureDir("build/debug", "debug"); }) + [this]() { this->configureDir("build/debug", "Debug"); }) .name("configureDir(build/debug)"); auto buildDirTask = m_Taskflow.emplace([this]() { this->buildDir("build/debug"); }) @@ -122,7 +122,7 @@ void Application::configureProject() { auto configureDirDebugTask = m_Taskflow .emplace( - [this]() { this->configureDir("build/debug", "debug"); }) + [this]() { this->configureDir("build/debug", "Debug"); }) .name("configureDir(build/debug)"); checkBuildDirsTask.precede(configureDirDebugTask); @@ -154,7 +154,7 @@ void Application::configureProject() { auto configureDirDebugTask = m_Taskflow .emplace( - [this]() { this->configureDir("build/debug", "debug"); }) + [this]() { this->configureDir("build/debug", "Debug"); }) .name("configureDir(build/debug)"); checkBuildDirsTask.precede(configureDirDebugTask); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 91523bb..ff5e6bd 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -1,3 +1,4 @@ +#include #include #include "app.h" @@ -40,128 +41,43 @@ void Application::createDir(const std::filesystem::path& path) { } } -void Application::checkBuildDirs() { - spdlog::get("filesystem")->debug("Checking 'build' directory."); - if (!std::filesystem::is_directory("build")) { +void Application::checkDir(std::string path) { + spdlog::get("filesystem")->debug("Checking '{}' directory.", path); + + if (!std::filesystem::is_directory(path)) { + if (!std::filesystem::exists(path)) { + spdlog::get("filesystem") + ->info("Creating 'build/debug' directory."); + createDir(path); + return; + } spdlog::get("filesystem") - ->warn("'build' is not a directory. Deleting."); - deleteDir("build"); - } - if (!std::filesystem::exists("build")) { - spdlog::get("filesystem")->info("Creating 'build' directory"); - createDir("build"); + ->warn("'build/debug' is not a directory. Deleting."); + deleteDir("build/debug"); } +} + +void Application::checkBuildDirs() { + checkDir("build"); switch (m_BuildType) { case none: - spdlog::get("filesystem") - ->debug("Checking 'build/debug' directory."); - if (!std::filesystem::is_directory("build/debug")) { - spdlog::get("filesystem") - ->warn("'build/debug' is not a directory. Deleting."); - deleteDir("build/debug"); - } - if (!std::filesystem::exists("build/debug")) { - spdlog::get("filesystem") - ->info("Creating 'build/debug' directory."); - createDir("build/debug"); - } - - spdlog::get("filesystem") - ->debug("Checking 'build/release' directory."); - if (!std::filesystem::is_directory("build/release")) { - spdlog::get("filesystem") - ->warn("'build/release' is not a directory. Deleting."); - deleteDir("build/release"); - } - if (!std::filesystem::exists("build/release")) { - spdlog::get("filesystem") - ->info("Creating 'build/release' directory."); - createDir("build/release"); - } - - spdlog::get("filesystem") - ->debug("Checking 'build/relwithdeb' directory."); - if (!std::filesystem::is_directory("build/relwithdeb")) { - spdlog::get("filesystem") - ->warn("'build/relwithdeb' is not a directory. Deleting."); - deleteDir("build/relwithdeb"); - } - if (!std::filesystem::exists("build/relwithdeb")) { - spdlog::get("filesystem") - ->info("Creating 'build/relwithdeb' directory."); - createDir("build/relwithdeb"); - } - - spdlog::get("filesystem") - ->debug("Checking 'build/minsizerel' directory."); - if (!std::filesystem::is_directory("build/minsizerel")) { - spdlog::get("filesystem") - ->warn("'build/minsizerel' is not a directory. Deleting."); - deleteDir("build/minsizerel"); - } - if (!std::filesystem::exists("build/minsizerel")) { - spdlog::get("filesystem") - ->info("Creating 'build/minsizerel' directory."); - createDir("build/minsizerel"); - }; - + checkDir("build/debug"); + checkDir("build/release"); + checkDir("build/relwithdeb"); + checkDir("build/minsizerel"); break; case debug: - spdlog::get("filesystem") - ->debug("Checking 'build/debug' directory."); - if (!std::filesystem::is_directory("build/debug")) { - spdlog::get("filsystem") - ->warn("'build/debug' is not a directory. Deleting."); - deleteDir("build/debug"); - } - if (!std::filesystem::exists("build/debug")) { - spdlog::get("filesystem") - ->info("Creating 'build/debug' directory."); - createDir("build/debug"); - } + checkDir("build/debug"); break; case release: - spdlog::get("filesystem") - ->debug("Checking 'build/release' directory."); - if (!std::filesystem::is_directory("build/release")) { - spdlog::get("filesystem") - ->warn("'build/release' is not a directory. Deleting."); - deleteDir("build/release"); - } - if (!std::filesystem::exists("build/release")) { - spdlog::get("filesystem") - ->info("Creating 'build/release' directory."); - createDir("build/release"); - } + checkDir("build/release"); break; case relwithdeb: - spdlog::get("filesystem") - ->debug("Checking 'build/relwithdeb' directory."); - if (!std::filesystem::is_directory("build/relwithdeb")) { - spdlog::get("filesystem") - ->warn("'build/relwithdeb' is not a directory. Deleting."); - deleteDir("build/relwithdeb"); - } - if (!std::filesystem::exists("build/relwithdeb")) { - spdlog::get("filesystem") - ->info("Creating 'build/relwithdeb' directory."); - createDir("build/relwithdeb"); - }; + checkDir("build/relwithdeb"); break; case minsizerel: - spdlog::get("filesystem") - ->debug("Checking 'build/minsizerel' directory."); - if (!std::filesystem::is_directory("build/minsizerel")) { - spdlog::get("filesystem") - ->warn("'build/minsizerel' is not a directory. Deleting."); - deleteDir("build/minsizerel"); - } - if (!std::filesystem::exists("build/minsizerel")) { - spdlog::get("filesystem") - ->info("Creating 'build/minsizerel' directory."); - createDir("build/minsizerel"); - }; + checkDir("build/minsizerel"); break; }