1 # This build helper writes a Meson cross-file, allowing other build styles
2 # to properly drive cross-builds in Meson when appropriate
4 # Action is only taken for cross builds
5 [ -z "$CROSS_BUILD" ] && return 0
7 # The cross file should only be written once, unless forced
8 [ -e "${XBPS_WRAPPERDIR}/meson/xbps_meson.cross" ] && [ -z "$XBPS_BUILD_FORCEMODE" ] && return 0
10 mkdir
-p "${XBPS_WRAPPERDIR}/meson"
12 _MESON_TARGET_ENDIAN
=little
13 # drop the -musl suffix to the target cpu, meson doesn't recognize it
14 _MESON_TARGET_CPU
=${XBPS_TARGET_MACHINE/-musl/}
15 case "$XBPS_TARGET_MACHINE" in
16 mips|mips-musl|mipshf-musl
)
17 _MESON_TARGET_ENDIAN
=big
18 _MESON_CPU_FAMILY
=mips
27 _MESON_CPU_FAMILY
=ppc64
30 _MESON_TARGET_ENDIAN
=big
31 _MESON_CPU_FAMILY
=ppc64
37 _MESON_TARGET_ENDIAN
=big
41 # if we reached here that means that the cpu and cpu_family
42 # are the same like 'x86_64' and 'aarch64'
43 _MESON_CPU_FAMILY
=${_MESON_TARGET_CPU}
47 # Tell meson to run binaries with qemu if desired
49 if [[ "${build_helper}" = *qemu
* ]]; then
50 _MESON_EXE_WRAPPER
="exe_wrapper = '/usr/bin/qemu-${XBPS_TARGET_QEMU_MACHINE}-static'"
53 # Record cross-compiling information in cross file.
55 # CFLAGS, CXXFLAGS and LDFLAGS are not yet available and
56 # will be taken from the environment at configure time.
57 cat > "${XBPS_WRAPPERDIR}/meson/xbps_meson.cross" <<-EOF
59 ${_MESON_EXE_WRAPPER:-# exe_wrapper is not set}
62 ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
65 readelf = '${READELF}'
66 objcopy = '${OBJCOPY}'
67 pkg-config = '${PKG_CONFIG}'
68 rust = ['rustc', '--target', '${RUST_TARGET}' ,'--sysroot', '${XBPS_CROSS_BASE}/usr']
69 g-ir-scanner = '${XBPS_CROSS_BASE}/usr/bin/g-ir-scanner'
70 g-ir-compiler = '${XBPS_CROSS_BASE}/usr/bin/g-ir-compiler'
71 g-ir-generate = '${XBPS_CROSS_BASE}/usr/bin/g-ir-generate'
72 llvm-config = '/usr/bin/llvm-config'
73 cups-config = '${XBPS_CROSS_BASE}/usr/bin/cups-config'
76 needs_exe_wrapper = true
77 bindgen_clang_arguments = ['-target', '${XBPS_CROSS_TRIPLET}']
81 cpu_family = '${_MESON_CPU_FAMILY}'
82 cpu = '${_MESON_TARGET_CPU}'
83 endian = '${_MESON_TARGET_ENDIAN}'
86 unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN _MESON_EXE_WRAPPER