From 8cd6e8ef00680341dd65678e22952bb115aa2e03 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Mon, 18 Sep 2023 15:40:49 -0400 Subject: [PATCH 1/2] common/build-helper/meson.sh: new build helper, used by meson build style --- common/build-helper/meson.sh | 82 ++++++++++++++++++++++++ common/build-style/meson.sh | 85 +------------------------ common/environment/build-style/meson.sh | 1 + 3 files changed, 84 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..1933306c18a4b --- /dev/null +++ b/common/build-helper/meson.sh @@ -0,0 +1,82 @@ +# 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 + + # Tell meson to run binaries with qemu if desired + _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, CXXFLAGS and LDFLAGS are not yet available and + # will be taken from the environment at configure time. + cat > "${XBPS_WRAPPERDIR}/meson/xbps_meson.cross" <<-EOF + [binaries] + ${_MESON_EXE_WRAPPER:-# exe_wrapper is not set} + 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 + + [host_machine] + system = 'linux' + cpu_family = '${_MESON_CPU_FAMILY}' + cpu = '${_MESON_TARGET_CPU}' + endian = '${_MESON_TARGET_ENDIAN}' + EOF + + 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} < Date: Wed, 20 Sep 2023 10:45:43 -0400 Subject: [PATCH 2/2] python3-scipy: use new meson helper --- srcpkgs/python3-scipy/template | 47 ++++++++++++++++------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/srcpkgs/python3-scipy/template b/srcpkgs/python3-scipy/template index ba0dd761cdcf5..e99919babf3bf 100644 --- a/srcpkgs/python3-scipy/template +++ b/srcpkgs/python3-scipy/template @@ -2,9 +2,10 @@ pkgname=python3-scipy version=1.11.2 revision=1 -build_style=meson -build_helper="python3" -configure_args="$(vopt_if openblas "" "-Dblas=blas -Dlapack=lapack")" +build_style=python3-pep517 +build_helper="meson" +make_build_args="--no-isolation --wheel + $(vopt_if openblas "" "-Csetup-args=-Dblas=blas -Csetup-args=-Dlapack=lapack")" hostmakedepends="python3-build python3-installer python3-meson-python python3-wheel python3-Cython python3-pybind11 pythran python3-numpy gcc-fortran pkg-config" @@ -22,8 +23,12 @@ make_check="no" # Tests need an installed copy to run and meson makes this tough build_options="openblas" if [ "$CROSS_BUILD" ]; then + make_build_args+=" + -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/xbps_meson.cross + -Csetup-args=--cross-file=${XBPS_WRAPPERDIR}/meson/python.cross + " + _pybind11_dir="${py3_sitelib}/pybind11" - configure_args+=" --cross-file=python.cross" export PKG_CONFIG_PATH="${XBPS_CROSS_BASE}/${_pybind11_dir}/share/pkgconfig" # pybind11 uses a path relative to the pkgconfig file to set $prefix, # which causes the wrapper to double-include $XBPS_CROSS_BASE; override @@ -46,34 +51,26 @@ if [ "$build_option_openblas" ]; then esac fi -pre_patch() { - if [ "${CROSS_BUILD}" ]; then - # Meson can't tolerate $CC with arguments as set by the build helper - CC="${XBPS_CROSS_TRIPLET}-gcc" - # CXX needs to know where to find Python headers - CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}" - fi -} - post_patch() { if [ "$CROSS_BUILD" ]; then local _xpy="${XBPS_CROSS_BASE}/${py3_sitelib}" - cat > python.cross <<-EOF - [properties] - numpy-include-dir = '${_xpy}/numpy/core/include' - pythran-include-dir = '${_xpy}/pythran' - EOF + cat > "${XBPS_WRAPPERDIR}/meson/python.cross" <<-EOF + [properties] + numpy-include-dir = '${_xpy}/numpy/core/include' + pythran-include-dir = '${_xpy}/pythran' + EOF fi } -do_build() { - # Use the build directory already configured by xbps-src for meson - python3 -m build --no-isolation --wheel \ - -Cbuilddir="./build" -Ccompile-args="${makejobs}" . +pre_build() { + if [ "$CROSS_BUILD" ]; then + # Meson can't tolerate $CC with arguments as set by the build helper + CC="${XBPS_CROSS_TRIPLET}-gcc" + # CXX needs to know where to find Python headers + CXXFLAGS+=" -I${XBPS_CROSS_BASE}/${py3_inc}" + fi } -do_install() { - python3 -m installer --destdir "${DESTDIR}" \ - --no-compile-bytecode dist/*.whl +post_install() { vlicense LICENSE.txt }