Compile Shaders now as well
This commit is contained in:
parent
d464128d78
commit
26ed5a1398
@ -20,7 +20,8 @@ inline std::string fix_path(const std::string &path)
|
|||||||
inline std::string stupid_hash(const std::string &file)
|
inline std::string stupid_hash(const std::string &file)
|
||||||
{
|
{
|
||||||
std::ifstream iff(file);
|
std::ifstream iff(file);
|
||||||
if(!iff.is_open()) {
|
if (!iff.is_open())
|
||||||
|
{
|
||||||
return std::to_string(rand());
|
return std::to_string(rand());
|
||||||
}
|
}
|
||||||
unsigned long long check_sum = 0x0ULL;
|
unsigned long long check_sum = 0x0ULL;
|
||||||
@ -44,13 +45,16 @@ createHashes(const std::vector<std::string> &dirs,
|
|||||||
{
|
{
|
||||||
for (const auto &file : std::filesystem::directory_iterator(it))
|
for (const auto &file : std::filesystem::directory_iterator(it))
|
||||||
{
|
{
|
||||||
if (file.is_regular_file() && file.path().extension() == extension)
|
if (file.is_regular_file())
|
||||||
{
|
{
|
||||||
std::string path = fix_path(file.path().string());
|
std::string path = fix_path(file.path().string());
|
||||||
|
if (path.length() > extension.length() && path.ends_with(extension))
|
||||||
|
{
|
||||||
hashes[path] = stupid_hash(path);
|
hashes[path] = stupid_hash(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return hashes;
|
return hashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
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>
|
std::vector<std::filesystem::path>
|
||||||
get_files_in_dir(const std::vector<std::string> &dir_paths,
|
get_files_in_dir(const std::vector<std::string> &dir_paths,
|
||||||
const std::string &extension)
|
const std::string &extension)
|
||||||
@ -54,13 +59,19 @@ get_files_in_dir(const std::vector<std::string> &dir_paths,
|
|||||||
continue;
|
continue;
|
||||||
for (const auto &entry : std::filesystem::directory_iterator(dir_path))
|
for (const auto &entry : std::filesystem::directory_iterator(dir_path))
|
||||||
{
|
{
|
||||||
if (std::filesystem::is_regular_file(entry.path()) &&
|
if (std::filesystem::is_regular_file(entry.path()))
|
||||||
entry.path().extension() == extension)
|
{
|
||||||
|
std::string fn = entry.path().string();
|
||||||
|
if (fn.length() > extension.length())
|
||||||
|
{
|
||||||
|
if (fn.ends_with(extension))
|
||||||
{
|
{
|
||||||
files.push_back(fix_path(entry.path().string()));
|
files.push_back(fix_path(entry.path().string()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
@ -344,6 +355,9 @@ void CompileProject(NpiProject &prj, std::string dir_)
|
|||||||
AutoVecRepl(prj.source_dirs);
|
AutoVecRepl(prj.source_dirs);
|
||||||
AutoVecRepl(prj.include_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 =
|
std::vector<std::filesystem::path> cpp_files =
|
||||||
get_files_in_dir(prj.source_dirs, ".cpp");
|
get_files_in_dir(prj.source_dirs, ".cpp");
|
||||||
std::vector<std::filesystem::path> c_files =
|
std::vector<std::filesystem::path> c_files =
|
||||||
@ -445,6 +459,43 @@ void CompileProject(NpiProject &prj, std::string dir_)
|
|||||||
any_errors = true;
|
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_)
|
for (auto const &it : cpp_files_)
|
||||||
{
|
{
|
||||||
std::string command =
|
std::string command =
|
||||||
|
Loading…
Reference in New Issue
Block a user