From: James Hilliard <james.hilliard1@gmail.com>
To: buildroot@buildroot.org
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>,
Samuel Martin <s.martin49@gmail.com>,
James Hilliard <james.hilliard1@gmail.com>,
Norbert Lange <nolange79@gmail.com>,
"Yann E . MORIN" <yann.morin.1998@free.fr>,
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Subject: [Buildroot] [PATCH v3 1/1] package/pkg-meson: use meson to build/install packages
Date: Fri, 22 Jul 2022 00:09:36 -0600 [thread overview]
Message-ID: <20220722060936.566534-1-james.hilliard1@gmail.com> (raw)
As of version 0.54.0 meson has had the ability to build and install
packages rather than having to run ninja directly as before.
This will allow us to use features such as meson install tags in
the future which require meson to be used for the installation.
It appears we need to ensure the cmake prefix path is set for the
meson generated relocatable pkg-config format to work properly.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes v2 -> v3:
- set pkgconfig to relocatable
- set cmake pkg-config prefix path
Changes v1 -> v2:
- update docs
---
docs/manual/adding-packages-meson.txt | 4 +-
.../gobject-introspection.mk | 4 +-
package/pkg-cmake.mk | 4 ++
package/pkg-meson.mk | 61 +++++++++++++------
package/systemd/systemd.mk | 4 +-
5 files changed, 53 insertions(+), 24 deletions(-)
diff --git a/docs/manual/adding-packages-meson.txt b/docs/manual/adding-packages-meson.txt
index 029c8c2488..c8aed65c2f 100644
--- a/docs/manual/adding-packages-meson.txt
+++ b/docs/manual/adding-packages-meson.txt
@@ -125,8 +125,8 @@ will therefore only use a few of them.
+c_link_args+, +cpp_args+, +cpp_link_args+, +sys_root+, and
+pkg_config_libdir+.
-* +FOO_NINJA_ENV+, to specify additional environment variables to pass to
- +ninja+, meson companion tool in charge of the build operations. By default,
+* +FOO_MESON_ENV+, to specify additional environment variables to pass to
+ +meson+, meson tool in charge of the build/install operations. By default,
empty.
* +FOO_NINJA_OPTS+, to specify a space-separated list of targets to build. By
diff --git a/package/gobject-introspection/gobject-introspection.mk b/package/gobject-introspection/gobject-introspection.mk
index 41d64171a7..ea5100247d 100644
--- a/package/gobject-introspection/gobject-introspection.mk
+++ b/package/gobject-introspection/gobject-introspection.mk
@@ -30,14 +30,14 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
host-python3
# g-ir-scanner will default to /usr/bin/ld for linking if this is not set.
-GOBJECT_INTROSPECTION_NINJA_ENV += \
+GOBJECT_INTROSPECTION_MESON_ENV += \
CC="$(TARGET_CC)"
# 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 += \
+HOST_GOBJECT_INTROSPECTION_MESON_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
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 3b1db35fb6..4fa620080d 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -90,6 +90,8 @@ define $(2)_CONFIGURE_CMDS
$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/share/buildroot/toolchainfile.cmake" \
-DCMAKE_INSTALL_PREFIX="/usr" \
+ -DCMAKE_PREFIX_PATH="$$(STAGING_DIR)/usr" \
+ -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON \
-DCMAKE_COLOR_MAKEFILE=OFF \
-DBUILD_DOC=OFF \
-DBUILD_DOCS=OFF \
@@ -123,6 +125,8 @@ define $(2)_CONFIGURE_CMDS
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \
-DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)" \
+ -DCMAKE_PREFIX_PATH="$$(HOST_DIR)" \
+ -DPKG_CONFIG_USE_CMAKE_PREFIX_PATH=ON \
-DCMAKE_C_FLAGS="$$(HOST_CFLAGS)" \
-DCMAKE_CXX_FLAGS="$$(HOST_CXXFLAGS)" \
-DCMAKE_EXE_LINKER_FLAGS="$$(HOST_LDFLAGS)" \
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index 0835e08e3a..de5817d5da 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -21,13 +21,13 @@
################################################################################
#
-# Pass PYTHONNOUSERSITE environment variable when invoking Meson or Ninja, so
+# Pass PYTHONNOUSERSITE environment variable when invoking Meson, so
# $(HOST_DIR)/bin/python3 will not look for Meson modules in
# $HOME/.local/lib/python3.x/site-packages
#
-MESON = PYTHONNOUSERSITE=y $(HOST_DIR)/bin/meson
-NINJA = PYTHONNOUSERSITE=y $(HOST_DIR)/bin/ninja
-NINJA_OPTS = $(if $(VERBOSE),-v)
+MESON = PYTHONNOUSERSITE=y $(HOST_DIR)/bin/meson
+MESON_BUILD_OPTS = $(if $(VERBOSE),-v)
+MESON_INSTALL_OPTS = --no-rebuild
# https://mesonbuild.com/Reference-tables.html#cpu-families
ifeq ($(BR2_arcle)$(BR2_arceb),y)
@@ -138,6 +138,7 @@ define $(2)_CONFIGURE_CMDS
$$(MESON) \
--prefix=/usr \
--libdir=lib \
+ --pkgconfig.relocatable \
--default-library=$(if $(BR2_STATIC_LIBS),static,shared) \
--buildtype=$(if $(BR2_ENABLE_RUNTIME_DEBUG),debug,release) \
--cross-file=$$($$(PKG)_SRCDIR)/build/cross-compilation.conf \
@@ -156,10 +157,11 @@ define $(2)_CONFIGURE_CMDS
mkdir -p $$($$(PKG)_SRCDIR)/build
$$(HOST_CONFIGURE_OPTS) \
$$($$(PKG)_CONF_ENV) $$(MESON) \
- --prefix=$$(HOST_DIR) \
+ --prefix=/ \
--libdir=lib \
- --sysconfdir=$$(HOST_DIR)/etc \
- --localstatedir=$$(HOST_DIR)/var \
+ --pkgconfig.relocatable \
+ --sysconfdir=etc \
+ --localstatedir=var \
--default-library=shared \
--buildtype=release \
--wrap-mode=nodownload \
@@ -179,13 +181,23 @@ $(2)_DEPENDENCIES += host-meson
ifndef $(2)_BUILD_CMDS
ifeq ($(4),target)
define $(2)_BUILD_CMDS
- $$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
- $$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/build
+ $$(TARGET_MAKE_ENV) \
+ $$($$(PKG)_MESON_ENV) \
+ $$(MESON) \
+ compile \
+ $$(MESON_BUILD_OPTS) \
+ $$(if $$($$(PKG)_NINJA_OPTS),--ninja-args $$($$(PKG)_NINJA_OPTS)) \
+ -C $$($$(PKG)_SRCDIR)/build
endef
else
define $(2)_BUILD_CMDS
- $$(HOST_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
- $$(NINJA) $$(NINJA_OPTS) $$($$(PKG)_NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/build
+ $$(HOST_MAKE_ENV) \
+ $$($$(PKG)_MESON_ENV) \
+ $$(MESON) \
+ compile \
+ $$(MESON_BUILD_OPTS) \
+ $$(if $$($$(PKG)_NINJA_OPTS),--ninja-args $$($$(PKG)_NINJA_OPTS)) \
+ -C $$($$(PKG)_SRCDIR)/build
endef
endif
endif
@@ -196,8 +208,13 @@ endif
#
ifndef $(2)_INSTALL_CMDS
define $(2)_INSTALL_CMDS
- $$(HOST_MAKE_ENV) $$($$(PKG)_NINJA_ENV) \
- $$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/build install
+ $$(HOST_MAKE_ENV) \
+ $$($$(PKG)_MESON_ENV) \
+ $$(MESON) \
+ install \
+ $$(MESON_INSTALL_OPTS) \
+ --destdir $$(HOST_DIR) \
+ -C $$($$(PKG)_SRCDIR)/build
endef
endif
@@ -207,8 +224,13 @@ endif
#
ifndef $(2)_INSTALL_STAGING_CMDS
define $(2)_INSTALL_STAGING_CMDS
- $$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) DESTDIR=$$(STAGING_DIR) \
- $$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/build install
+ $$(TARGET_MAKE_ENV) \
+ $$($$(PKG)_MESON_ENV) \
+ $$(MESON) \
+ install \
+ $$(MESON_INSTALL_OPTS) \
+ --destdir $$(STAGING_DIR) \
+ -C $$($$(PKG)_SRCDIR)/build
endef
endif
@@ -218,8 +240,13 @@ endif
#
ifndef $(2)_INSTALL_TARGET_CMDS
define $(2)_INSTALL_TARGET_CMDS
- $$(TARGET_MAKE_ENV) $$($$(PKG)_NINJA_ENV) DESTDIR=$$(TARGET_DIR) \
- $$(NINJA) $$(NINJA_OPTS) -C $$($$(PKG)_SRCDIR)/build install
+ $$(TARGET_MAKE_ENV) \
+ $$($$(PKG)_MESON_ENV) \
+ $$(MESON) \
+ install \
+ $$(MESON_INSTALL_OPTS) \
+ --destdir $$(TARGET_DIR) \
+ -C $$($$(PKG)_SRCDIR)/build
endef
endif
diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index 46a4e8de2c..9bb87f8e39 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -746,7 +746,7 @@ endef
SYSTEMD_ROOTFS_PRE_CMD_HOOKS += SYSTEMD_PRESET_ALL
SYSTEMD_CONF_ENV = $(HOST_UTF8_LOCALE_ENV)
-SYSTEMD_NINJA_ENV = $(HOST_UTF8_LOCALE_ENV)
+SYSTEMD_MESON_ENV = $(HOST_UTF8_LOCALE_ENV)
define SYSTEMD_LINUX_CONFIG_FIXUPS
$(call KCONFIG_ENABLE_OPT,CONFIG_DEVTMPFS)
@@ -849,8 +849,6 @@ HOST_SYSTEMD_DEPENDENCIES = \
host-gperf \
host-python-jinja2
-HOST_SYSTEMD_NINJA_ENV = DESTDIR=$(HOST_DIR)
-
# Fix RPATH After installation
# * systemd provides a install_rpath instruction to meson because the binaries
# need to link with libsystemd which is not in a standard path
--
2.34.1
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next reply other threads:[~2022-07-22 6:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 6:09 James Hilliard [this message]
2022-07-24 15:37 ` [Buildroot] [PATCH v3 1/1] package/pkg-meson: use meson to build/install packages Yann E. MORIN
2022-07-24 19:30 ` Arnout Vandecappelle
2022-07-26 4:59 ` James Hilliard
2022-07-26 7:31 ` Arnout Vandecappelle
2022-07-28 1:53 ` James Hilliard
2022-07-24 19:42 ` Arnout Vandecappelle
2022-07-26 5:05 ` James Hilliard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220722060936.566534-1-james.hilliard1@gmail.com \
--to=james.hilliard1@gmail.com \
--cc=buildroot@buildroot.org \
--cc=eric.le.bihan.dev@free.fr \
--cc=nolange79@gmail.com \
--cc=s.martin49@gmail.com \
--cc=thomas.de_schampheleire@nokia.com \
--cc=yann.morin.1998@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.