This commit is contained in:
parent
df9436c51d
commit
de9865b583
8 changed files with 163 additions and 1 deletions
|
|
@ -572,6 +572,36 @@ BuildResult Crafter::Build(Configuration& config, std::unordered_map<fs::path, s
|
|||
return {buildError, false, {}};
|
||||
}
|
||||
|
||||
// Ship .spv files from transitive deps' bin dirs alongside the executable
|
||||
// so consumers find shaders next to the binary at runtime. Only an exe is
|
||||
// a deployment unit; intermediate libs don't need to forward shaders since
|
||||
// the exe walks all transitive deps. Runs outside the repack gate because
|
||||
// the relink mtime check above only watches .so/.dll/.a, so a shader-only
|
||||
// change in a dep wouldn't trigger repack but still needs the new .spv
|
||||
// copied across.
|
||||
if (config.type == ConfigurationType::Executable) {
|
||||
try {
|
||||
std::unordered_set<Configuration*> shaderSeen;
|
||||
std::function<void(Configuration*)> copyDepShaders = [&](Configuration* dep) {
|
||||
if (!shaderSeen.insert(dep).second) return;
|
||||
fs::path depDir = dep->BinDir();
|
||||
for (const Shader& shader : dep->shaders) {
|
||||
fs::path src = depDir / shader.path.filename().replace_extension("spv");
|
||||
if (!fs::exists(src)) continue;
|
||||
fs::path dest = outputDir / src.filename();
|
||||
if (!fs::exists(dest) || fs::last_write_time(src) > fs::last_write_time(dest)) {
|
||||
fs::copy_file(src, dest, fs::copy_options::overwrite_existing);
|
||||
}
|
||||
}
|
||||
for (Configuration* sub : dep->dependencies) copyDepShaders(sub);
|
||||
};
|
||||
for (Configuration* dep : config.dependencies) copyDepShaders(dep);
|
||||
} catch (const fs::filesystem_error& e) {
|
||||
for(std::thread& thread : threads) thread.join();
|
||||
return {e.what(), false, {}};
|
||||
}
|
||||
}
|
||||
|
||||
if(repack.load()) {
|
||||
buildResult.repack = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue