Skip to contentSkip to conversation

allow build infrastructure to pick up installed meson tool

PATCH New Norbert Lange 2 participants 6 messages May 8, 2019 – Oct 4, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover allow build infrastructure to pick up installed meson tool

This is V2 of the patchset. The purpose is to allow meson/ninja dependencies to be optionally resolved to the system installed version.

This wont be fully accepted, thanks to meson missing patches upstream, the patches default to disable this functionality.

V2 includes 2 more cleanup-patches, a rebase and default to never use the system installed tools.

users can force the use of the system installed tools, by overriding variables:

make graph-depends BR2_MESON_VERSION_MIN=0 BR2_NINJA_VERSION_MIN=0

Norbert Lange (4):
package/pkg-meson: move crosscompilation support out of package prepare build infrastructure to pick up installed meson tool prepare build infrastructure to pick up installed ninja tool support/dependencies: use a helper script for common checks

 package/meson/meson.mk                        | 55 ---------------
 package/pkg-meson.mk                          | 70 +++++++++++++++----
 support/dependencies/check-host-cmake.sh      | 47 ++-----------
 support/dependencies/check-host-make.sh       | 39 ++---------
 support/dependencies/check-host-meson.mk      | 15 ++++
 support/dependencies/check-host-meson.sh      |  5 ++
 support/dependencies/check-host-ninja.mk      | 13 ++++
 support/dependencies/check-host-ninja.sh      |  5 ++
 support/dependencies/versioncheck.sh          | 45 ++++++++++++
 .../misc}/cross-compilation.conf.in           |  0
 10 files changed, 149 insertions(+), 145 deletions(-)
 create mode 100644 support/dependencies/check-host-meson.mk
 create mode 100755 support/dependencies/check-host-meson.sh
 create mode 100644 support/dependencies/check-host-ninja.mk
 create mode 100755 support/dependencies/check-host-ninja.sh
 create mode 100755 support/dependencies/versioncheck.sh
 rename {package/meson => support/misc}/cross-compilation.conf.in (100%)

--
2.20.1

#1 lore raw

PATCH v2 1/4 package/pkg-meson: move crosscompilation support out of package

From: Norbert Lange <[email protected]>

install the cross-compilation.conf file when setting up the staging area, not as part of host-meson.
This allows external usage of the buildroot toolchain through meson.

Remove a few variables, as they were only used to communicate between meson package and pkg-meson.

---
 package/meson/meson.mk                        | 54 ----------------
 package/pkg-meson.mk                          | 64 +++++++++++++++----
 .../misc}/cross-compilation.conf.in           |  0
 3 files changed, 53 insertions(+), 65 deletions(-)
 rename {package/meson => support/misc}/cross-compilation.conf.in (100%)
package/meson/meson.mk +0 -54
index cf62b0ddde..12cadb2856 100644
@@ -13,58 +13,4 @@ MESON_SETUP_TYPE = setuptools
 HOST_MESON_DEPENDENCIES = host-ninja
 HOST_MESON_NEEDS_HOST_PYTHON = python3
 
-HOST_MESON_TARGET_ENDIAN = $(call LOWERCASE,$(BR2_ENDIAN))
-HOST_MESON_TARGET_CPU = $(GCC_TARGET_CPU)
-
-# https://mesonbuild.com/Reference-tables.html#cpu-families
-ifeq ($(BR2_arcle)$(BR2_arceb),y)
-HOST_MESON_TARGET_CPU_FAMILY = arc
-else ifeq ($(BR2_arm)$(BR2_armeb),y)
-HOST_MESON_TARGET_CPU_FAMILY = arm
-else ifeq ($(BR2_aarch64)$(BR2_aarch64_be),y)
-HOST_MESON_TARGET_CPU_FAMILY = aarch64
-else ifeq ($(BR2_i386),y)
-HOST_MESON_TARGET_CPU_FAMILY = x86
-else ifeq ($(BR2_mips)$(BR2_mipsel),y)
-HOST_MESON_TARGET_CPU_FAMILY = mips
-else ifeq ($(BR2_mips64)$(BR2_mips64el),y)
-HOST_MESON_TARGET_CPU_FAMILY = mips64
-else ifeq ($(BR2_powerpc),y)
-HOST_MESON_TARGET_CPU_FAMILY = ppc
-else ifeq ($(BR2_powerpc64)$(BR2_powerpc64le),y)
-HOST_MESON_TARGET_CPU_FAMILY = ppc64
-else ifeq ($(BR2_riscv),y)
-HOST_MESON_TARGET_CPU_FAMILY = riscv64
-else ifeq ($(BR2_sparc),y)
-HOST_MESON_TARGET_CPU_FAMILY = sparc
-else ifeq ($(BR2_sparc64),y)
-HOST_MESON_TARGET_CPU_FAMILY = sparc64
-else ifeq ($(BR2_x86_64),y)
-HOST_MESON_TARGET_CPU_FAMILY = x86_64
-else
-HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
-endif
-
-HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
-HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
-HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
-
-# Generate a Meson cross-compilation.conf suitable for use with the
-# SDK
-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)%g" \
-	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
-	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%g" \
-	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
-	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
-	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
-endef
-
-TARGET_FINALIZE_HOOKS += HOST_MESON_INSTALL_CROSS_CONF
-
 $(eval $(host-python-package))
package/pkg-meson.mk +53 -11

78 lines not on this page · raw message

support/misc/cross-compilation.conf.in renamed from package/meson/cross-compilation.conf.in +0 -0
similarity index 100%
rename from package/meson/cross-compilation.conf.in
rename to support/misc/cross-compilation.conf.in
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 1/4 package/pkg-meson: move crosscompilation support out of package

Am Wed, 08 May 2019 13:02:25 +0200 schrieb Norbert Lange:

Quoted 2 lines

From: Norbert Lange
<[email protected]>

Hi,

this patch needs a rebase.

Regards, Bernd

#3 lore raw

PATCH v2 2/4 prepare build infrastructure to pick up installed meson tool

In reply to Norbert Lange

From: Norbert Lange <[email protected]>

Automatically check for an available meson tool,
and use it as long as the version is fitting.

Using a system provided meson is not an official supported option, hence this is currently disabled.
use of the system provided meson can be enforced with:

make ... BR2_MESON_VERSION_MIN=0

---
 package/pkg-meson.mk                     |  4 +--
 support/dependencies/check-host-meson.mk | 15 ++++++++
 support/dependencies/check-host-meson.sh | 45 ++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 2 deletions(-)
 create mode 100644 support/dependencies/check-host-meson.mk
 create mode 100755 support/dependencies/check-host-meson.sh
package/pkg-meson.mk +2 -2
index 5487ee2c11..157ccde446 100644
@@ -25,7 +25,7 @@
 # $(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
+MESON		= PYTHONNOUSERSITE=y $(BR2_MESON)
 NINJA		= PYTHONNOUSERSITE=y $(HOST_DIR)/bin/ninja
 NINJA_OPTS	= $(if $(VERBOSE),-v) -j$(PARALLEL_JOBS)
 
@@ -92,7 +92,7 @@ endef
 endif
 endif
 
-$(2)_DEPENDENCIES += host-meson
+$(2)_DEPENDENCIES += $(BR2_MESON_HOST_DEPENDENCY)
 
 #
 # Build step. Only define it if not already defined by the package .mk
support/dependencies/check-host-meson.mk new file +15 -0
new file mode 100644
index 0000000000..fbe0b7d7aa
@@ -0,0 +1,15 @@
+# Set this to a valid version like  0.49, depending on the highest minimum
+# version required by any of the packages bundled in Buildroot.
+# An empty version will never match a system executable
+#
+# BR2_MESON_VERSION_MIN = 0.49
+
+BR2_MESON_CANDIDATES ?= meson
+BR2_MESON ?= $(call suitable-host-package,meson,\
+	$(BR2_MESON_VERSION_MIN) $(BR2_MESON_CANDIDATES))
+ifeq ($(BR2_MESON),)
+BR2_MESON = $(HOST_DIR)/bin/meson
+BR2_MESON_HOST_DEPENDENCY = host-meson host-ninja
+else
+BR2_MESON_HOST_DEPENDENCY = host-ninja
+endif
support/dependencies/check-host-meson.sh new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 3/4 prepare build infrastructure to pick up installed ninja tool

In reply to Norbert Lange

From: Norbert Lange <[email protected]>

The only notable use is as dependency from meson, since using the system installed meson is not officially supported, netiher is using a system installed ninja.

a user can force the use of the system installed ninja with

make graph-depends BR2_NINJA_VERSION_MIN=0

---
 package/meson/meson.mk                   |  1 -
 package/pkg-meson.mk                     |  2 +-
 support/dependencies/check-host-meson.mk |  4 +--
 support/dependencies/check-host-ninja.mk | 13 +++++++
 support/dependencies/check-host-ninja.sh | 45 ++++++++++++++++++++++++
 5 files changed, 61 insertions(+), 4 deletions(-)
 create mode 100644 support/dependencies/check-host-ninja.mk
 create mode 100755 support/dependencies/check-host-ninja.sh
package/meson/meson.mk +0 -1
index 12cadb2856..e0585d228c 100644
@@ -10,7 +10,6 @@ MESON_LICENSE = Apache-2.0
 MESON_LICENSE_FILES = COPYING
 MESON_SETUP_TYPE = setuptools
 
-HOST_MESON_DEPENDENCIES = host-ninja
 HOST_MESON_NEEDS_HOST_PYTHON = python3
 
 $(eval $(host-python-package))
package/pkg-meson.mk +1 -1
index 157ccde446..6adda743e4 100644
@@ -26,7 +26,7 @@
 # $HOME/.local/lib/python3.x/site-packages
 #
 MESON		= PYTHONNOUSERSITE=y $(BR2_MESON)
-NINJA		= PYTHONNOUSERSITE=y $(HOST_DIR)/bin/ninja
+NINJA		= PYTHONNOUSERSITE=y $(BR2_NINJA)
 NINJA_OPTS	= $(if $(VERBOSE),-v) -j$(PARALLEL_JOBS)
 
 ################################################################################
support/dependencies/check-host-meson.mk +2 -2
index fbe0b7d7aa..fb07bea792 100644
@@ -9,7 +9,7 @@ BR2_MESON ?= $(call suitable-host-package,meson,\
 	$(BR2_MESON_VERSION_MIN) $(BR2_MESON_CANDIDATES))
 ifeq ($(BR2_MESON),)
 BR2_MESON = $(HOST_DIR)/bin/meson
-BR2_MESON_HOST_DEPENDENCY = host-meson host-ninja
+BR2_MESON_HOST_DEPENDENCY = host-meson $(BR2_NINJA_HOST_DEPENDENCY)
 else
-BR2_MESON_HOST_DEPENDENCY = host-ninja
+BR2_MESON_HOST_DEPENDENCY = $(BR2_NINJA_HOST_DEPENDENCY)
 endif
support/dependencies/check-host-ninja.mk new file +13 -0
new file mode 100644
index 0000000000..09ee45ef1e
@@ -0,0 +1,13 @@
+# Set this to a valid version like 1.8.2, depending on the highest
+# minimum version required by any of the packages bundled in Buildroot.
+# An empty version will never match a system executable
+#
+# BR2_NINJA_VERSION_MIN = 1.8.2
+
+BR2_NINJA_CANDIDATES ?= ninja
+BR2_NINJA ?= $(call suitable-host-package,ninja,\
+	$(BR2_NINJA_VERSION_MIN) $(BR2_NINJA_CANDIDATES))
+ifeq ($(BR2_NINJA),)
+BR2_NINJA = $(HOST_DIR)/bin/ninja
+BR2_NINJA_HOST_DEPENDENCY = host-ninja
+endif
support/dependencies/check-host-ninja.sh new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.20.1
#5 lore raw

PATCH v2 4/4 support/dependencies: use a helper script for common checks

In reply to Norbert Lange
---
 support/dependencies/check-host-cmake.sh | 47 +++---------------------
 support/dependencies/check-host-make.sh  | 39 +++-----------------
 support/dependencies/check-host-meson.sh | 44 +---------------------
 support/dependencies/check-host-ninja.sh | 44 +---------------------
 support/dependencies/versioncheck.sh     | 45 +++++++++++++++++++++++
 5 files changed, 59 insertions(+), 160 deletions(-)
 create mode 100755 support/dependencies/versioncheck.sh
support/dependencies/check-host-cmake.sh +5 -42
index fadeae9f6b..0699ddf571 100755
@@ -1,45 +1,8 @@
 #!/bin/sh
 
-# prevent shift error
-[ $# -lt 2 ] && exit 1
+readversion() {
+	"$1" --version |
+		sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' -e 's//\1/'
+}
 
-major_min="${1%.*}"
-minor_min="${1#*.}"
-
-shift
-
-for candidate; do
-
-    # Try to locate the candidate. Discard it if not located.
-    cmake=`which "${candidate}" 2>/dev/null`
-    [ -n "${cmake}" ] || continue
-
-    # Extract version X.Y from versions in the form X.Y or X.Y.Z
-    # with X, Y and Z numbers with one or more digits each, e.g.
-    #   3.2     -> 3.2
-    #   3.2.3   -> 3.2
-    #   3.2.42  -> 3.2
-    #   3.10    -> 3.10
-    #   3.10.4  -> 3.10
-    #   3.10.42 -> 3.10
-    # Discard the candidate if no version can be obtained
-    version="$(${cmake} --version \
-               |sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' \
-                       -e 's//\1/'
-              )"
-    [ -n "${version}" ] || continue
-
-    major="${version%.*}"
-    minor="${version#*.}"
-
-    if [ ${major} -gt ${major_min} ]; then
-        echo "${cmake}"
-        exit
-    elif [ ${major} -eq ${major_min} -a ${minor} -ge ${minor_min} ]; then
-        echo "${cmake}"
-        exit
-    fi
-done
-
-# echo nothing: no suitable cmake found
-exit 1
+. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh
support/dependencies/check-host-make.sh +5 -34
index 0de7e9f6fa..77bfc5123d 100755
@@ -1,37 +1,8 @@
 #!/bin/sh
 
-# prevent shift error
-[ $# -lt 2 ] && exit 1
+readversion() {
+	"$1" --version 2>&1 |
+		sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-].*//g' -e '1q'
+}
 
-major_min="${1%.*}"
-minor_min="${1#*.}"
-
-shift
-
-# The host make program is already checked by dependencies.sh but we
-# want to check the version number even if Buildroot is able to use
-# GNU make >= 3.81 but some packages may require a more recent version.
-make="$1"
-
-# Output of 'make --version' examples:
-# GNU Make 4.2.1
-# GNU Make 4.0
-# GNU Make 3.81
-version=`$make --version 2>&1 | sed -e 's/^.* \([0-9\.]\)/\1/g' -e 's/[-\
-].*//g' -e '1q'`
-
-major=`echo "$version" | cut -d. -f1`
-minor=`echo "$version" | cut -d. -f2`
-
-if [ $major -lt $major_min ]; then
-	# echo nothing: no suitable make found
-	exit 1
-fi
-
-if [ $major -eq $major_min -a $minor -lt $minor_min ]; then
-	# echo nothing: no suitable make found
-	exit 1
-fi
-
-# valid
-echo $make
+. "$(dirname "$(readlink -e "$0")")"/versioncheck.sh
support/dependencies/check-host-meson.sh +2 -42

47 lines not on this page · raw message

support/dependencies/check-host-ninja.sh +2 -42

47 lines not on this page · raw message

support/dependencies/versioncheck.sh new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.20.1