/* Crafter® Build Copyright (C) 2026 Catcrafts® Catcrafts.net LGPL-3.0-only. Verifies that when an executable consumes a library that registers a shader, the resulting .spv ships in the executable's bin dir alongside the binary — not just in the lib's own bin dir, where the runtime exe wouldn't find it. */ import std; import Crafter.Build; #include "../_shared/TestUtil.h" namespace fs = std::filesystem; using namespace TestUtil; using namespace Crafter; int main() { try { fs::path src = fs::current_path() / "tests" / "ShaderDep" / "inner"; Configuration cfg = LoadFixture("ShaderDep", src); auto br = BuildOnce(cfg); if (!br.result.empty()) { std::println(std::cerr, "build failed:\n{}", br.result); return 1; } fs::path libSpv = cfg.dependencies[0]->BinDir() / "triangle.spv"; fs::path appSpv = cfg.BinDir() / "triangle.spv"; if (!fs::exists(libSpv)) { std::println(std::cerr, "lib .spv missing at {}", libSpv.string()); return 1; } if (!fs::exists(appSpv)) { std::println(std::cerr, "exe .spv missing at {}", appSpv.string()); return 1; } std::ifstream f(appSpv, std::ios::binary); unsigned char magic[4] = {}; f.read(reinterpret_cast(magic), 4); if (magic[0] != 0x03 || magic[1] != 0x02 || magic[2] != 0x23 || magic[3] != 0x07) { std::println(std::cerr, "SPIR-V magic mismatch in exe-side copy: got {:#04x} {:#04x} {:#04x} {:#04x}", magic[0], magic[1], magic[2], magic[3]); return 1; } return 0; } catch (const std::exception& e) { std::println(std::cerr, "test exception: {}", e.what()); return 1; } }