Compile Shaders now as well

This commit is contained in:
2024-03-09 16:52:26 +01:00
parent d464128d78
commit 26ed5a1398
2 changed files with 61 additions and 6 deletions

View File

@ -42,6 +42,11 @@ std::pair<T, bool> js_catch(const nlohmann::json &js, const std::string &at)
return std::make_pair(js[at].get<T>(), exists);
}
void recursive_repl(std::string &i, char v1, char v2)
{
std::replace(i.begin(), i.end(), v1, v2);
}
std::vector<std::filesystem::path>
get_files_in_dir(const std::vector<std::string> &dir_paths,
const std::string &extension)
@ -54,10 +59,16 @@ get_files_in_dir(const std::vector<std::string> &dir_paths,
continue;
for (const auto &entry : std::filesystem::directory_iterator(dir_path))
{
if (std::filesystem::is_regular_file(entry.path()) &&
entry.path().extension() == extension)
if (std::filesystem::is_regular_file(entry.path()))
{
files.push_back(fix_path(entry.path().string()));
std::string fn = entry.path().string();
if (fn.length() > extension.length())
{
if (fn.ends_with(extension))
{
files.push_back(fix_path(entry.path().string()));
}
}
}
}
}
@ -344,6 +355,9 @@ void CompileProject(NpiProject &prj, std::string dir_)
AutoVecRepl(prj.source_dirs);
AutoVecRepl(prj.include_dirs);
// Inject build dir as include dir
prj.include_dirs.push_back(dir_ + "/build");
std::vector<std::filesystem::path> cpp_files =
get_files_in_dir(prj.source_dirs, ".cpp");
std::vector<std::filesystem::path> c_files =
@ -445,6 +459,43 @@ void CompileProject(NpiProject &prj, std::string dir_)
any_errors = true;
}
for (auto const &it : v_pica_files_)
{
std::string res_f = dir_ + "/build/" + fix_path(it.stem().stem().string()) + ".shbin ";
std::string command = dkp_env + "/tools/bin/picasso -o " +
res_f + fix_path(it.string());
std::cout << CCMAGENTA << "Generating: " << CCCYAN << fix_path(it.filename().string())
<< std::endl;
int reqres = system(command.c_str());
std::cout << (reqres == 0 ? CCGREEN : CCRED)
<< (reqres == 0 ? "[+] " : "[-] ") << fix_path(it.filename().string())
<< std::endl;
if (reqres != 0)
any_errors = true;
// Bin2o action
// Mod res_f
std::string erf = res_f;
recursive_repl(erf, '.', '_');
erf = erf.substr(0, erf.length() - 1);
std::string tmp = "t.s";
std::string obj = erf + ".o";
std::string hdr = erf + ".h";
// Convert bin2asm
std::string cmd = "bin2s -a 4 -H " + hdr + ' ' + res_f + " > " + tmp;
reqres = system(cmd.c_str());
if (reqres != 0)
any_errors = true;
cmd = prj.cxx_compiler + " -x assembler-with-cpp " + tmp + " -c -o " + obj;
reqres = system(cmd.c_str());
if (reqres != 0)
any_errors = true;
// remove asm file
remove(tmp.c_str());
}
for (auto const &it : cpp_files_)
{
std::string command =