package/meson: install cross-compilation.conf during toolchain install
authorThomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Mon, 25 Feb 2019 21:11:46 +0000 (22:11 +0100)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Sun, 27 Oct 2019 13:34:25 +0000 (14:34 +0100)
package/meson installs a cross-compilation.conf file in
$(HOST_DIR)/etc/meson, via TARGET_FINALIZE_HOOKS.

package/pkg-cmake.mk installs a toolchainfile.cmake in
$(HOST_DIR)/share/buildroot, via TOOLCHAIN_POST_INSTALL_STAGING_HOOKS.

Both files have a similar concept, they describe some flags/paths needed for
compilation using respective build systems. One difference is that the meson
file is added for external compilation, from the SDK, while the cmake file
is used internally in Buildroot.

The 'problem' of using TARGET_FINALIZE_HOOKS for the meson file, is that it
installs a 'host' file from target-finalize, which is conceptually incorrect
since not just TARGET_DIR but also HOST_DIR is "regenerated" on a subsequent
'make' when everything was already built (i.e. only target-finalize is run).

This can easily be fixed, by using the same hook as cmake uses, i.e.
TOOLCHAIN_POST_INSTALL_STAGING_HOOKS.

Note that actually even for cmake, TOOLCHAIN_POST_INSTALL_STAGING_HOOKS is
not the best hook to install a host file. A better hook would have been
TOOLCHAIN_POST_INSTALL_HOOKS, but this triggers only for 'host' packages,
and 'toolchain' is treated as a 'target' package.

Also, the hook (and therefore also the definition of
PKG_MESON_INSTALL_CROSS_CONF) is moved to pkg-meson.mk, again to make it
more similar to how it's done for cmake. Otherwise check-package
complains that the meson package is setting variables that don't start
with MESON_.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
package/meson/meson.mk
package/pkg-meson.mk

index 29a192c56910e2f006c09e07e1afc21c2f406c9d..c708532c6dc802c9872a806b8f770df8167ce7a8 100644 (file)
@@ -49,28 +49,4 @@ HOST_MESON_SED_CFLAGS = $(if $(strip $(TARGET_CFLAGS)),`printf '"%s"$(comma) ' $
 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)`)
 
-# Generate a Meson cross-compilation.conf suitable for use with the
-# SDK; also install the file as a template for users to add their
-# own flags if they need to.
-define HOST_MESON_INSTALL_CROSS_CONF
-       mkdir -p $(HOST_DIR)/etc/meson
-       sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-           -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%@HOST_DIR@%$(HOST_DIR)%g" \
-           $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
-           > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
-       sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
-           -e "s%@PKG_TARGET_LDFLAGS@%%g" \
-           -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
-           $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
-           > $(HOST_DIR)/etc/meson/cross-compilation.conf
-endef
-
-TARGET_FINALIZE_HOOKS += HOST_MESON_INSTALL_CROSS_CONF
-
 $(eval $(host-python-package))
index 184a22a44a1c625ea60fde8cdc09ca043d9014af..21895654403111981925f3dd9e2191f6236b3136 100644 (file)
@@ -178,3 +178,32 @@ endef
 
 meson-package = $(call inner-meson-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
 host-meson-package = $(call inner-meson-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
+
+################################################################################
+# Generation of the Meson cross-compilation.conf file
+################################################################################
+
+# Generate a Meson cross-compilation.conf suitable for use with the
+# SDK; also install the file as a template for users to add their
+# own flags if they need to.
+define PKG_MESON_INSTALL_CROSS_CONF
+       mkdir -p $(HOST_DIR)/etc/meson
+       sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
+           -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%@HOST_DIR@%$(HOST_DIR)%g" \
+           $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
+           > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
+       sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
+           -e "s%@PKG_TARGET_LDFLAGS@%%g" \
+           -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
+           $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
+           > $(HOST_DIR)/etc/meson/cross-compilation.conf
+endef
+
+TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += HOST_MESON_INSTALL_CROSS_CONF
+TOOLCHAIN_INSTALL_STAGING = YES