Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [RFC, WIP] common/build-helper/meson.sh: new build helper, used by meson build style
@ 2023-09-18 19:53 ahesford
  2023-09-18 20:02 ` tornaria
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: ahesford @ 2023-09-18 19:53 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2473 bytes --]

There is a new pull request by ahesford against master on the void-packages repository

https://github.com/ahesford/void-packages meson
https://github.com/void-linux/void-packages/pull/46117

[RFC, WIP] common/build-helper/meson.sh: new build helper, used by meson build style
The `python3-scipy` package now builds with `python3-meson-python`, with some more coming down the pike. The Python build process is necessary to include Python package metadata. For SciPy, this is accomplished by using the `meson` build style to configure a build directory, then overriding `do_build` and `do_install` to build things the PEP517 way (using the pre-configured build directory).

It might be helpful to define a `meson` build helper that can write out the standard cross file for builds, allowing packages like SciPy to use the `python3-pep517` build style with the `meson` helper. There are some issues to be worked out:
1. It seems like the `xbps_meson.cross` is written before `CFLAGS`, *et al.* are properly defined, so this cross file is actually broken. (This is the process by which the `qmake` helper writes its configurations, and they reference `CFLAGS` and others; is the `qmake` helper writing broken configs?)
2. The meson configuration (which would need to happen even with `python3-pep517` plus a `meson` helper) still includes a lot of magic that would have to be brought over to templates. This isn't really easier than the current practice of overriding the one-line `do_build` and `do_install`.

A possible solution would be to define a special-purpose function in the helper, called `vmesoncross` or somesuch, that will only write the configured when called---from a build function where these are properly defined (*e.g.*, `pre_configure`, `do_configure`). We could also define a special `do_configure`-like function in the helper that can be used by the `meson` style to actually do the configuration. This might be a bit ugly, but avoids repetition or violating the typical practice that the actual build functions are only defined in templates or build styles.

A third option is just defining a new `python3-meson` build style that mashes the meson `do_configure` bits from the `meson` style with the `do_build` and `do_install` bits from the `python3-pep517` style.

All of these options are sub-optimal, but I'm not sure which one is least offsensive.

A patch file from https://github.com/void-linux/void-packages/pull/46117.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-meson-46117.patch --]
[-- Type: text/x-diff, Size: 6540 bytes --]

From 3fb3cd93a207ec4f9c5bec3164d454b76e6d7418 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Mon, 18 Sep 2023 15:40:49 -0400
Subject: [PATCH] common/build-helper/meson.sh: new build helper, used by meson
 build style

---
 common/build-helper/meson.sh            | 90 +++++++++++++++++++++++++
 common/build-style/meson.sh             | 85 +----------------------
 common/environment/build-style/meson.sh |  1 +
 3 files changed, 92 insertions(+), 84 deletions(-)
 create mode 100644 common/build-helper/meson.sh

diff --git a/common/build-helper/meson.sh b/common/build-helper/meson.sh
new file mode 100644
index 0000000000000..ca9fb5827dbd7
--- /dev/null
+++ b/common/build-helper/meson.sh
@@ -0,0 +1,90 @@
+# This bulid-helper writes a Meson cross-file, allowing other build styles
+# to properly drive cross-builds in Meson when appropriate
+
+if [ "$CROSS_BUILD" ]; then
+	mkdir -p "${XBPS_WRAPPERDIR}/meson"
+
+	_MESON_TARGET_ENDIAN=little
+	# drop the -musl suffix to the target cpu, meson doesn't recognize it
+	_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
+	case "$XBPS_TARGET_MACHINE" in
+		mips|mips-musl|mipshf-musl)
+			_MESON_TARGET_ENDIAN=big
+			_MESON_CPU_FAMILY=mips
+			;;
+		armv*)
+			_MESON_CPU_FAMILY=arm
+			;;
+		i686*)
+			_MESON_CPU_FAMILY=x86
+			;;
+		ppc64le*)
+			_MESON_CPU_FAMILY=ppc64
+			;;
+		ppc64*)
+			_MESON_TARGET_ENDIAN=big
+			_MESON_CPU_FAMILY=ppc64
+			;;
+		ppcle*)
+			_MESON_CPU_FAMILY=ppc
+			;;
+		ppc*)
+			_MESON_TARGET_ENDIAN=big
+			_MESON_CPU_FAMILY=ppc
+			;;
+		*)
+			# if we reached here that means that the cpu and cpu_family
+			# are the same like 'x86_64' and 'aarch64'
+			_MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
+			;;
+	esac
+
+	_MESON_EXE_WRAPPER=""
+	if [[ $build_helper = *"qemu"* ]]; then
+		_MESON_EXE_WRAPPER="exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'"
+	fi
+
+	# Record cross-compiling information in cross file.
+	# CFLAGS and LDFLAGS must be set as c_args and c_link_args.
+	cat > "${XBPS_WRAPPERDIR}/meson/xbps_meson.cross" <<-EOF
+		[binaries]
+		${_MESON_EXE_WRAPPER}
+		c = '${CC}'
+		cpp = '${CXX}'
+		ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
+		nm = '${NM}'
+		ld = '${LD}'
+		strip = '${STRIP}'
+		readelf = '${READELF}'
+		objcopy = '${OBJCOPY}'
+		pkgconfig = '${PKG_CONFIG}'
+		rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
+		g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
+		g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
+		g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
+		llvm-config = '/usr/bin/llvm-config'
+		cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
+		
+		[properties]
+		needs_exe_wrapper = true
+		
+		[built-in options]
+		c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
+		c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
+		
+		cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
+		cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
+		
+		[host_machine]
+		system = 'linux'
+		cpu_family = '${_MESON_CPU_FAMILY}'
+		cpu = '${_MESON_TARGET_CPU}'
+		endian = '${_MESON_TARGET_ENDIAN}'
+		EOF
+
+	if [[ $build_helper = *"qemu"* ]]; then
+		sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" -i ${meson_crossfile}
+	fi
+
+	unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN _MESON_EXE_WRAPPER
+fi
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index e983c5f42c2f7..5ea2eeda40097 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -1,94 +1,11 @@
 #
 # This helper is for templates using meson.
 #
-do_patch() {
-	: ${meson_crossfile:=xbps_meson.cross}
-
-	if [ "$CROSS_BUILD" ]; then
-		_MESON_TARGET_ENDIAN=little
-		# drop the -musl suffix to the target cpu, meson doesn't recognize it
-		_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
-		case "$XBPS_TARGET_MACHINE" in
-			mips|mips-musl|mipshf-musl)
-				_MESON_TARGET_ENDIAN=big
-				_MESON_CPU_FAMILY=mips
-				;;
-			armv*)
-				_MESON_CPU_FAMILY=arm
-				;;
-			i686*)
-				_MESON_CPU_FAMILY=x86
-				;;
-			ppc64le*)
-				_MESON_CPU_FAMILY=ppc64
-				;;
-			ppc64*)
-				_MESON_TARGET_ENDIAN=big
-				_MESON_CPU_FAMILY=ppc64
-				;;
-			ppcle*)
-				_MESON_CPU_FAMILY=ppc
-				;;
-			ppc*)
-				_MESON_TARGET_ENDIAN=big
-				_MESON_CPU_FAMILY=ppc
-				;;
-			*)
-				# if we reached here that means that the cpu and cpu_family
-				# are the same like 'x86_64' and 'aarch64'
-				_MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
-				;;
-		esac
-
-		# Record cross-compiling information in cross file.
-		# CFLAGS and LDFLAGS must be set as c_args and c_link_args.
-		cat > ${meson_crossfile} <<EOF
-[binaries]
-c = '${CC}'
-cpp = '${CXX}'
-ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
-nm = '${NM}'
-ld = '${LD}'
-strip = '${STRIP}'
-readelf = '${READELF}'
-objcopy = '${OBJCOPY}'
-pkgconfig = '${PKG_CONFIG}'
-rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
-g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
-g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
-g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
-llvm-config = '/usr/bin/llvm-config'
-cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
-
-[properties]
-needs_exe_wrapper = true
-
-[built-in options]
-c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
-c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
-
-cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
-cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
-
-[host_machine]
-system = 'linux'
-cpu_family = '${_MESON_CPU_FAMILY}'
-cpu = '${_MESON_TARGET_CPU}'
-endian = '${_MESON_TARGET_ENDIAN}'
-EOF
-		if [[ $build_helper = *"qemu"* ]]; then
-			sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" \
-				-i ${meson_crossfile}
-		fi
-
-		unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN
-	fi
-}
 
 do_configure() {
 	: ${meson_cmd:=meson}
 	: ${meson_builddir:=build}
-	: ${meson_crossfile:=xbps_meson.cross}
+	: ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
 
 	if [ "$CROSS_BUILD" ]; then
 		configure_args+=" --cross-file=${meson_crossfile}"
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index d5a3c4141f7d9..dbfe93700f691 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1 +1,2 @@
 hostmakedepends+=" meson"
+build_helper+=" meson"

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-09-22 14:17 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 19:53 [PR PATCH] [RFC, WIP] common/build-helper/meson.sh: new build helper, used by meson build style ahesford
2023-09-18 20:02 ` tornaria
2023-09-20  3:25 ` tornaria
2023-09-20 14:46 ` [PR PATCH] [Updated] " ahesford
2023-09-20 14:48 ` ahesford
2023-09-20 14:50 ` ahesford
2023-09-20 14:54 ` ahesford
2023-09-20 15:13 ` [PR PATCH] [Updated] " ahesford
2023-09-20 15:16 ` ahesford
2023-09-20 22:16 ` tornaria
2023-09-21  0:36 ` [RFC] " ahesford
2023-09-21  0:50 ` ahesford
2023-09-21  0:51 ` ahesford
2023-09-21 19:28 ` [PR PATCH] [Updated] " ahesford
2023-09-22 14:17 ` [PR PATCH] [Merged]: " ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).