blob: 1549357a554bc05bcfb4c6e9b3b39c7c764c367c [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001include meson.inc
2
3inherit nativesdk
4inherit siteinfo
5
6SRC_URI += "file://meson-setup.py \
7 file://meson-wrapper"
8
9def meson_endian(prefix, d):
10 arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS")
11 sitedata = siteinfo_data_for_machine(arch, os, d)
12 if "endian-little" in sitedata:
13 return "little"
14 elif "endian-big" in sitedata:
15 return "big"
16 else:
17 bb.fatal("Cannot determine endianism for %s-%s" % (arch, os))
18
19MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
20MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
21MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
22MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
23
24# The cross file logic is similar but not identical to that in meson.bbclass,
25# since it's generating for an SDK rather than a cross-compile. Important
26# differences are:
27# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
28# real paths by meson-setup.sh when the SDK is extracted.
29# - Some overrides aren't needed, since the SDK injects paths that take care of
30# them.
31do_install_append() {
32 install -d ${D}${datadir}/meson
33 cat >${D}${datadir}/meson/meson.cross.template <<EOF
34[binaries]
35c = @CC
36cpp = @CXX
37ar = @AR
38nm = @NM
39ld = @LD
40strip = @STRIP
41pkgconfig = 'pkg-config'
42
43[properties]
44needs_exe_wrapper = true
45c_args = @CFLAGS
46c_link_args = @LDFLAGS
47cpp_args = @CPPFLAGS
48cpp_link_args = @LDFLAGS
49
50[host_machine]
51system = '${SDK_OS}'
52cpu_family = '${SDK_ARCH}'
53cpu = '${SDK_ARCH}'
54endian = '${@meson_endian("SDK", d)}'
55EOF
56
57 install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
58 install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
59
60 # We need to wrap the real meson with a thin env setup wrapper.
61 mv ${D}${bindir}/meson ${D}${bindir}/meson.real
62 install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
63}
64
65RDEPENDS_${PN} += "\
66 nativesdk-ninja \
67 nativesdk-python3 \
68 nativesdk-python3-setuptools \
69 "
70
71FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"