With my snap (a C++ SDL2 app) I need to include a few files as assets to be loaded at runtime: some PNG images, fonts, .wav files. So far I was able to accomplish this using “layout” and setting make to copy required files to snap’s DESTDIR folder in make’s install target.
I wonder if this is the best approach and what are the alternatives. I tried adding a separate part using /local and dump as plugin; some sites mention “artifacts” for this - none of this worked for me.
Of course with SDL as a method of last resort I can convert all assets to binary arrays and include directly into application but I would like to avoid this.
Both ways are fine, the dump plugin is surely more elegant than having to maintain a separate Makefile though.
Would be interesting what issues you had with it and get these solved …
As I mentioned, I was able to copy and use app’s assets using “layout”. Here’s the example I used: https://github.com/Joker2770/SDL2snake. In this example, CMake copies res/lazy.ttf to /usr/local/bin and then yaml has this part:
I tried to accomplish the same with “parts” but so far failed.
In my case I have assets folder (as sub-folder of the source directory). Here’s my syntax in .yaml:
When application tries to load an image from there, it fails:
File NOT found: /firstname.lastname@example.org
File NOT found: /usr/local/bin/assets/beginner.png
Can you please advise how do I map “assets” with all its content to /usr/local/bin/assets for snap to use, using “parts”?
You map the path the same way you did for the
lazy.ttf but using
bind instead of
bind-file (because you want the whole directory):