/* Crafter® Build Copyright (C) 2026 Catcrafts® Catcrafts.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3.0 as published by the Free Software Foundation; This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ module Crafter.Build:Asset_impl; import :Asset; import std; #ifdef CRAFTER_BUILD_HAS_ASSET import Crafter.Asset; import Crafter.Math; #endif namespace fs = std::filesystem; namespace Crafter { std::string CompressAsset(const fs::path& input, const fs::path& output) { std::string ext = input.extension().string(); #ifdef CRAFTER_BUILD_HAS_ASSET try { if (ext == ".png") { auto tex = TextureAsset>::LoadPNG(input); tex.SaveCompressed(output); } else if (ext == ".obj") { auto mesh = MeshAsset::LoadOBJ(input); mesh.SaveCompressed(output); } else { return std::format("{}: unsupported asset extension '{}'", input.string(), ext); } } catch (const std::exception& e) { return std::format("{}: {}", input.string(), e.what()); } return {}; #else return std::format( "{}: crafter-build was bootstrapped without Crafter.Asset linkage; " "rebuild via `./bin/crafter-build` so the self-host pass picks up the " "Crafter.Asset dep declared in project.cpp", input.string()); #endif } }