light/modules/asset_baker/entrypoint.cpp
light7734 6d5256e0ec
Some checks reported errors
continuous-integration/drone/push Build was killed
fix: asset baker not taking generic path on Windows
Technically this will cause failure on non utf-8 text, but freak it for now...
2026-01-04 18:34:12 +03:30

44 lines
1,011 B
C++

import assets.shader;
import logger;
import bakers;
import std;
auto main(int argc, char *argv[]) -> std::int32_t
try
{
if (argc != 2)
{
throw std::logic_error("Argc should be 2 -- exe dir (implicit) and target dir");
}
for (const auto &directory_iterator :
std::filesystem::recursive_directory_iterator(argv[1])) // NOLINT
{
if (directory_iterator.is_directory())
{
continue;
}
const auto &in_path = directory_iterator.path();
const std::string in_path_str = in_path.generic_string();
const auto out_path = std::format("{}.asset", in_path_str);
if (in_path.extension() == ".vert")
{
bake_shader(in_path, out_path, lt::assets::ShaderAsset::Type::vertex);
}
else if (in_path.extension() == ".frag")
{
bake_shader(in_path, out_path, lt::assets::ShaderAsset::Type::fragment);
}
}
return 0;
}
catch (const std::exception &exp)
{
lt::log::critical("Terminating due to uncaught exception:");
lt::log::critical("\texception.what: {}:", exp.what());
return 1;
}