clojure-lsp: update to 2024.08.05.
[void-pkg.git] / common / build-helper / meson.sh
blobe414afbfba4bb39c651b74af141d3e55e24037c1
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
20 armv*)
21 _MESON_CPU_FAMILY=arm
23 i686*)
24 _MESON_CPU_FAMILY=x86
26 ppc64le*)
27 _MESON_CPU_FAMILY=ppc64
29 ppc64*)
30 _MESON_TARGET_ENDIAN=big
31 _MESON_CPU_FAMILY=ppc64
33 ppcle*)
34 _MESON_CPU_FAMILY=ppc
36 ppc*)
37 _MESON_TARGET_ENDIAN=big
38 _MESON_CPU_FAMILY=ppc
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}
45 esac
47 # Tell meson to run binaries with qemu if desired
48 _MESON_EXE_WRAPPER=""
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
58 [binaries]
59 ${_MESON_EXE_WRAPPER:-# exe_wrapper is not set}
60 c = '${CC}'
61 cpp = '${CXX}'
62 ar = '${XBPS_CROSS_TRIPLET}-gcc-ar'
63 nm = '${NM}'
64 strip = '${STRIP}'
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'
75 [properties]
76 needs_exe_wrapper = true
77 bindgen_clang_arguments = ['-target', '${XBPS_CROSS_TRIPLET}']
79 [host_machine]
80 system = 'linux'
81 cpu_family = '${_MESON_CPU_FAMILY}'
82 cpu = '${_MESON_TARGET_CPU}'
83 endian = '${_MESON_TARGET_ENDIAN}'
84 EOF
86 unset _MESON_CPU_FAMILY _MESON_TARGET_CPU _MESON_TARGET_ENDIAN _MESON_EXE_WRAPPER