void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

meson.sh (4021B)


      1#
      2# This helper is for templates using meson.
      3#
      4do_patch() {
      5	: ${meson_crossfile:=xbps_meson.cross}
      6
      7	if [ "$CROSS_BUILD" ]; then
      8		_MESON_TARGET_ENDIAN=little
      9		# drop the -musl suffix to the target cpu, meson doesn't recognize it
     10		_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
     11		case "$XBPS_TARGET_MACHINE" in
     12			mips|mips-musl|mipshf-musl)
     13				_MESON_TARGET_ENDIAN=big
     14				_MESON_CPU_FAMILY=mips
     15				;;
     16			armv*)
     17				_MESON_CPU_FAMILY=arm
     18				;;
     19			i686*)
     20				_MESON_CPU_FAMILY=x86
     21				;;
     22			ppc64le*)
     23				_MESON_CPU_FAMILY=ppc64
     24				;;
     25			ppc64*)
     26				_MESON_TARGET_ENDIAN=big
     27				_MESON_CPU_FAMILY=ppc64
     28				;;
     29			ppcle*)
     30				_MESON_CPU_FAMILY=ppc
     31				;;
     32			ppc*)
     33				_MESON_TARGET_ENDIAN=big
     34				_MESON_CPU_FAMILY=ppc
     35				;;
     36			*)
     37				# if we reached here that means that the cpu and cpu_family
     38				# are the same like 'x86_64' and 'aarch64'
     39				_MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
     40				;;
     41		esac
     42
     43		# Record cross-compiling information in cross file.
     44		# CFLAGS and LDFLAGS must be set as c_args and c_link_args.
     45		cat > ${meson_crossfile} <<EOF
     46[binaries]
     47c = '${CC}'
     48cpp = '${CXX}'
     49ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
     50nm = '${NM}'
     51ld = '${LD}'
     52strip = '${STRIP}'
     53readelf = '${READELF}'
     54objcopy = '${OBJCOPY}'
     55pkgconfig = '${PKG_CONFIG}'
     56rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
     57g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
     58g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
     59g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
     60llvm-config = '/usr/bin/llvm-config'
     61cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
     62
     63[properties]
     64needs_exe_wrapper = true
     65
     66[built-in options]
     67c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
     68c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
     69
     70cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
     71cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
     72
     73[host_machine]
     74system = 'linux'
     75cpu_family = '${_MESON_CPU_FAMILY}'
     76cpu = '${_MESON_TARGET_CPU}'
     77endian = '${_MESON_TARGET_ENDIAN}'
     78EOF
     79		if [[ $build_helper = *"qemu"* ]]; then
     80			sed -e "/\[binaries\]/ a exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'" \
     81				-i ${meson_crossfile}
     82		fi
     83
     84		unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN
     85	fi
     86}
     87
     88do_configure() {
     89	: ${meson_cmd:=meson}
     90	: ${meson_builddir:=build}
     91	: ${meson_crossfile:=xbps_meson.cross}
     92
     93	if [ "$CROSS_BUILD" ]; then
     94		configure_args+=" --cross-file=${meson_crossfile}"
     95	fi
     96
     97	# binutils ar needs a plugin when LTO is used on static libraries, so we
     98	# have to use the gcc-ar wrapper that calls the correct plugin.
     99	# As seen in https://github.com/mesonbuild/meson/issues/1646 (and its
    100	# solution, https://github.com/mesonbuild/meson/pull/1649), meson fixed
    101	# issues with static libraries + LTO by defaulting to gcc-ar themselves.
    102	# We also force gcc-ar usage in the crossfile above.
    103	export AR="gcc-ar"
    104
    105	${meson_cmd} \
    106		--prefix=/usr \
    107		--libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
    108		--libexecdir=/usr/libexec \
    109		--bindir=/usr/bin \
    110		--sbindir=/usr/bin \
    111		--includedir=/usr/include \
    112		--datadir=/usr/share \
    113		--mandir=/usr/share/man \
    114		--infodir=/usr/share/info \
    115		--localedir=/usr/share/locale \
    116		--sysconfdir=/etc \
    117		--localstatedir=/var \
    118		--sharedstatedir=/var/lib \
    119		--buildtype=plain \
    120		--auto-features=auto \
    121		--wrap-mode=nodownload \
    122		-Db_lto=true -Db_ndebug=true \
    123		-Db_staticpic=true \
    124		${configure_args} . ${meson_builddir}
    125}
    126
    127do_build() {
    128	: ${make_cmd:=ninja}
    129	: ${make_build_target:=all}
    130	: ${meson_builddir:=build}
    131
    132	${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target}
    133}
    134
    135do_check() {
    136	: ${make_cmd:=ninja}
    137	: ${make_check_target:=test}
    138	: ${meson_builddir:=build}
    139
    140	${make_cmd} -C ${meson_builddir} ${makejobs} ${make_check_args} ${make_check_target}
    141}
    142
    143do_install() {
    144	: ${make_cmd:=ninja}
    145	: ${make_install_target:=install}
    146	: ${meson_builddir:=build}
    147
    148	DESTDIR=${DESTDIR} ${make_cmd} -C ${meson_builddir} ${make_install_args} ${make_install_target}
    149}