115 lines
3.8 KiB
C++
115 lines
3.8 KiB
C++
#include <taskflow/core/task.hpp>
|
|
|
|
#include "app.h"
|
|
#include "types.h"
|
|
|
|
void Application::buildProject() {
|
|
auto checkBuildDirsTask =
|
|
m_Taskflow.emplace([this]() { this->checkBuildDirs(); })
|
|
.name("checkBuildDirs");
|
|
if (m_BuildType == BuildType::none) {
|
|
tf::Task previousBuildTask;
|
|
for (BuildType type : buildTypes) {
|
|
std::string dir = BuildTypeToDir(type);
|
|
std::string name = BuildTypeToString(type);
|
|
|
|
auto configureTask =
|
|
m_Taskflow
|
|
.emplace(
|
|
[this, dir, name]() { this->configureDir(dir, name); })
|
|
.name(std::format("configureDir({})", dir));
|
|
|
|
auto buildTask =
|
|
m_Taskflow.emplace([this, dir]() { this->buildDir(dir); })
|
|
.name(std::format("buildDir({})", dir));
|
|
configureTask.succeed(checkBuildDirsTask);
|
|
buildTask.succeed(configureTask);
|
|
if (!previousBuildTask.empty()) {
|
|
buildTask.succeed(previousBuildTask);
|
|
}
|
|
previousBuildTask = buildTask;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
auto configureDirTask =
|
|
m_Taskflow
|
|
.emplace([this]() {
|
|
this->configureDir(BuildTypeToDir(m_BuildType),
|
|
BuildTypeToString(m_BuildType));
|
|
})
|
|
.name(std::format("configureDir({})", BuildTypeToDir(m_BuildType)));
|
|
auto buildDirTask =
|
|
m_Taskflow
|
|
.emplace([this]() { this->buildDir(BuildTypeToDir(m_BuildType)); })
|
|
.name(std::format("buildDir({})", BuildTypeToDir(m_BuildType)));
|
|
|
|
configureDirTask.precede(buildDirTask);
|
|
checkBuildDirsTask.precede(configureDirTask);
|
|
}
|
|
|
|
void Application::configureProject() {
|
|
auto checkBuildDirsTask =
|
|
m_Taskflow.emplace([this]() { this->checkBuildDirs(); })
|
|
.name("checkBuildDirs");
|
|
if (m_BuildType == BuildType::none) {
|
|
for (BuildType type : buildTypes) {
|
|
std::string dir = BuildTypeToDir(type);
|
|
std::string name = BuildTypeToString(type);
|
|
auto configureDirTask =
|
|
m_Taskflow
|
|
.emplace(
|
|
[this, dir, name]() { this->configureDir(dir, name); })
|
|
.name(std::format("configureDir({})", dir));
|
|
checkBuildDirsTask.precede(configureDirTask);
|
|
}
|
|
return;
|
|
}
|
|
|
|
auto configureDirDebugTask =
|
|
m_Taskflow
|
|
.emplace([this]() {
|
|
this->configureDir(BuildTypeToDir(m_BuildType),
|
|
BuildTypeToString(m_BuildType));
|
|
})
|
|
.name(std::format("configureDir({})", BuildTypeToDir(m_BuildType)));
|
|
checkBuildDirsTask.precede(configureDirDebugTask);
|
|
}
|
|
|
|
void Application::cleanProject() {
|
|
auto checkBuildDirsTask =
|
|
m_Taskflow.emplace([this]() { this->checkBuildDirs(); })
|
|
.name("checkBuildDirs");
|
|
|
|
if (m_BuildType == BuildType::none) {
|
|
for (BuildType type : buildTypes) {
|
|
std::string dir = BuildTypeToDir(type);
|
|
auto cleanDirTask =
|
|
m_Taskflow.emplace([this, dir]() { this->cleanDir(dir); })
|
|
.name(std::format("cleanDir({})", dir));
|
|
checkBuildDirsTask.precede(cleanDirTask);
|
|
}
|
|
return;
|
|
}
|
|
|
|
auto cleanDirDebugTask =
|
|
m_Taskflow
|
|
.emplace([this]() { this->cleanDir(BuildTypeToDir(m_BuildType)); })
|
|
.name(std::format("cleanDir({})", BuildTypeToDir(m_BuildType)));
|
|
checkBuildDirsTask.precede(cleanDirDebugTask);
|
|
}
|
|
|
|
void Application::deleteProject() {
|
|
if (m_BuildType == BuildType::none) {
|
|
deleteDir("build");
|
|
return;
|
|
}
|
|
deleteDir(BuildTypeToDir(m_BuildType));
|
|
}
|
|
|
|
void Application::rebuildProject() {
|
|
deleteProject();
|
|
buildProject();
|
|
}
|