Skip to contentSkip to conversation

package/gobject-introspection: misc fixes (branch yem/goi-fixes)

PATCH Superseded Yann E. MORIN 3 participants 9 messages Mar 15, 2020 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v6 cover package/gobject-introspection: misc fixes (branch yem/goi-fixes)

Hello All!

Series based on previous work by Adam, with commit logs slightly expanded and reworded with my own understanding of the problems and the fixes.

Regards,
Yann E. MORIN.

The following changes since commit 17a75bbccfd9a4e7810cbb2fe4182b4f9276cc45

package/perl-timedate: bump to version 2.32 (2020-03-15 16:11:09 +0100)

are available in the git repository at:

git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to 2b3494c60f3e0d1a9bdf79dfb902e685b713c0e3

package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig (2020-03-15 16:32:31 +0100)

----------------------------------------------------------------
Adam Duskett (3):
package/gobject-introspection: fix host-linking package/gobject-introspection: export variables in g-ir-scanner package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

 package/gobject-introspection/g-ir-scanner.in      | 14 +++++
 .../gobject-introspection/gobject-introspection.mk | 20 +++++--
 ...rospection-determine-g-ir-scanner-and-g-i.patch | 62 ++++++++++++++++++++++
 ...modules-gnome.py-Fix-giscanner-and-gicomp.patch | 41 ++++++++++++++
 4 files changed, 132 insertions(+), 5 deletions(-)
 create mode 100644 package/meson/0004-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 package/meson/0005-mesonbuild-modules-gnome.py-Fix-giscanner-and-gicomp.patch
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v6 1/3 package/gobject-introspection: fix host-linking

From: Adam Duskett <[email protected]>

When building, gobject-introspection uses tools/g-ir-scanner to build several .gir and .typelib files. To that goal, it internally builds and runs a few small executables linked to libglib2. However, it does not pass them any LDFLAGS that we could pass the buildsystem. So, it either ends up trying to link with the system's libglib2, which may not be instaleld (build breaks), or is installed to an other version (build may break); in either cases, this is not good...

g-ir-scanner can use the argument --lib-dirs-envvar to pass a list of library directories to search for. However, during the build process, this is not possible due to the build process calling g-ir-scanner directly without letting the user (us) pass any option.

When discussing with upstream, they explained that the only solution in that case was to set and export LD_LIBRARY_PATH to point to the location where the correct libglib2 was installed.

Ergo, that's what we do.

This fix has the added benefit of allowing the host gobject-introspection to build the host .gir, .rnc, and .typelib files, which some packages may require.

---
Changes v1 -> v3:
- Update comment to be more clear.

Changes v3 -> v4:
- Update patch to work with gobject-introspection 2.64.0

Changes v4 -> v5:
- Changed LD_LIBRARY_PATH to LD_RUN_PATH after more testing.
- Updated the commit message and comments in the .mk file to better
describe
what the problem was and why this is necessary.

Changes v5 -> v6 (Yann):
- switch back to LD_LIBRARY_PATH
- append to an already set LD_LIBRARY_PATH
- tweak the comment
- reorganise and reword the commit log

---
 .../gobject-introspection/gobject-introspection.mk    | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
package/gobject-introspection/gobject-introspection.mk +6 -5
index c18a1f17d3..35b6669469 100644
@@ -33,11 +33,12 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
 GOBJECT_INTROSPECTION_NINJA_ENV += \
 	CC="$(TARGET_CC)"
 
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-	-Dbuild_introspection_data=false
+# When building, gobject-introspection uses tools/g-ir-scanner to build several
+# .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default,
+# links to the system-installed libglib2 path. To remedy this issue, defining
+# LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+	LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib"
 
 # Use the host gi-scanner to prevent the scanner from generating incorrect
 # elf classes.
Signature · 1 line
2.20.1
#2 lore raw

PATCH v6 1/3 package/gobject-introspection: fix host-linking

All:

Quoted 76 lines · Yann E. MORIN

From: Adam Duskett <[email protected]>

When building, gobject-introspection uses tools/g-ir-scanner to build several .gir and .typelib files. To that goal, it internally builds and runs a few small executables linked to libglib2. However, it does not pass them any LDFLAGS that we could pass the buildsystem. So, it either ends up trying to link with the system's libglib2, which may not be instaleld (build breaks), or is installed to an other version (build may break); in either cases, this is not good...

g-ir-scanner can use the argument --lib-dirs-envvar to pass a list of library directories to search for. However, during the build process, this is not possible due to the build process calling g-ir-scanner directly without letting the user (us) pass any option.

When discussing with upstream, they explained that the only solution in that case was to set and export LD_LIBRARY_PATH to point to the location where the correct libglib2 was installed.

Ergo, that's what we do.

This fix has the added benefit of allowing the host gobject-introspection to build the host .gir, .rnc, and .typelib files, which some packages may require.

---
Changes v1 -> v3:
- Update comment to be more clear.

Changes v3 -> v4:
- Update patch to work with gobject-introspection 2.64.0

Changes v4 -> v5:
- Changed LD_LIBRARY_PATH to LD_RUN_PATH after more testing.
- Updated the commit message and comments in the .mk file to better
describe
what the problem was and why this is necessary.

Changes v5 -> v6 (Yann):
- switch back to LD_LIBRARY_PATH
- append to an already set LD_LIBRARY_PATH
- tweak the comment
- reorganise and reword the commit log

---
 .../gobject-introspection/gobject-introspection.mk    | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
package/gobject-introspection/gobject-introspection.mk +6 -6
index c18a1f17d3..35b6669469 100644
@@ -33,11 +33,12 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
 GOBJECT_INTROSPECTION_NINJA_ENV += \
        CC="$(TARGET_CC)"
 
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-       -Dbuild_introspection_data=false
+# When building, gobject-introspection uses tools/g-ir-scanner to build several
+# .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default,
+# links to the system-installed libglib2 path. To remedy this issue, defining
+# LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+       LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib"
 
 # Use the host gi-scanner to prevent the scanner from generating incorrect
 # elf classes.
--

2.20.1

#3 lore raw

PATCH v6 1/3 package/gobject-introspection: fix host-linking

In reply to Yann E. MORIN

package/gobject-introspection/gobject-introspection.mk HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \ · line 41

Quoted 11 lines · On Sun, 15 Mar 2020 16:33:19 +0100 "Yann E. MORIN" <[email protected]>…
package/gobject-introspection/gobject-introspection.mk +6 -5
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-	-Dbuild_introspection_data=false
+# When building, gobject-introspection uses tools/g-ir-scanner to build several
+# .gir and .typelib files. g-ir-scanner does not use LDFLAGS, and by default,
+# links to the system-installed libglib2 path. To remedy this issue, defining
+# LD_LIBRARY_PATH forces g-ir-scanner to use our host installed libglib2 files.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+	LD_LIBRARY_PATH="$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(HOST_DIR)/lib"

So there's really no other way? No way to convince this thing to use -Wl,-rpath,$(HOST_DIR)/lib when building host binaries ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v6 2/3 package/gobject-introspection: export variables in g-ir-scanner

In reply to Yann E. MORIN

From: Adam Duskett <[email protected]>

When building .gir .typelib files, the g-ir-scanner wrapper calls the host g-ir-scanner. g-ir-scanner calls ccompiler.py, which searches for the following environment variables:
CPP, CC, CXX, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS

These environment variables are empty by default, and as such ccompiler.py defaults to either using the system tools (CC, CXX, and CPP) or leaving the variables blank (LDFLAGS, CFLAGS, and CPPFLAGS.)

For autotools packages, this issue does not occur because autotools uses Makefile.introspection found on the staging directory in usr/share/gobject-introspection-1.0/ which automatically exports the above variables.

However, for meson, the above variables are not exported when meson calls g-ir-scanner to build .gir and .typelib files, which results in linking errors.

Exporting these variables in the g-ir-scanner wrapper fixes these issues and ensures all build systems can generate .gir and .typelib files properly.

---
Changes v1 -> v3:
- Use relative paths. (Yann)

Changes v4 -> v5:
- Switch back to using HOST_DIR. (Yann)
- Update commit message as to why this patch is necessary.
- Add CXX, CPP, LDFLAGS, CFLAGS and CPPFLAGS to the list of variables of which are exported.
- Add a comment in g-ir-scanner as to why these exports are necessary.

Changes v5 -> v6 (Yann):
- only set the variables if not already set
- use a single call to $(SED) instead of one per variable
- reorder variables in a more logical order
- add missing CXXFLAGS

---
 package/gobject-introspection/g-ir-scanner.in      | 14 ++++++++++++++
 .../gobject-introspection/gobject-introspection.mk |  9 +++++++++
 2 files changed, 23 insertions(+)
package/gobject-introspection/g-ir-scanner.in +14 -0
index 9f97497b7e..22df7be309 100644
@@ -1,6 +1,20 @@
 #!/usr/bin/env bash
 
+# These environment variables are empty by default, and as such ccompiler.py
+# defaults to either using the system tools (CC, CXX, and CPP) or leaving
+# the variables blank (LDFLAGS, CFLAGS, and CPPFLAGS.)
+# Export these variables to ensure all build systems can generate .gir and
+# .typelib files properly.
+export CPP="${CPP:-${HOST_DIR}/bin/@BASENAME_TARGET_CPP@}"
+export CC="${CC:-${HOST_DIR}/bin/@BASENAME_TARGET_CC@}"
+export CXX="${CXX:-${HOST_DIR}/bin/@BASENAME_TARGET_CXX@}"
+export CPPFLAGS="${CPPFLAGS:- at TARGET_CPPFLAGS@}"
+export CFLAGS="${CFLAGS:- at TARGET_CFLAGS@}"
+export CXXFLAGS="${CXXFLAGS:- at TARGET_CXXFLAGS@}"
+export LDFLAGS="${LDFLAGS:- at TARGET_LDFLAGS@}"
+
 export GI_SCANNER_DISABLE_CACHE=1
+
 ${HOST_DIR}/bin/g-ir-scanner \
 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
package/gobject-introspection/gobject-introspection.mk +9 -0
index 35b6669469..0a395b814c 100644
@@ -105,6 +105,15 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
 		$(INSTALL) -D -m 755 \
 			$(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
 	)
+	$(SED) "s%@BASENAME_TARGET_CPP@%$(notdir $(TARGET_CPP))%g" \
+		-e "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" \
+		-e "s%@BASENAME_TARGET_CXX@%$(notdir $(TARGET_CXX))%g" \
+		-e "s%@TARGET_CPPFLAGS@%$(TARGET_CPPFLAGS)%g" \
+		-e "s%@TARGET_CFLAGS@%$(TARGET_CFLAGS)%g" \
+		-e "s%@TARGET_CXXFLAGS@%$(TARGET_CXXFLAGS)%g" \
+		-e "s%@TARGET_LDFLAGS@%$(TARGET_LDFLAGS)%g" \
+		$(STAGING_DIR)/usr/bin/g-ir-scanner
+
 	# Gobject-introspection installs Makefile.introspection in
 	# $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
 	# build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
Signature · 1 line
2.20.1
#5 lore raw

PATCH v6 2/3 package/gobject-introspection: export variables in g-ir-scanner

All:

Quoted 95 lines · Yann E. MORIN

From: Adam Duskett <[email protected]>

When building .gir .typelib files, the g-ir-scanner wrapper calls the host g-ir-scanner. g-ir-scanner calls ccompiler.py, which searches for the following environment variables:
CPP, CC, CXX, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS

These environment variables are empty by default, and as such ccompiler.py defaults to either using the system tools (CC, CXX, and CPP) or leaving the variables blank (LDFLAGS, CFLAGS, and CPPFLAGS.)

For autotools packages, this issue does not occur because autotools uses Makefile.introspection found on the staging directory in usr/share/gobject-introspection-1.0/ which automatically exports the above variables.

However, for meson, the above variables are not exported when meson calls g-ir-scanner to build .gir and .typelib files, which results in linking errors.

Exporting these variables in the g-ir-scanner wrapper fixes these issues and ensures all build systems can generate .gir and .typelib files properly.

---
Changes v1 -> v3:
- Use relative paths. (Yann)

Changes v4 -> v5:
- Switch back to using HOST_DIR. (Yann)
- Update commit message as to why this patch is necessary.
- Add CXX, CPP, LDFLAGS, CFLAGS and CPPFLAGS to the list of variables of which are exported.
- Add a comment in g-ir-scanner as to why these exports are necessary.

Changes v5 -> v6 (Yann):
- only set the variables if not already set
- use a single call to $(SED) instead of one per variable
- reorder variables in a more logical order
- add missing CXXFLAGS

---
 package/gobject-introspection/g-ir-scanner.in      | 14 ++++++++++++++
 .../gobject-introspection/gobject-introspection.mk |  9 +++++++++
 2 files changed, 23 insertions(+)
package/gobject-introspection/g-ir-scanner.in +14 -0
index 9f97497b7e..22df7be309 100644
@@ -1,6 +1,20 @@
 #!/usr/bin/env bash
 
+# These environment variables are empty by default, and as such ccompiler.py
+# defaults to either using the system tools (CC, CXX, and CPP) or leaving
+# the variables blank (LDFLAGS, CFLAGS, and CPPFLAGS.)
+# Export these variables to ensure all build systems can generate .gir and
+# .typelib files properly.
+export CPP="${CPP:-${HOST_DIR}/bin/@BASENAME_TARGET_CPP@}"
+export CC="${CC:-${HOST_DIR}/bin/@BASENAME_TARGET_CC@}"
+export CXX="${CXX:-${HOST_DIR}/bin/@BASENAME_TARGET_CXX@}"
+export CPPFLAGS="${CPPFLAGS:- at TARGET_CPPFLAGS@}"
+export CFLAGS="${CFLAGS:- at TARGET_CFLAGS@}"
+export CXXFLAGS="${CXXFLAGS:- at TARGET_CXXFLAGS@}"
+export LDFLAGS="${LDFLAGS:- at TARGET_LDFLAGS@}"
+
 export GI_SCANNER_DISABLE_CACHE=1
+
 ${HOST_DIR}/bin/g-ir-scanner \
 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
package/gobject-introspection/gobject-introspection.mk +9 -1
index 35b6669469..0a395b814c 100644
@@ -105,6 +105,15 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
                $(INSTALL) -D -m 755 \
                        $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
        )
+       $(SED) "s%@BASENAME_TARGET_CPP@%$(notdir $(TARGET_CPP))%g" \
+               -e "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" \
+               -e "s%@BASENAME_TARGET_CXX@%$(notdir $(TARGET_CXX))%g" \
+               -e "s%@TARGET_CPPFLAGS@%$(TARGET_CPPFLAGS)%g" \
+               -e "s%@TARGET_CFLAGS@%$(TARGET_CFLAGS)%g" \
+               -e "s%@TARGET_CXXFLAGS@%$(TARGET_CXXFLAGS)%g" \
+               -e "s%@TARGET_LDFLAGS@%$(TARGET_LDFLAGS)%g" \
+               $(STAGING_DIR)/usr/bin/g-ir-scanner
+
        # Gobject-introspection installs Makefile.introspection in
        # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
        # build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
--

2.20.1

#6 lore raw

PATCH v6 3/3 package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

In reply to Yann E. MORIN

From: Adam Duskett <[email protected]>

Currently, meson hard codes the paths of these binaries which results in cross-compiled environments to run the host versions of these tools. However, GObject-introspection provides the appropriate paths to these utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If g-ir-scanner or g-ir-compiler are in the build or source directory use those. If they aren't found in the source directory, use the results from pkg-config.

Backport two upstream commits to fix the issue.

---
Changes v1 -> v3:
- Use an upstream patch that fixes this issue permanently.

Changes v4 -> v5:
- Split the patches into two seperate patches. (Yann)

Changes v5 -> v6 (Yann):
- really make them patches backport with git-format-patch

---
 ...ction-determine-g-ir-scanner-and-g-i.patch | 62 +++++++++++++++++++
 ...es-gnome.py-Fix-giscanner-and-gicomp.patch | 41 ++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 package/meson/0004-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 package/meson/0005-mesonbuild-modules-gnome.py-Fix-giscanner-and-gicomp.patch
package/meson/0004-gobject-introspection-determine-g-ir-scanner-and-g-i.patch new file +62 -0
new file mode 100644
index 0000000000..9c7eb656bc
@@ -0,0 +1,62 @@
+From f66b04b0996eae5cd7b0ad007435d5a51f28b691 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Mon, 24 Feb 2020 06:29:26 -0800
+Subject: [PATCH] gobject-introspection: determine g-ir-scanner and
+ g-ir-compiler paths from pkgconfig
+
+Currently, meson hard codes the paths of these binaries which results in
+cross-compiled environments to run the host versions of these tools.
+However, GObject-introspection provides the appropriate paths to these
+utilities via pkg-config
+
+find_program is needed in the case g-i is built as a subproject. If
+g-ir-scanner or g-ir-compiler are in the build or source directory use those.
+If they aren't found in the source directory, use the results from pkg-config.
+
+Upstream commit: f66b04b0996eae5cd7b0ad007435d5a51f28b691
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 21 ++++++++++++++++++---
+ 1 file changed, 18 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 3d5d7181..0ea4b273 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -736,15 +736,30 @@ class GnomeModule(ExtensionModule):
+         if kwargs.get('install_dir'):
+             raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
+ 
+-        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
+-        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+-
+         girtargets = [self._unwrap_gir_target(arg, state) for arg in args]
+ 
+         if len(girtargets) > 1 and any([isinstance(el, build.Executable) for el in girtargets]):
+             raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
+ 
+         self.gir_dep, pkgargs = self._get_gir_dep(state)
++        # find_program is needed in the case g-i is built as subproject.
++        # In that case it uses override_find_program so the gobject utilities
++        # can be used from the build dir instead of from the system.
++        # However, GObject-introspection provides the appropriate paths to
++        # these utilities via pkg-config, so it would be best to use the
++        # results from pkg-config when possible.
++        gi_util_dirs_check = [state.environment.get_build_dir(), state.environment.get_source_dir()]
++        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
++        if giscanner.found():
++            giscanner_path = giscanner.get_command()[0]
++            if not any(x in giscanner_path for x in gi_util_dirs_check):
++                giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++
++        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
++        if gicompiler.found():
++            gicompiler_path = gicompiler.get_command()[0]
++            if not any(x in gicompiler_path for x in gi_util_dirs_check):
++                gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+ 
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+-- 
+2.20.1
+
package/meson/0005-mesonbuild-modules-gnome.py-Fix-giscanner-and-gicomp.patch new file +41 -0

41 lines not on this page · raw message

Signature · 1 line
2.20.1
#7 lore raw

PATCH v6 3/3 package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

All:

Quoted 151 lines · Yann E. MORIN

From: Adam Duskett <[email protected]>

Currently, meson hard codes the paths of these binaries which results in cross-compiled environments to run the host versions of these tools. However, GObject-introspection provides the appropriate paths to these utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If g-ir-scanner or g-ir-compiler are in the build or source directory use those. If they aren't found in the source directory, use the results from pkg-config.

Backport two upstream commits to fix the issue.

---
Changes v1 -> v3:
- Use an upstream patch that fixes this issue permanently.

Changes v4 -> v5:
- Split the patches into two seperate patches. (Yann)

Changes v5 -> v6 (Yann):
- really make them patches backport with git-format-patch

---
 ...ction-determine-g-ir-scanner-and-g-i.patch | 62 +++++++++++++++++++
 ...es-gnome.py-Fix-giscanner-and-gicomp.patch | 41 ++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 package/meson/0004-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 package/meson/0005-mesonbuild-modules-gnome.py-Fix-giscanner-and-gicomp.patch
package/meson/0004-gobject-introspection-determine-g-ir-scanner-and-g-i.patch new file +62 -0
new file mode 100644
index 0000000000..9c7eb656bc
@@ -0,0 +1,62 @@
+From f66b04b0996eae5cd7b0ad007435d5a51f28b691 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Mon, 24 Feb 2020 06:29:26 -0800
+Subject: [PATCH] gobject-introspection: determine g-ir-scanner and
+ g-ir-compiler paths from pkgconfig
+
+Currently, meson hard codes the paths of these binaries which results in
+cross-compiled environments to run the host versions of these tools.
+However, GObject-introspection provides the appropriate paths to these
+utilities via pkg-config
+
+find_program is needed in the case g-i is built as a subproject. If
+g-ir-scanner or g-ir-compiler are in the build or source directory use those.
+If they aren't found in the source directory, use the results from pkg-config.
+
+Upstream commit: f66b04b0996eae5cd7b0ad007435d5a51f28b691
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 21 ++++++++++++++++++---
+ 1 file changed, 18 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 3d5d7181..0ea4b273 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -736,15 +736,30 @@ class GnomeModule(ExtensionModule):
+         if kwargs.get('install_dir'):
+             raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
+
+-        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
+-        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+-
+         girtargets = [self._unwrap_gir_target(arg, state) for arg in args]
+
+         if len(girtargets) > 1 and any([isinstance(el, build.Executable) for el in girtargets]):
+             raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
+
+         self.gir_dep, pkgargs = self._get_gir_dep(state)
++        # find_program is needed in the case g-i is built as subproject.
++        # In that case it uses override_find_program so the gobject utilities
++        # can be used from the build dir instead of from the system.
++        # However, GObject-introspection provides the appropriate paths to
++        # these utilities via pkg-config, so it would be best to use the
++        # results from pkg-config when possible.
++        gi_util_dirs_check = [state.environment.get_build_dir(), state.environment.get_source_dir()]
++        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
++        if giscanner.found():
++            giscanner_path = giscanner.get_command()[0]
++            if not any(x in giscanner_path for x in gi_util_dirs_check):
++                giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++
++        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
++        if gicompiler.found():
++            gicompiler_path = gicompiler.get_command()[0]
++            if not any(x in gicompiler_path for x in gi_util_dirs_check):
++                gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+--
+2.20.1
+
package/meson/0005-mesonbuild-modules-gnome.py-Fix-giscanner-and-gicomp.patch new file +41 -1
new file mode 100644
index 0000000000..4a0813dc8d
@@ -0,0 +1,41 @@
+From 6ba034c37d8004a72d392f37f66e709c593d8983 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Wed, 26 Feb 2020 05:51:28 -0800
+Subject: [PATCH] mesonbuild/modules/gnome.py: Fix giscanner and gicompiler
+ logic
+
+Currently, giscanner and the gicompiler paths are only scanned via pkg-config
+if they are first found in the host path.
+
+Add a else statement to fix this oversite.
+
+Upstream commit: 6ba034c37d8004a72d392f37f66e709c593d8983
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 0ea4b273..1743b59c 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -754,12 +754,16 @@ class GnomeModule(ExtensionModule):
+             giscanner_path = giscanner.get_command()[0]
+             if not any(x in giscanner_path for x in gi_util_dirs_check):
+                 giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++        else:
++            giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
+
+         gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+         if gicompiler.found():
+             gicompiler_path = gicompiler.get_command()[0]
+             if not any(x in gicompiler_path for x in gi_util_dirs_check):
+                 gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
++        else:
++            gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+--
+2.20.1
+
--

2.20.1

#8 lore raw

v6 cover package/gobject-introspection: misc fixes (branch yem/goi-fixes)

In reply to Yann E. MORIN

Adam, All,

On 2020-03-15 16:33 +0100, Yann E. MORIN spake thusly:

Quoted 3 lines

Series based on previous work by Adam, with commit logs slightly expanded and reworded with my own understanding of the problems and the fixes.

Series eventually applied, now. Thanks for your persistence. :-)

We shall now all rejoice at the incoming flood of patches making use of GOI in buildroot. Rejoice, or brace ourselves, that is... ;-]

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'