How to get build files into prime directory?

When trying to snap my project with snapcraft 3.9.7 on Ubuntu 19.10, I get an error with the command:

caleb@whistling-duck:~/projects/gladupe$ snapcraft --debug
Launching a VM.
snap "snapd" has no updates available                                           
Skipping pull gladupe (already ran)
Skipping build gladupe (already ran)
Skipping stage gladupe (already ran)
Skipping prime gladupe (already ran)
Failed to generate snap metadata: Specified command 'bin/gladupe' was not found.
Verify the command is correct and for a more deterministic outcome, specify the relative path to the command from the prime directory.
snapcraft-gladupe # ls prime
etc  include  lib  meta  usr
 snapcraft-gladupe # ls -l parts/gladupe/build/bin/
total 92
-rwxr-xr-x 1 root root 93288 Jan 18 16:24 gladupe
snapcraft-gladupe # 

How do I get parts/gladupe/build/bin into prime? Or is that not what I want? If not, how do I get the command to find my executable?
I tried to set the command to be ../parts/gladupe/build/bin/gladupe, but it wasn’t too happy about that either.
Here’s the last half of my snap/snapcraft.yaml file:

parts:
    gladupe:
        plugin: cmake
        configflags:
            - -DSNAPCRAFT=True
            - -DCOMPILE_INK=True
            - -DCOMPILE_LIB2D=True
            - -DUIINK_BUILD_RUNNER=False
            - -DUIINK_BUILD_TESTS=False
            - -DUIINK_DX11=False
            - -DUIINK_HARFBUZZ=True
            - -DUIINK_USE_LUA=False
        source: .
        build-packages:
            - g++
            - cmake
            - make
            - libsdl2-dev
            - libsdl2-image-dev
apps:
    gladupe:
        command: bin/gladupe

When I run the example project for the cmake plugin, it spits out a bin/executable into the prime directory and it works fine. And there aren’t any parts I don’t have in my snapcraft.yaml

Two more questions.
My program has two dependencies that aren’t on apt and must be built from source. Since both are use cmake, it works just to include the source files and add add_subdirectory() and include_directories() to my CMakeLists.txt, but is there a better way?

My program also uses .png images, a variety of files for the gui, and binary files for maps and settings. How do I get these in the installable result?

Thanks.

Hi,

Re: your first question: In general if a file is in the part’s install/ directory, it ends up in the final snap in the same location. So check for parts/gladupe/install/bin/. If that does not exist then you need to take a look at the plugin type (cmake in this case), since each plugin has different native approaches for installing files, and add appropriate install rules.

Once it is in the install/ dir, you can modify where it ends up in the snap (including filename and location) with the organize: keyword in the relevant part, which takes a DICT, where the KEY designates the starting file and the VALUE is the ending file & path.

1 Like

Thanks a lot.
The files weren’t in the install dir, so I added install(TARGETS gladupe DESTINATION bin) to my CMakeLists.txt, and that fixed it.

Hi, glad to see you got your binary into the prime directory.

However, I need to ask if you can you start a new topic with this problem (or maybe as the author you can “split” the post out), I do not think most people that know about GL will crawl into a topic about priming.

1 Like