blob: 53503aa99884e95ceb04cbcc03ca826229f36954 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001include meson.inc
2
3inherit nativesdk
4
5SRC_URI += "file://meson-setup.py \
6 file://meson-wrapper"
7
8def meson_array(var, d):
9 return "', '".join(d.getVar(var).split()).join(("'", "'"))
10
11# both are required but not used by meson
12MESON_SDK_ENDIAN = "bogus-endian"
13MESON_TARGET_ENDIAN = "bogus-endian"
14
15MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}"
16MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}"
17MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}"
18MESON_LINK_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_LDFLAGS}"
19
20# This logic is similar but not identical to that in meson.bbclass, since it's
21# generating for an SDK rather than a cross-compile. Important differences are:
22# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
23# real paths by meson-setup.sh when the SDK is extracted.
24# - Some overrides aren't needed, since the SDK injects paths that take care of
25# them.
26addtask write_config before do_install
27do_write_config[vardeps] += "MESON_C_ARGS MESON_CPP_ARGS MESON_LINK_ARGS CC CXX LD AR NM STRIP READELF"
28do_write_config() {
29 # This needs to be Py to split the args into single-element lists
30 cat >${WORKDIR}/meson.cross <<EOF
31[binaries]
32c = @@CC@@
33cpp = @@CXX@@
34ar = @@AR@@
35nm = @@NM@@
36ld = @@LD@@
37strip = @@STRIP@@
38pkgconfig = 'pkg-config'
39
40[properties]
41needs_exe_wrapper = true
42c_args = @@CFLAGS@@
43c_link_args = @@LDFLAGS@@
44cpp_args = @@CPPFLAGS@@
45cpp_link_args = @@LDFLAGS@@
46
47[host_machine]
48system = '${SDK_OS}'
49cpu_family = '${SDK_ARCH}'
50cpu = '${SDK_ARCH}'
51endian = '${MESON_SDK_ENDIAN}'
52EOF
53}
54
55do_install_append() {
56 install -d ${D}${datadir}/meson
57 install -m 0644 ${WORKDIR}/meson.cross ${D}${datadir}/meson/
58
59 install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
60 install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
61
62 # We need to wrap the real meson with a thin env setup wrapper.
63 mv ${D}${bindir}/meson ${D}${bindir}/meson.real
64 install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
65}
66
67RDEPENDS_${PN} += "\
68 nativesdk-ninja \
69 nativesdk-python3-core \
70 nativesdk-python3-misc \
71 nativesdk-python3-modules \
72 "
73
74FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}"