wmww / gtk4-layer-shell

A library to create panels and other desktop components for Wayland using the Layer Shell protocol and GTK4
MIT License
128 stars 4 forks source link

Build gtk-layer-shell as dependency #31

Closed LukashonakV closed 6 months ago

LukashonakV commented 6 months ago

Hi there,

When gtk-layer-shell is not installed in the system is it possible to have it compiled as as subproject ?

I'm trying to do next:

  1. Use such wrapper:
    
    [wrap-file]
    directory = gtk-layer-shell-1.0.2
    source_filename = gtk4-layer-shell-1.0.2.tar.gz
    source_hash = a3a827845612fa15de30734eb29c01db329c32f8e279d8bc5251facc69220b86
    source_url = https://github.com/wmww/gtk4-layer-shell/archive/v1.0.2/gtk4-layer-shell-1.0.2.tar.gz

[provide] gtk_layer_shell = gtk_layer_shell_dep

2. Add gtk-layer-shell as a dependency in main project
```meson.build
gtk_layer_shell = dependency('gtk-layer-shell-0',
                             version : ['>=1.0.2'],
                             required: get_option('gtk-layer-shell'),
                             fallback : ['gtk-layer-shell', 'gtk_layer_shell_dep'],
                             default_options : ['vapi=false'])

if gtk_layer_shell.found()
    add_project_arguments('-DHAVE_GTK_LAYER_SHELL', language: 'cpp')
endif

As a result I got an error:

meson build
The Meson build system
Version: 1.2.3
Source dir: /home/viktar/Documents/git/waybar
Build dir: /home/viktar/Documents/git/waybar/build
Build type: native build
Project name: waybar
Project version: 1.0.0
C compiler for the host machine: cc (gcc 13.2.1 "cc (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826")
C linker for the host machine: cc ld.bfd 2.41
C++ compiler for the host machine: c++ (gcc 13.2.1 "c++ (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826")
C++ linker for the host machine: c++ ld.bfd 2.41
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C++ supports link arguments -lc++fs: NO 
Compiler for C++ supports link arguments -lc++experimental: NO 
Compiler for C++ supports link arguments -lstdc++fs: YES 
Program git found: YES (/usr/bin/git)
meson.build:36: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
meson.build:37: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.
meson.build:38: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
meson.build:39: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
Has header "filesystem" : YES 
Checking if "nl_langinfo with _NL_TIME_WEEK_1STDAY, _NL_TIME_FIRST_WEEKDAY" : links: YES 
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency jsoncpp found: YES 1.9.4
Run-time dependency wayland-client found: YES 1.22.0
Run-time dependency wayland-cursor found: YES 1.22.0
Run-time dependency wayland-protocols found: YES 1.32
Run-time dependency sigc++-3.0 found: YES 3.4.0
Run-time dependency gtkmm-4.0 found: YES 4.10.0
Run-time dependency gtk4 found: YES 4.10.5
Run-time dependency gio-unix-2.0 found: YES 2.76.4
Run-time dependency spdlog found: YES 1.11.0
Dependency gtk-layer-shell-0 found: NO found 0.8.1 but need: '>=1.0.2'
Found CMake: /usr/bin/cmake (3.27.7)
Run-time dependency gtk-layer-shell-0 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency gtk-layer-shell-0
Using gtk-layer-shell source from cache.
Subproject exists but has no meson.build file
Subproject  gtk-layer-shell is buildable: NO (disabling)
Dependency gtk-layer-shell-0 from subproject gtk-layer-shell found: NO (subproject failed to configure)
protocol/meson.build:1: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
Program wayland-scanner found: YES (/usr/bin/wayland-scanner)
Program gdbus-codegen found: YES (/usr/bin/gdbus-codegen)
Build targets in project: 5
WARNING: Deprecated features used:
 * 0.55.0: {'ExternalProgram.path'}
 * 0.56.0: {'dependency.get_pkgconfig_variable', 'meson.source_root'}

waybar 1.0.0

  Subprojects
    gtk-layer-shell: NO Subproject exists but has no meson.build file

Found ninja-1.11.1 at /usr/bin/ninja
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
ninja -C build
ninja: Entering directory `build'
[40/49] Compiling C++ object waybar.p/src_bar.cpp.o
FAILED: waybar.p/src_bar.cpp.o 
c++ -Iwaybar.p -I. -I.. -I../include -Iprotocol -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -I/usr/include/gtkmm-4.0 -I/usr/lib64/gtkmm-4.0/include -I/usr/include/giomm-2.68 -I/usr/lib64/giomm-2.68/include -I/usr/include/glibmm-2.68 -I/usr/lib64/glibmm-2.68/include -I/usr/include/sigc++-3.0 -I/usr/lib64/sigc++-3.0/include -I/usr/include/cairomm-1.16 -I/usr/lib64/cairomm-1.16/include -I/usr/include/pangomm-2.48 -I/usr/lib64/pangomm-2.48/include -I/usr/include/gtk-4.0/unix-print -I/usr/include/gio-unix-2.0 -I/usr/include/jsoncpp -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O3 '-DVERSION="0.9.24-20-gb920ec6b (branch '"'"'gtk4'"'"')"' -DHAVE_LANGINFO_1STDAY '-DSYSCONFDIR="//usr/local/etc"' -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -pthread -mfpmath=sse -msse -msse2 -mfpmath=sse -msse -msse2 -MD -MQ waybar.p/src_bar.cpp.o -MF waybar.p/src_bar.cpp.o.d -o waybar.p/src_bar.cpp.o -c ../src/bar.cpp
../src/bar.cpp:6:10: fatal error: gtk4-layer-shell.h: No such file or directory
    6 | #include "gtk4-layer-shell.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
[47/49] Compiling C++ object waybar.p/src_client.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:7: build] Error 1

The reason:

Subproject exists but has no meson.build file Subproject gtk-layer-shell is buildable: NO (disabling) Dependency gtk-layer-shell-0 from subproject gtk-layer-shell found: NO (subproject failed to configure)

When I'm trying to build gtk-layer-shell as independent project it builds OK and looks like I can then to install it and satisfy dependency in the main project. But to me it looks like the current project structure does not provide an opportunity to build gtk-layer-shell as a part on the main project when it's not installed int the system. Or I might wrong , can you clarify it please?

LukashonakV commented 6 months ago

I fixed a little bit wrap file and fix depenency library name

[wrap-file]
directory = gtk4-layer-shell-1.0.2
source_filename = gtk4-layer-shell-1.0.2.tar.gz
source_hash = a3a827845612fa15de30734eb29c01db329c32f8e279d8bc5251facc69220b86
source_url = https://github.com/wmww/gtk4-layer-shell/archive/v1.0.2/gtk4-layer-shell-1.0.2.tar.gz

[provide]
gtk_layer_shell = gtk_layer_shell_dep
gtk_layer_shell = dependency('gtk4-layer-shell-0',
                             version : ['>=1.0.2'],
                             required: get_option('gtk-layer-shell'),
                             fallback : ['gtk-layer-shell', 'gtk_layer_shell_dep'],
                             default_options : ['vapi=false'])

if gtk_layer_shell.found()
    add_project_arguments('-DHAVE_GTK_LAYER_SHELL', language: 'cpp')
endif

And this time subproject is compiled.. but still no luck...

meson build
The Meson build system
Version: 1.2.3
Source dir: /home/viktar/Documents/git/waybar
Build dir: /home/viktar/Documents/git/waybar/build
Build type: native build
Project name: waybar
Project version: 1.0.0
C compiler for the host machine: cc (gcc 13.2.1 "cc (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826")
C linker for the host machine: cc ld.bfd 2.41
C++ compiler for the host machine: c++ (gcc 13.2.1 "c++ (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826")
C++ linker for the host machine: c++ ld.bfd 2.41
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C++ supports link arguments -lc++fs: NO 
Compiler for C++ supports link arguments -lc++experimental: NO 
Compiler for C++ supports link arguments -lstdc++fs: YES 
Program git found: YES (/usr/bin/git)
meson.build:36: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
meson.build:37: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.56.0': meson.source_root. use meson.project_source_root() or meson.global_source_root() instead.
meson.build:38: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
meson.build:39: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.55.0': ExternalProgram.path. use ExternalProgram.full_path() instead
Has header "filesystem" : YES 
Checking if "nl_langinfo with _NL_TIME_WEEK_1STDAY, _NL_TIME_FIRST_WEEKDAY" : links: YES 
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency jsoncpp found: YES 1.9.4
Run-time dependency wayland-client found: YES 1.22.0
Run-time dependency wayland-cursor found: YES 1.22.0
Run-time dependency wayland-protocols found: YES 1.32
Run-time dependency sigc++-3.0 found: YES 3.4.0
Run-time dependency gtkmm-4.0 found: YES 4.10.0
Run-time dependency gtk4 found: YES 4.10.5
Run-time dependency gio-unix-2.0 found: YES 2.76.4
Run-time dependency spdlog found: YES 1.11.0
Found CMake: /usr/bin/cmake (3.27.7)
Run-time dependency gtk4-layer-shell-0 found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency gtk4-layer-shell-0
Using gtk-layer-shell source from cache.

Executing subproject gtk-layer-shell 

gtk-layer-shell| Project name: gtk4-layer-shell
gtk-layer-shell| Project version: 1.0.2
gtk-layer-shell| C compiler for the host machine: cc (gcc 13.2.1 "cc (Gentoo 13.2.1_p20230826 p7) 13.2.1 20230826")
gtk-layer-shell| C linker for the host machine: cc ld.bfd 2.41
gtk-layer-shell| Dependency gtk4 found: YES 4.10.5 (cached)
gtk-layer-shell| Dependency wayland-client found: YES 1.22.0 (cached)
gtk-layer-shell| Run-time dependency wayland-server found: YES 1.22.0
gtk-layer-shell| Found pkg-config: /usr/bin/pkg-config (1.8.1)
gtk-layer-shell| Build-time dependency wayland-scanner found: YES 1.22.0
gtk-layer-shell| Dependency wayland-protocols found: YES 1.32 (cached)
gtk-layer-shell| Program /usr/bin/wayland-scanner found: YES (/usr/bin/wayland-scanner)
gtk-layer-shell| Run-time dependency gobject-introspection-1.0 found: YES 1.76.1
gtk-layer-shell| Dependency gobject-introspection-1.0 found: YES 1.76.1 (cached)
gtk-layer-shell| Program /usr/bin/g-ir-scanner found: YES (/usr/bin/g-ir-scanner)
gtk-layer-shell| Dependency gobject-introspection-1.0 found: YES 1.76.1 (cached)
gtk-layer-shell| Program /usr/bin/g-ir-compiler found: YES (/usr/bin/g-ir-compiler)
gtk-layer-shell| Program sh found: YES (/bin/sh)
gtk-layer-shell| Build targets in project: 5
gtk-layer-shell| Subproject gtk-layer-shell finished.

WARNING: Variable 'gtk_layer_shell_dep' in the subproject 'subprojects/gtk4-layer-shell-1.0.2' is not found
Dependency gtk4-layer-shell-0 from subproject subprojects/gtk4-layer-shell-1.0.2 found: NO
protocol/meson.build:1: WARNING: Project targets '>= 1.2.3' but uses feature deprecated since '0.56.0': dependency.get_pkgconfig_variable. use dependency.get_variable(pkgconfig : ...) instead
Program wayland-scanner found: YES (/usr/bin/wayland-scanner)
Program gdbus-codegen found: YES (/usr/bin/gdbus-codegen)
Build targets in project: 10
WARNING: Deprecated features used:
 * 0.55.0: {'ExternalProgram.path'}
 * 0.56.0: {'dependency.get_pkgconfig_variable', 'meson.source_root'}

waybar 1.0.0

  Subprojects
    gtk-layer-shell: YES

Found ninja-1.11.1 at /usr/bin/ninja
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.
ninja -C build
ninja: Entering directory `build'
[46/62] Compiling C++ object waybar.p/src_bar.cpp.o
FAILED: waybar.p/src_bar.cpp.o 
c++ -Iwaybar.p -I. -I.. -I../include -Iprotocol -I/usr/include/gtk-4.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/lib64/libffi/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/libpng16 -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/graphene-1.0 -I/usr/lib64/graphene-1.0/include -I/usr/include/gtkmm-4.0 -I/usr/lib64/gtkmm-4.0/include -I/usr/include/giomm-2.68 -I/usr/lib64/giomm-2.68/include -I/usr/include/glibmm-2.68 -I/usr/lib64/glibmm-2.68/include -I/usr/include/sigc++-3.0 -I/usr/lib64/sigc++-3.0/include -I/usr/include/cairomm-1.16 -I/usr/lib64/cairomm-1.16/include -I/usr/include/pangomm-2.48 -I/usr/lib64/pangomm-2.48/include -I/usr/include/gtk-4.0/unix-print -I/usr/include/gio-unix-2.0 -I/usr/include/jsoncpp -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c++17 -O3 '-DVERSION="0.9.24-20-gb920ec6b (branch '"'"'gtk4'"'"')"' -DHAVE_LANGINFO_1STDAY '-DSYSCONFDIR="//usr/local/etc"' -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -pthread -mfpmath=sse -msse -msse2 -mfpmath=sse -msse -msse2 -MD -MQ waybar.p/src_bar.cpp.o -MF waybar.p/src_bar.cpp.o.d -o waybar.p/src_bar.cpp.o -c ../src/bar.cpp
../src/bar.cpp:6:10: fatal error: gtk4-layer-shell.h: No such file or directory
    6 | #include "gtk4-layer-shell.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
[57/62] Compiling C++ object waybar.p/src_client.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:7: build] Error 1

Will check soon...

LukashonakV commented 6 months ago

So.. finally

  1. wrap file is something like:
    
    [wrap-file]
    directory = gtk4-layer-shell-1.0.2
    source_filename = gtk4-layer-shell-1.0.2.tar.gz
    source_hash = 8e9585393f984f39a388eaefec51404a40c92b79596731c209b0fb986663e23c
    source_url = https://github.com/wmww/gtk4-layer-shell/archive/v1.0.2/gtk4-layer-shell-1.0.2.tar.gz

[provide] gtk-layer-shell = gtk_layer_shell

2. and meson.build like
```meson.build
gtk_layer_shell = dependency('gtk4-layer-shell-0',
                             version : ['>=1.0.2'],
                             required: get_option('gtk-layer-shell'),
                             fallback : ['gtk-layer-shell', 'gtk_layer_shell'],
                             default_options : ['vapi=false'])

if gtk_layer_shell.found()
    add_project_arguments('-DHAVE_GTK_LAYER_SHELL', language: 'cpp')
endif

works fine