77 lines
1.2 KiB
C++
77 lines
1.2 KiB
C++
#define NO_Werror
|
|
#include "build.hpp"
|
|
|
|
bool build = false;
|
|
bool clear = false;
|
|
bool run = false;
|
|
bool opt = false;
|
|
|
|
int main(int argc, char const *argv[])
|
|
{
|
|
if (rebuild_my_self(__FILE__, argc, argv))
|
|
return 1;
|
|
|
|
for (int i = 1; i < argc; ++i)
|
|
{
|
|
if (!std::strcmp(argv[i], "opt"))
|
|
{
|
|
opt = true;
|
|
}
|
|
if (!std::strcmp(argv[i], "build"))
|
|
build = true;
|
|
|
|
if (!std::strcmp(argv[i], "run"))
|
|
run = true;
|
|
|
|
if (!std::strcmp(argv[i], "clear"))
|
|
{
|
|
clear = true;
|
|
}
|
|
}
|
|
|
|
if (clear)
|
|
{
|
|
clear_all_build();
|
|
}
|
|
|
|
// clean recompile of code
|
|
if (clear && !build)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
std::filesystem::create_directory(OBJ_DIR);
|
|
|
|
if (opt)
|
|
{
|
|
opt_flags = "-O3";
|
|
build_as_one();
|
|
}
|
|
else
|
|
{
|
|
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)
|
|
{
|
|
run_main();
|
|
}
|
|
return 0;
|
|
}
|