Issue while building libwebkit2gtk-5 from source

I am trying to build the libwebkit2gtk-5 from source. I guess I have figured out the build-packages and stage-packages correctly. But, when I try to build it, it can’t fetch the icu libraries from the icu that I build from source. This is my snapcraft.yaml

name: newsflash # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
adopt-info: newsflash
architectures:
  - build-on: amd64
license: GPL-3.0
compression: lzo
source-code: https://gitlab.com/news-flash/news_flash_gtk
issues: https://github.com/soumyaDghosh/newsflash-snap/issues
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

environment:
  # WORKAROUND: Add python modules in Snap to search path
  PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
parts:
  libicu:
    source: https://github.com/unicode-org/icu.git
    source-tag: release-73-1
    source-subdir: icu4c/source
    plugin: autotools
    autotools-configure-parameters:
      # WORKAROUND: Install to /usr instead of /usr/local because it's not in search paths
      - --prefix=/usr
      - --disable-renaming
    build-packages:
      - doxygen
  gi-docgen:
    source: https://gitlab.gnome.org/GNOME/gi-docgen.git
    source-tag: '2023.1'
    plugin: python
    build-environment:
      # WORKAROUND: The python plugin is broken with gnome extension
      - PATH: ${CRAFT_PART_INSTALL}/bin:${PATH}
      - PYTHONPATH: ""
    stage:
      # WORKAROUND: Skip venv from python plugin
      - -bin/activate
      - -bin/activate.csh
      - -bin/activate.fish
      - -bin/Activate.ps1
      - -bin/python
      - -bin/python3
      - -bin/python3.10
      - -bin/pip
      - -bin/pip3
      - -bin/pip3.10
      - -pyvenv.cfg
  webkitgtk:
    after: [gi-docgen, libicu]
    source: https://salsa.debian.org/webkit-team/webkit.git
    source-tag: upstream/2.40.1
    plugin: cmake
    build-environment:
      - CPPFLAGS: "$CPPFLAGS -l/$CRAFT_PRIME/usr/include -l$CRAFT_PRIME/usr/include"
      - LD_LIBRARY_PATH: "$CRAFT_STAGE/usr/lib:$LD_LIBRARY_PATH"
      - PYTHONPATH: "$PYTHONPATH:$CRAFT_STAGE/lib/python3.10/site-packages"
    cmake-parameters:
      - -DPORT=GTK
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_INSTALL_LIBDIR=lib
      - -DCMAKE_INSTALL_LIBEXECDIR=lib
      - -DCMAKE_SKIP_RPATH=ON
      - -DUSE_AVIF=ON
      - -DUSE_GTK4=ON
      - -DENABLE_DOCUMENTATION=ON
      - -DENABLE_MINIBROWSER=ON
    build-packages:
      - ruby-all-dev
      - libfreetype-dev
      - libgcrypt20-dev
      - unifdef
      - libmanette-0.2-dev
      - libpng-dev
      - libxslt1-dev
      - libsqlite3-dev
      - libcurl4-gnutls-dev
      - libenchant-2-dev
      - libwpe-1.0-dev
      - libwpebackend-fdo-1.0-dev
      - libxcomposite-dev
      - libxdamage-dev
      - libxrender-dev
      - libxt-dev
      - libhyphen-dev
      - libwoff-dev
      - libavif-dev
      - libsystemd-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-bad1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer-plugins-good1.0-dev
      - gperf
    stage-packages:
      - bubblewrap
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - libatomic1
      - libenchant-2-2
      - libglx0
      - libgstreamer-gl1.0-0
      - libgstreamer-plugins-base1.0-0
      - libgstreamer1.0-0
      - libhyphen0
      - libmanette-0.2-0
      - libopengl0
      - libsystemd0
      - libwpe-1.0-1
      - libwpebackend-fdo-1.0-1
      - libwoff1
  rustup:
    after: [webkitgtk]
    plugin: nil
    build-packages: [wget]
    build-environment:
      - RUSTUP_HOME: $CRAFT_PART_INSTALL/usr/share/rust
      - CARGO_HOME: $CRAFT_PART_INSTALL/usr/share/rust
      - CARGO_BUILD_JOBS: $CRAFT_PARALLEL_BUILD_COUNT
    override-pull: |
      wget https://sh.rustup.rs -O $CRAFT_PART_SRC/rustup-init.sh
      chmod +x $CRAFT_PART_SRC/rustup-init.sh
    override-build: |
      $CRAFT_PART_SRC/rustup-init.sh -y --no-modify-path
      mkdir -p $CRAFT_PART_INSTALL/usr/bin
      for i in `ls $RUSTUP_HOME/bin/`; do
        ln -s ../share/rust/bin/$i $CRAFT_PART_INSTALL/usr/bin/$i
      done
    override-prime: |
      echo 'Skip Prime'
  newsflash:
    after: [rustup, webkitgtk]
    # See 'snapcraft plugins'
    plugin: meson
    source: https://gitlab.com/news-flash/news_flash_gtk.git
    source-tag: v.2.2.4
    build-environment:
      - RUSTUP_HOME: $CRAFT_STAGE/usr/share/rust
      - CARGO_HOME: $CRAFT_STAGE/usr/share/rust
      - CARGO_BUILD_JOBS: $CRAFT_PARALLEL_BUILD_COUNT
    meson-parameters:
      - --prefix=/snap/newsflash/current/usr
    build-packages:
      - libssl-dev
    organize:
      snap/newsflash/current/usr: usr
    parse-info: [usr/share/metainfo/com.gitlab.newsflash.appdata.xml]
  cleanup:
    after:  # Make this part run last; list all your other parts here
      - newsflash
      - rustup
      - webkitgtk
      - gi-docgen
      - libicu
    plugin: nil
    build-snaps:  # List all content-snaps and base snaps you're using here
      - gnome-42-2204
      - gtk-common-themes
      - core22
    override-prime: |
      set -eux
      for snap in "gnome-42-2204" "gtk-common-themes" "core22"; do
      cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
      done
apps:
  newsflash:
    command: usr/bin/com.gitlab.newsflash
    extensions: [gnome]
    common-id: com.gitlab.newsflash
    desktop: usr/share/applications/com.gitlab.newsflash.desktop

@ogra can you help me with this, please? I guess this code can be merged into the gnome-sdk also, so, anyone will be able to make snaps using webkit2gtk

your icu build will be in your stage dir, not installed on the host … you will need to teach your webkit part to look in CRAFT_STAGE for the headers …

I have added it, yet no luck.

name: newsflash # you probably want to 'snapcraft register <name>'
base: core22 # the base snap is the execution environment for this snap
adopt-info: newsflash
architectures:
  - build-on: amd64
license: GPL-3.0
compression: lzo
source-code: https://gitlab.com/news-flash/news_flash_gtk
issues: https://github.com/soumyaDghosh/newsflash-snap/issues
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

environment:
  # WORKAROUND: Add python modules in Snap to search path
  PYTHONPATH: ${SNAP}/lib/python3.10/site-packages:${SNAP}/usr/lib/python3/dist-packages
parts:
  libicu:
    source: https://github.com/unicode-org/icu.git
    source-tag: release-73-1
    source-subdir: icu4c/source
    plugin: autotools
    autotools-configure-parameters:
      # WORKAROUND: Install to /usr instead of /usr/local because it's not in search paths
      - --prefix=/usr
      - --disable-renaming
    build-packages:
      - doxygen
  gi-docgen:
    source: https://gitlab.gnome.org/GNOME/gi-docgen.git
    source-tag: '2023.1'
    plugin: python
    build-environment:
      # WORKAROUND: The python plugin is broken with gnome extension
      - PATH: ${CRAFT_PART_INSTALL}/bin:${PATH}
      - PYTHONPATH: ""
    stage:
      # WORKAROUND: Skip venv from python plugin
      - -bin/activate
      - -bin/activate.csh
      - -bin/activate.fish
      - -bin/Activate.ps1
      - -bin/python
      - -bin/python3
      - -bin/python3.10
      - -bin/pip
      - -bin/pip3
      - -bin/pip3.10
      - -pyvenv.cfg
  webkitgtk:
    after: [gi-docgen, libicu]
    source: https://salsa.debian.org/webkit-team/webkit.git
    source-tag: upstream/2.40.1
    plugin: cmake
    build-environment:
      - CPPFLAGS: "-I/$CRAFT_PRIME/usr/include -L/$CRAFT_PRIME/usr/lib/icu -licu"
      - LDFLAGS: "-L$CRAFT_STAGE/usr/lib/icu"
      - PYTHONPATH: "$PYTHONPATH:$CRAFT_STAGE/lib/python3.10/site-packages"
    cmake-parameters:
      - -DPORT=GTK
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_INSTALL_LIBDIR=lib
      - -DCMAKE_INSTALL_LIBEXECDIR=lib
      - -DCMAKE_SKIP_RPATH=ON
      - -DUSE_AVIF=ON
      - -DUSE_GTK4=ON
      - -DENABLE_DOCUMENTATION=ON
      - -DENABLE_MINIBROWSER=ON
    build-packages:
      - ruby-all-dev
      - libfreetype-dev
      - libgcrypt20-dev
      - unifdef
      - libmanette-0.2-dev
      - libpng-dev
      - libxslt1-dev
      - libsqlite3-dev
      - libcurl4-gnutls-dev
      - libenchant-2-dev
      - libwpe-1.0-dev
      - libwpebackend-fdo-1.0-dev
      - libxcomposite-dev
      - libxdamage-dev
      - libxrender-dev
      - libxt-dev
      - libhyphen-dev
      - libwoff-dev
      - libavif-dev
      - libsystemd-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-bad1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer-plugins-good1.0-dev
      - gperf
    stage-packages:
      - bubblewrap
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - libatomic1
      - libenchant-2-2
      - libglx0
      - libgstreamer-gl1.0-0
      - libgstreamer-plugins-base1.0-0
      - libgstreamer1.0-0
      - libhyphen0
      - libmanette-0.2-0
      - libopengl0
      - libsystemd0
      - libwpe-1.0-1
      - libwpebackend-fdo-1.0-1
      - libwoff1
  rustup:
    after: [webkitgtk]
    plugin: nil
    build-packages: [wget]
    build-environment:
      - RUSTUP_HOME: $CRAFT_PART_INSTALL/usr/share/rust
      - CARGO_HOME: $CRAFT_PART_INSTALL/usr/share/rust
      - CARGO_BUILD_JOBS: $CRAFT_PARALLEL_BUILD_COUNT
    override-pull: |
      wget https://sh.rustup.rs -O $CRAFT_PART_SRC/rustup-init.sh
      chmod +x $CRAFT_PART_SRC/rustup-init.sh
    override-build: |
      $CRAFT_PART_SRC/rustup-init.sh -y --no-modify-path
      mkdir -p $CRAFT_PART_INSTALL/usr/bin
      for i in `ls $RUSTUP_HOME/bin/`; do
        ln -s ../share/rust/bin/$i $CRAFT_PART_INSTALL/usr/bin/$i
      done
    override-prime: |
      echo 'Skip Prime'
  newsflash:
    after: [rustup, webkitgtk]
    # See 'snapcraft plugins'
    plugin: meson
    source: https://gitlab.com/news-flash/news_flash_gtk.git
    source-tag: v.2.2.4
    build-environment:
      - RUSTUP_HOME: $CRAFT_STAGE/usr/share/rust
      - CARGO_HOME: $CRAFT_STAGE/usr/share/rust
      - CARGO_BUILD_JOBS: $CRAFT_PARALLEL_BUILD_COUNT
    meson-parameters:
      - --prefix=/snap/newsflash/current/usr
    build-packages:
      - libssl-dev
    organize:
      snap/newsflash/current/usr: usr
    parse-info: [usr/share/metainfo/com.gitlab.newsflash.appdata.xml]
  cleanup:
    after:  # Make this part run last; list all your other parts here
      - newsflash
      - rustup
      - webkitgtk
      - gi-docgen
      - libicu
    plugin: nil
    build-snaps:  # List all content-snaps and base snaps you're using here
      - gnome-42-2204
      - gtk-common-themes
      - core22
    override-prime: |
      set -eux
      for snap in "gnome-42-2204" "gtk-common-themes" "core22"; do
      cd "/snap/$snap/current" && find . -type f,l -exec rm -f "$SNAPCRAFT_PRIME/{}" \;
      done
apps:
  newsflash:
    command: usr/bin/com.gitlab.newsflash
    extensions: [gnome]
    common-id: com.gitlab.newsflash
    desktop: usr/share/applications/com.gitlab.newsflash.desktop