Built library part found but not being used by later primary part build

I’m struggling with trying to build a snap that needs to use a later version of a library than available in either core18 or core20, and wonder if someone could give me a little advice on where I’m going wrong?

An upcoming version of Snippet Pixie needs to use a feature introduced in version 5.4.0 of Granite, but core20 (and Ubuntu 20.04) currently has version 5.3.0.

Building the app on elementary OS 5.1 or 6.0 works fine as they both include granite 5.4.0 or later.

Right from the start I’ve been using a custom build of Granite in my snap anyway, and it seems to have been working fine, and for a good while I thought I was building against version 5.4.0 as built as a custom part, but now I have doubts. Now that I’m using a feature introduced in Granite 5.4.0 I’m getting compile time errors because that feature isn’t available.

Full snapcraft.yaml is at: https://github.com/bytepixie/snippetpixie/blob/elementary-6.0/snapcraft.yaml

This is a stripped down version (bunch of runtime dependencies and info entries removed for brevity)…

name: snippetpixie
base: core18
version: 1.5.0.dev
summary: Your little expandable text snippet helper


    after: [granite, desktop-gnome-platform]
    plugin: meson
      - --prefix=/usr
    source: .
    override-build: |
      snapcraftctl build
      sed -i 's|Icon=com.github.bytepixie.snippetpixie|Icon=\${SNAP}/meta/gui/icon.svg|' ${SNAPCRAFT_PART_INSTALL}/usr/share/applications/com.github.bytepixie.snippetpixie.desktop
      - valac
      - desktop-file-utils
      - appstream
      - libatspi2.0-dev
      - libgee-0.8-dev
      - libglib2.0-dev
      - libgranite-dev
      - libgtk-3-dev
      - libibus-1.0-dev
      - libjson-glib-dev
      - libsqlite3-dev
      - libxtst-dev
      - libx11-dev
    plugin: meson
      - --prefix=/usr
    source: https://github.com/elementary/granite/archive/5.4.0.tar.gz
    source-type: tar
    override-build: |
      snapcraftctl build

I’m running the build with lxd, and it fails as pictured.


That failure is because Granite.Settings is not known, that was introduced in v5.4.0.

But I’m building Granite 5.4.0 as a build dependency, and the pkg-config near the top of the screenshot says it found that version as a runtime dependency.

Earlier in the build process when granite is built, it installs a bunch of files such as the following…

Installing lib/libgranite.so.5.4.0 to /root/parts/granite/install/usr/lib/x86_64-linux-gnu
Installing lib/granite.h to /root/parts/granite/install/usr/include/granite
Installing lib/granite.vapi to /root/parts/granite/install/usr/share/vala/vapi
Installing lib/Granite-1.0.gir to /root/parts/granite/install/usr/share/gir-1.0
Installing lib/Granite-1.0.typelib to /root/parts/granite/install/usr/lib/x86_64-linux-gnu/girepository-1.0
Installing data/granite.appdata.xml to /root/parts/granite/install/usr/share/metainfo
Installing demo/granite-demo to /root/parts/granite/install/usr/bin
Installing /root/parts/granite/build/lib/granite.deps to /root/parts/granite/install/usr/share/vala/vapi
Installing /root/parts/granite/build/lib/Widgets/widgets-utils.h to /root/parts/granite/install/usr/include/granite
Installing /root/parts/granite/build/snapbuild/meson-private/granite.pc to /root/parts/granite/install/usr/lib/x86_64-linux-gnu/pkgconfig

I’ve tried all kinds of combinations of adding CFLAGS and LDFLAG to a build-environment that add things like -isystem$SNAPCRAFT_STAGE/usr/include/granite to CFLAGS, but they seem to be ignored. That’s even though I see their paths added to the CFLAGS or LDFLAGS pkg-config output.

I must just not be grokking what I need from https://snapcraft.io/docs/parts-environment-variables#heading--build-flags

I’ve run with --debug a bunch of times and delved into the files installed by the Granite part and all looks good, header file has expected code etc.

I expect I am missing something really simple, is anyone able to teach me how to ensure the meson and vala based compile picks up the version of granite the snapcraft.yaml builds?

I worked it out, needed to tell the vala compiler that there were some extra vapi files available.

Just added the following to the snippetpixie part…

      - VALAFLAGS: " --vapidir $SNAPCRAFT_STAGE/usr/share/vala/vapi"