How to embed compiled SPIR-V into program using build system?

I cannot figure out how to work around the build system to do this. All i need is to just access the compiled spir-v binary through an import.

Are you looking for @embedFile? It works with a path, or name of a module.

So you can for example use it in combination with std.Build.Module.addAnonymousImport from the build system.

1 Like

I am specifically looking for how to embed the result of an addObject, which is not able to be done with addAnonymousImport.

I am not sure if I understand what you are trying to do, I would expect the linker to link the objects into whatever build artifact you are creating.

I am trying to embed a compiled binary for one arch(spirv) into an executable for another(x86), so I can then use that embedded binary as a shader for vulkan.

Is it a full binary or just an object file?

If it is a full binary, then why can’t you use spirv_artifact_compile_step.getEmittedBin() wrap the resulting lazy_path in a module and @embedFile that?

This also reminds me of this topic Generating fat binary on macOS

Are any of these in the vicinity of what you are looking for?
So far I have only embedded assets so might also be that I lack some experience with multi-target builds, in that case somebody else may have an answer.

since when were binaries allowed for module source files??

I don’t know, I think since @embedFile exists, seems like it was added in Release 0.11.0 embedFile Supports Module Mapped Names.