Best way to precompile dependencies

The project I created depends on a newer version of libvips that is not included in Ubuntu 18 arm64 and armv7. There are no precompiled binaries that can be added at this time. Currently the dependency is being compiled at build. This is certainly not the best way to do this.

What would be the best way to precompile these dependencies and include it in the snap during the build process? Create another snap for my snap?

This is how it’s being built in the snap today.

if [ "$ARCH" != "x86_64" ]; then
    git clone --depth 1 --branch v8.10.5
    cd libvips && ./
    make -j$(nproc) && make install
    cd ../ && rm -rf libvips

I disagree, I think it’s a fine way to do it. That said, if that dependency doesn’t change much, and you feel like the build time is too long, go ahead and make a snap of it, and then you can specify it as a stage snap in your current snap instead of building it, something like:

    after: [libvips]

    plugin: nil
    stage-snaps: [my-libvips-snap]
    stage: [-snap/, -meta/]  # Remove the snap metadata

if that dependency doesn’t change much, and you feel like the build time is too long, go ahead and make a snap of it

It does not change much and currently the build time is over an hour.

Thank you for the example.

I am new to snapcraft and I am not entirely sure how I should build the dependency snap. This is what I was attempting. Do you mind taking a look and pointing me in the right direction?

name: libvips
version: v8.10.5
summary: libvips
description: >
base: core18
confinement: strict

    plugin: dump
      - git
      - sqlite3
      - libsqlite3-dev
      - build-essential
      - automake
      - libtool
      - swig
      - libxml2-dev
      - libfftw3-dev
      - libmagickwand-dev
      - libopenexr-dev
      - liborc-0.4-0
      - gobject-introspection
      - libgsf-1-dev
      - libglib2.0-dev
      - liborc-0.4-dev
      - gtk-doc-tools
      - libopenslide-dev
      - libmatio-dev
      - libgif-dev
      - python-gi-dev
      - libgirepository1.0-dev
    source: .
      - VIPSHOME: "/usr/local"
      - PATH: "$VIPSHOME/bin:$SNAPCRAFT_PART_BUILD/node_modules/.bin:$SNAPCRAFT_PART_BUILD/../npm/bin:$PATH"
      - PYTHONPATH: "$VIPSHOME/lib/python3.6/site-packages"
    override-build: |
      git clone --depth 1 --branch v8.10.5
      cd libvips && ./
      make -j$(nproc) && make install
      - libaec0
      - libcairo2
      - libcroco3
      - libdatrie1
      - libexif12
      - libfftw3-double3
      - libfontconfig1
      - libfreetype6
      - libgdk-pixbuf2.0-0
      - libgif7
      - libgomp1
      - libgraphite2-3
      - libgsf-1-114
      - libharfbuzz0b
      - libhdf5-100
      - libicu60
      - libilmbase12
      - libjbig0
      - libjpeg-turbo8
      - liblcms2-2
      - liblqr-1-0
      - libltdl7
      - libmagickcore-6.q16-3
      - libmatio4
      - libopenexr22
      - libopenjp2-7
      - libopenslide0
      - liborc-0.4-0
      - libpango-1.0-0
      - libpangocairo-1.0-0
      - libpangoft2-1.0-0
      - libpixman-1-0
      - libpng16-16
      - librsvg2-2
      - libsz2
      - libthai0
      - libtiff5
      - libx11-6
      - libxau6
      - libxcb-render0
      - libxcb-shm0
      - libxcb1
      - libxdmcp6
      - libxext6
      - libxml2
      - libxrender1

I would look into the autotools plugin. Something like this:

    plugin: autotools
    source-branch: v8.10.5
    source-depth: 1

How would I insure that the main snap is able to find libvips?
I tried with what I posted above but it does not seem to be able to find the new version.

For context. it is a dependency in node for sharp.

Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
Directory: /data/parts/project/build/node_modules/sharp
ERR! sharp Use with glibc 2.27 requires manual installation of libvips >= 8.10.0