light/modules/asset_baker/entrypoint.cpp
light7734 63cb6dfe92
Some checks are pending
continuous-integration/drone/push Build is running
wip: convert from include style to module import style :D
2025-11-04 18:50:59 +03:30

44 lines
956 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 auto out_path = std::format("{}.asset", in_path.c_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;
}