This commit is contained in:
Nikola Petrov
2024-07-19 18:18:05 +02:00
parent 33b3c10e4d
commit 748ab00289
2 changed files with 87 additions and 40 deletions

View File

@@ -15,7 +15,6 @@ int main(int argc, char const *argv[])
{
if (!std::strcmp(argv[i], "opt"))
{
opt_flags = "-O3";
opt = true;
}
if (!std::strcmp(argv[i], "build"))
@@ -24,13 +23,18 @@ int main(int argc, char const *argv[])
if (!std::strcmp(argv[i], "run"))
run = true;
if (!std::strcmp(argv[i], "cla"))
if (!std::strcmp(argv[i], "clear"))
{
clear_all_build();
clear = true;
}
}
if (clear)
{
clear_all_build();
}
// clean recompile of code
if (clear && !build)
{
return 0;
@@ -38,32 +42,35 @@ int main(int argc, char const *argv[])
std::filesystem::create_directory(OBJ_DIR);
if (!opt)
if (opt)
{
int res = compile_src_dir();
switch (res)
{
case 1:
compile_obj_dir();
break;
case -1:
return 0;
}
if (!std::filesystem::exists(BUILD_FILE))
compile_obj_dir();
opt_flags = "-O3";
build_as_one();
}
else
{
build_as_one();
int res = compile_src_dir();
switch (res)
{
// correcty recompile
case 1:
compile_obj_dir();
break;
// failed recompile
case -1:
return 0;
// no need for recompile
case 0:
break;
}
// files dont need to recompile but exe is mising
if (!std::filesystem::exists(BUILD_FILE))
compile_obj_dir();
}
if (run)
{
command = {"./" + BUILD_FILE.string(), "Pot", "20", "1080"};
nob_cmd_run_sync(command);
run_main();
}
return 0;
}