* [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir
2020-02-04 16:58 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Arnout Vandecappelle
@ 2020-02-04 16:58 ` Arnout Vandecappelle
2020-02-04 16:58 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
2020-02-05 9:15 ` [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Yann E. MORIN
2 siblings, 0 replies; 4+ messages in thread
From: Arnout Vandecappelle @ 2020-02-04 16:58 UTC (permalink / raw)
To: buildroot
To allow meson to distinguish between pkg-config for host (= native)
and pkg-config for target (= cross), we want to be able to give a
different pkg_config_libdir for host and for target. meson already has a
'sys_root' option that sets the sysroot that is used by pkg-config, but
we also need explicit search directories for pkg-config.
Therefore, back-port an upstream patch (will be included in 0.54) that
adds this feature.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
...onfig-add-pkg_config_libdir-property.patch | 102 ++++++++++++++++++
1 file changed, 102 insertions(+)
create mode 100644 package/meson/0003-envconfig-add-pkg_config_libdir-property.patch
diff --git a/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch b/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch
new file mode 100644
index 0000000000..ae40ab8b1c
--- /dev/null
+++ b/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch
@@ -0,0 +1,102 @@
+From 3af920cb4a9c272b9b75a4f3eea9da9000520949 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com>
+Date: Tue, 14 Jan 2020 11:11:52 +0100
+Subject: [PATCH] envconfig: add pkg_config_libdir property
+
+In order to unify the use of sysroot in the cross-file,
+the pkg_config_libdir can now be passed directly in the file.
+
+Upstream: 958df63dac810246e84c2b8eaa32d22d19ace0ef
+[Arnout: remove documentation changes: we don't extract docs/]
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+---
+ mesonbuild/dependencies/base.py | 6 ++++++
+ mesonbuild/envconfig.py | 6 ++++++
+ run_unittests.py | 30 +++++++++++++++++++++++++++++-
+ 3 files changed, 41 insertions(+), 1 deletion(-)
+
+diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
+index 40e304c7..282c314b 100644
+--- a/mesonbuild/dependencies/base.py
++++ b/mesonbuild/dependencies/base.py
+@@ -697,6 +697,12 @@ class PkgConfigDependency(ExternalDependency):
+ mlog.debug('PKG_CONFIG_PATH: ' + new_pkg_config_path)
+ env['PKG_CONFIG_PATH'] = new_pkg_config_path
+
++ pkg_config_libdir_prop = self.env.properties[self.for_machine].get_pkg_config_libdir()
++ if pkg_config_libdir_prop:
++ new_pkg_config_libdir = ':'.join([p for p in pkg_config_libdir_prop])
++ env['PKG_CONFIG_LIBDIR'] = new_pkg_config_libdir
++ mlog.debug('PKG_CONFIG_LIBDIR: ' + new_pkg_config_libdir)
++
+ fenv = frozenset(env.items())
+ targs = tuple(args)
+ cache = PkgConfigDependency.pkgbin_cache
+diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
+index c8a37f4c..3e5e44b8 100644
+--- a/mesonbuild/envconfig.py
++++ b/mesonbuild/envconfig.py
+@@ -143,6 +143,12 @@ class Properties(HasEnvVarFallback):
+ def get_sys_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
+ return self.properties.get('sys_root', None)
+
++ def get_pkg_config_libdir(self) -> T.Optional[T.List[str]]:
++ p = self.properties.get('pkg_config_libdir', None)
++ if p is None:
++ return p
++ return mesonlib.listify(p)
++
+ def __eq__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
+ if isinstance(other, type(self)):
+ return self.properties == other.properties
+diff --git a/run_unittests.py b/run_unittests.py
+index 676604f4..382c0964 100755
+--- a/run_unittests.py
++++ b/run_unittests.py
+@@ -3621,6 +3621,34 @@ recommended as it is not supported on some platforms''')
+ self.wipe()
+ self.init(testdir, extra_args=['-Dstart_native=true'], override_envvars=env)
+
++ @skipIfNoPkgconfig
++ @unittest.skipIf(is_windows(), 'Help needed with fixing this test on windows')
++ def test_pkg_config_libdir(self):
++ testdir = os.path.join(self.unit_test_dir,
++ '46 native dep pkgconfig var')
++ with tempfile.NamedTemporaryFile(mode='w', delete=False) as crossfile:
++ crossfile.write(textwrap.dedent(
++ '''[binaries]
++ pkgconfig = 'pkg-config'
++
++ [properties]
++ pkg_config_libdir = [r'{0}']
++
++ [host_machine]
++ system = 'linux'
++ cpu_family = 'arm'
++ cpu = 'armv7'
++ endian = 'little'
++ '''.format(os.path.join(testdir, 'cross_pkgconfig'))))
++ crossfile.flush()
++ self.meson_cross_file = crossfile.name
++
++ env = {'PKG_CONFIG_LIBDIR': os.path.join(testdir,
++ 'native_pkgconfig')}
++ self.init(testdir, extra_args=['-Dstart_native=false'], override_envvars=env)
++ self.wipe()
++ self.init(testdir, extra_args=['-Dstart_native=true'], override_envvars=env)
++
+ def __reconfigure(self, change_minor=False):
+ # Set an older version to force a reconfigure from scratch
+ filename = os.path.join(self.privatedir, 'coredata.dat')
+@@ -6847,7 +6875,7 @@ class NativeFileTests(BasePlatformTests):
+
+ class CrossFileTests(BasePlatformTests):
+
+- """Tests for cross file functioality not directly related to
++ """Tests for cross file functionality not directly related to
+ cross compiling.
+
+ This is mainly aimed to testing overrides from cross files.
+--
+2.24.1
+
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings
2020-02-04 16:58 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Arnout Vandecappelle
2020-02-04 16:58 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
@ 2020-02-04 16:58 ` Arnout Vandecappelle
2020-02-05 9:15 ` [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Yann E. MORIN
2 siblings, 0 replies; 4+ messages in thread
From: Arnout Vandecappelle @ 2020-02-04 16:58 UTC (permalink / raw)
To: buildroot
meson is able to distinguish between host (= native) and target (=
cross) compilation. It will explicitly pass different options to
pkg-config to distinguish them. Therefore, we don't need to use the
pkg-config wrapper when using meson, and can instead pass the pkg-config
settings through the cross-compilation.conf.
This is important because in some situations (e.g. for the Python
configuration), meson sets the PKG_CONFIG_LIBDIR variable to a different
value before calling pkg-config. Relying on our wrapper script doesn't
work in that case (except if the script would unconditionally set
PKG_CONFIG_LIBDIR, which it doesn't do at the moment).
Add the sys_root and pkg_config_lib settings to cross-compilation.conf
and use pkgconf directly instead of the wrapper.
Note that this requires us to substitute STAGING_DIR as well, with an
absolute path. This is not a big deal since cross-compilation.conf is
regenerated for every package.
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
package/meson/cross-compilation.conf.in | 4 +++-
package/pkg-meson.mk | 2 ++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/package/meson/cross-compilation.conf.in b/package/meson/cross-compilation.conf.in
index fc8e27f7eb..369e225b3e 100644
--- a/package/meson/cross-compilation.conf.in
+++ b/package/meson/cross-compilation.conf.in
@@ -8,7 +8,7 @@ c = '@TARGET_CROSS at gcc'
cpp = '@TARGET_CROSS at g++'
ar = '@TARGET_CROSS at ar'
strip = '@TARGET_CROSS at strip'
-pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
+pkgconfig = '@HOST_DIR@/bin/pkgconf'
[properties]
needs_exe_wrapper = true
@@ -16,6 +16,8 @@ c_args = [@TARGET_CFLAGS@]
c_link_args = [@TARGET_LDFLAGS@]
cpp_args = [@TARGET_CXXFLAGS@]
cpp_link_args = [@TARGET_LDFLAGS@]
+sys_root = '@STAGING_DIR@'
+pkg_config_libdir = '@STAGING_DIR@/usr/lib/pkgconfig:@STAGING_DIR@/usr/share/pkgconfig'
[host_machine]
system = 'linux'
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index f1a3a69129..6bed2c26d2 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -79,6 +79,7 @@ define $(2)_CONFIGURE_CMDS
-e "s%@TARGET_LDFLAGS@%$$(call meson-format-flags,$$($(2)_LDFLAGS))%g" \
-e "s%@TARGET_CXXFLAGS@%$$(call meson-format-flags,$$($(2)_CXXFLAGS))%g" \
-e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
+ -e "s%@STAGING_DIR@%$$(STAGING_DIR)%g" \
$$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
-e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
) \
@@ -196,6 +197,7 @@ define PKG_MESON_INSTALL_CROSS_CONF
-e "s%@TARGET_LDFLAGS@%$(call meson-format-flags,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g" \
-e "s%@TARGET_CXXFLAGS@%$(call meson-format-flags,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g" \
-e "s%@HOST_DIR@%$(HOST_DIR)%g" \
+ -e "s%@STAGING_DIR@%$$(STAGING_DIR)%g" \
$(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
> $(HOST_DIR)/etc/meson/cross-compilation.conf.in
sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
--
2.24.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function
2020-02-04 16:58 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Arnout Vandecappelle
2020-02-04 16:58 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
2020-02-04 16:58 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
@ 2020-02-05 9:15 ` Yann E. MORIN
2 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2020-02-05 9:15 UTC (permalink / raw)
To: buildroot
Arnout, All,
On 2020-02-04 17:58 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
> pkg-meson defines variables _MESON_SED_CFLAGS, _MESON_SED_LDFLAGS and
> _MESON_SED_CXXFLAGS that reformat the make-style flags (space-separated
> and unquoted) as meson-style flags (comma-separated and double-quoted).
> Similar variables are also defined in meson.mk. A future patch will add
> even more similar cases.
>
> Refactor this by defining a macro for this substitution, and using that
> macro in all places where *_MESON_SED_* is used. The definitions of
> these variables are no longer needed.
>
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
As seen IRL, we already have the make-comma-list macro that provides the
same exact feature, in support/misc/pkg-utils.mk, which you could use
instead of your meson-format-flags one.
Regards,
Yann E. MORIN.
> ---
> package/meson/meson.mk | 4 ----
> package/pkg-meson.mk | 20 ++++++++++----------
> 2 files changed, 10 insertions(+), 14 deletions(-)
>
> diff --git a/package/meson/meson.mk b/package/meson/meson.mk
> index e51e76d1c0..810c84690a 100644
> --- a/package/meson/meson.mk
> +++ b/package/meson/meson.mk
> @@ -45,10 +45,6 @@ else
> HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
> endif
>
> -HOST_MESON_SED_CFLAGS = $(if $(strip $(TARGET_CFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
> -HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
> -HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
> -
> # Avoid interpreter shebang longer than 128 chars
> define HOST_MESON_SET_INTERPRETER
> $(SED) '1s:.*:#!/usr/bin/env python3:' $(HOST_DIR)/bin/meson
> diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
> index e7eea2aa58..f1a3a69129 100644
> --- a/package/pkg-meson.mk
> +++ b/package/pkg-meson.mk
> @@ -29,6 +29,10 @@ MESON = PYTHONNOUSERSITE=y $(HOST_DIR)/bin/meson
> NINJA = PYTHONNOUSERSITE=y $(HOST_DIR)/bin/ninja
> NINJA_OPTS = $(if $(VERBOSE),-v) -j$(PARALLEL_JOBS)
>
> +# convert space-separated 'make'-style list of flags to comma-separated and
> +# double-quoted 'meson'-style
> +meson-format-flags = $(if $(strip $(1)),`printf '"%s"$(comma) ' $(1)`)
> +
> ################################################################################
> # inner-meson-package -- defines how the configuration, compilation and
> # installation of a Meson package should be done, implements a few hooks to
> @@ -61,10 +65,6 @@ $(2)_CFLAGS ?= $$(TARGET_CFLAGS)
> $(2)_LDFLAGS ?= $$(TARGET_LDFLAGS)
> $(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
>
> -$(2)_MESON_SED_CFLAGS = $$(if $$(strip $$($(2)_CFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CFLAGS)`)
> -$(2)_MESON_SED_LDFLAGS = $$(if $$(strip $$($(2)_LDFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_LDFLAGS)`)
> -$(2)_MESON_SED_CXXFLAGS = $$(if $$(strip $$($(2)_CXXFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CXXFLAGS)`)
> -
> # Configure package for target
> #
> #
> @@ -75,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
> -e "s%@TARGET_ARCH@%$$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
> -e "s%@TARGET_CPU@%$$(GCC_TARGET_CPU)%g" \
> -e "s%@TARGET_ENDIAN@%$$(call LOWERCASE,$$(BR2_ENDIAN))%g" \
> - -e "s%@TARGET_CFLAGS@%$$($(2)_MESON_SED_CFLAGS)%g" \
> - -e "s%@TARGET_LDFLAGS@%$$($(2)_MESON_SED_LDFLAGS)%g" \
> - -e "s%@TARGET_CXXFLAGS@%$$($(2)_MESON_SED_CXXFLAGS)%g" \
> + -e "s%@TARGET_CFLAGS@%$$(call meson-format-flags,$$($(2)_CFLAGS))%g" \
> + -e "s%@TARGET_LDFLAGS@%$$(call meson-format-flags,$$($(2)_LDFLAGS))%g" \
> + -e "s%@TARGET_CXXFLAGS@%$$(call meson-format-flags,$$($(2)_CXXFLAGS))%g" \
> -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
> $$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
> -e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
> @@ -192,9 +192,9 @@ define PKG_MESON_INSTALL_CROSS_CONF
> -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
> -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
> -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
> - -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)@PKG_TARGET_CFLAGS@%g" \
> - -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)@PKG_TARGET_CFLAGS@%g" \
> - -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)@PKG_TARGET_CFLAGS@%g" \
> + -e "s%@TARGET_CFLAGS@%$(call meson-format-flags,$(TARGET_CFLAGS))@PKG_TARGET_CFLAGS@%g" \
> + -e "s%@TARGET_LDFLAGS@%$(call meson-format-flags,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g" \
> + -e "s%@TARGET_CXXFLAGS@%$(call meson-format-flags,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g" \
> -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
> $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
> > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
> --
> 2.24.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 4+ messages in thread