Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | include meson.inc |
| 2 | |
| 3 | inherit nativesdk |
| 4 | inherit siteinfo |
| 5 | |
| 6 | SRC_URI += "file://meson-setup.py \ |
| 7 | file://meson-wrapper" |
| 8 | |
| 9 | def 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 | |
| 19 | MESON_TOOLCHAIN_ARGS = "${BUILDSDK_CC_ARCH}${TOOLCHAIN_OPTIONS}" |
| 20 | MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CFLAGS}" |
| 21 | MESON_CPP_ARGS = "${MESON_TOOLCHAIN_ARGS} ${BUILDSDK_CXXFLAGS}" |
| 22 | MESON_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. |
| 31 | do_install_append() { |
| 32 | install -d ${D}${datadir}/meson |
| 33 | cat >${D}${datadir}/meson/meson.cross.template <<EOF |
| 34 | [binaries] |
| 35 | c = @CC |
| 36 | cpp = @CXX |
| 37 | ar = @AR |
| 38 | nm = @NM |
| 39 | ld = @LD |
| 40 | strip = @STRIP |
| 41 | pkgconfig = 'pkg-config' |
| 42 | |
| 43 | [properties] |
| 44 | needs_exe_wrapper = true |
| 45 | c_args = @CFLAGS |
| 46 | c_link_args = @LDFLAGS |
| 47 | cpp_args = @CPPFLAGS |
| 48 | cpp_link_args = @LDFLAGS |
| 49 | |
| 50 | [host_machine] |
| 51 | system = '${SDK_OS}' |
| 52 | cpu_family = '${SDK_ARCH}' |
| 53 | cpu = '${SDK_ARCH}' |
| 54 | endian = '${@meson_endian("SDK", d)}' |
| 55 | EOF |
| 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 | |
| 65 | RDEPENDS_${PN} += "\ |
| 66 | nativesdk-ninja \ |
| 67 | nativesdk-python3 \ |
| 68 | nativesdk-python3-setuptools \ |
| 69 | " |
| 70 | |
| 71 | FILES_${PN} += "${datadir}/meson ${SDKPATHNATIVE}" |