summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2018-06-04 16:06:02 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-06-07 08:52:55 +0100
commite14171cc594e8c3dfee8119847c26e10b15bacf4 (patch)
treef29803be476eac841f621f140a63d3de5b5b8697 /meta/recipes-devtools
parent2a73be1b0e5adecd29e3dfb3f987d6bc761bc8f3 (diff)
downloadpoky-e14171cc594e8c3dfee8119847c26e10b15bacf4.tar.gz
meson: enable nativesdk
Currently, we can't build meson into SDKs because we don't autogenerate the required meson.cross file. Enable this by using the post-relocate hooks and generating a meson.cross file based on the SDK environment passed into the post-relocate hook. (From OE-Core rev: aabb846b165fec218024a7a57f3c9fdaa2514179) Signed-off-by: Martin Kelly <mkelly@xevo.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/meson/meson.inc22
-rwxr-xr-xmeta/recipes-devtools/meson/meson/meson-setup.py62
-rwxr-xr-xmeta/recipes-devtools/meson/meson/meson-wrapper14
-rw-r--r--meta/recipes-devtools/meson/meson_0.46.1.bb22
-rw-r--r--meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb74
5 files changed, 173 insertions, 21 deletions
diff --git a/meta/recipes-devtools/meson/meson.inc b/meta/recipes-devtools/meson/meson.inc
new file mode 100644
index 0000000000..4c113dcaf7
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson.inc
@@ -0,0 +1,22 @@
1HOMEPAGE = "http://mesonbuild.com"
2SUMMARY = "A high performance build system"
3
4LICENSE = "Apache-2.0"
5LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
6
7SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/meson-${PV}.tar.gz \
8 file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
9 file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
10 file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
11 file://0003-native_bindir.patch \
12 file://0004-Prettifying-some-output-with-pathlib.patch \
13 file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
14 "
15
16SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
17SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
18UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
19
20inherit setuptools3
21
22RDEPENDS_${PN} = "ninja python3-core python3-modules"
diff --git a/meta/recipes-devtools/meson/meson/meson-setup.py b/meta/recipes-devtools/meson/meson/meson-setup.py
new file mode 100755
index 0000000000..a9749eae9d
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/meson-setup.py
@@ -0,0 +1,62 @@
1#!/usr/bin/env python3
2
3import os
4import sys
5
6def bail(msg):
7 print(msg, file=sys.stderr)
8 sys.exit(1)
9
10_MARKER = '@@'
11def transform_line(line):
12 # Substitute any special markers of this form:
13 # @@ENV@@
14 # with the value of ENV, split into meson array syntax.
15 start = line.find(_MARKER)
16 if start == -1:
17 return line
18
19 end = line.rfind(_MARKER)
20 if end == start:
21 return line
22
23 # Lookup value of the env var.
24 var = line[start+len(_MARKER):end]
25 try:
26 val = os.environ[var]
27 except KeyError:
28 bail('cannot generate meson.cross; env var %s not set' % var)
29
30 # Transform into meson array.
31 val = ["'%s'" % x for x in val.split()]
32 val = ', '.join(val)
33 val = '[%s]' % val
34
35 before = line[:start]
36 after = line[end+len(_MARKER):]
37
38 return '%s%s%s' % (before, val, after)
39
40# Make sure this is really an SDK extraction environment.
41try:
42 sysroot = os.environ['OECORE_NATIVE_SYSROOT']
43except KeyError:
44 bail('OECORE_NATIVE_SYSROOT env var must be set')
45
46cross_file = os.path.join(sysroot, 'usr/share/meson/meson.cross')
47tmp_cross_file = '%s.tmp' % cross_file
48
49# Read through and transform the current meson.cross.
50lines = []
51with open(cross_file, 'r') as f:
52 for line in f:
53 lines.append(transform_line(line))
54
55# Write the transformed result to a tmp file and atomically rename it. In case
56# we crash during the file write, we don't want an invalid meson.cross file.
57with open(tmp_cross_file, 'w') as f:
58 for line in lines:
59 f.write(line)
60 f.flush()
61 os.fdatasync(f.fileno())
62os.rename(tmp_cross_file, cross_file)
diff --git a/meta/recipes-devtools/meson/meson/meson-wrapper b/meta/recipes-devtools/meson/meson/meson-wrapper
new file mode 100755
index 0000000000..b2e00da513
--- /dev/null
+++ b/meta/recipes-devtools/meson/meson/meson-wrapper
@@ -0,0 +1,14 @@
1#!/bin/sh
2
3if [ -z "$OECORE_NATIVE_SYSROOT" ]; then
4 echo "OECORE_NATIVE_SYSROOT not set; are you in a Yocto SDK environment?" >&2
5fi
6
7# If these are set to a cross-compile path, meson will get confused and try to
8# use them as native tools. Unset them to prevent this, as all the cross-compile
9# config is already in meson.cross.
10unset CC CXX CPP LD AR NM STRIP
11
12exec "$OECORE_NATIVE_SYSROOT/usr/bin/meson.real" \
13 --cross-file "$OECORE_NATIVE_SYSROOT/usr/share/meson/meson.cross" \
14 "$@"
diff --git a/meta/recipes-devtools/meson/meson_0.46.1.bb b/meta/recipes-devtools/meson/meson_0.46.1.bb
index 77f6416cc2..897fa148d9 100644
--- a/meta/recipes-devtools/meson/meson_0.46.1.bb
+++ b/meta/recipes-devtools/meson/meson_0.46.1.bb
@@ -1,23 +1,3 @@
1HOMEPAGE = "http://mesonbuild.com" 1include meson.inc
2SUMMARY = "A high performance build system"
3
4LICENSE = "Apache-2.0"
5LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
6
7SRC_URI = "https://github.com/mesonbuild/meson/releases/download/${PV}/${BP}.tar.gz \
8 file://0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch \
9 file://0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch \
10 file://0001-Linker-rules-move-cross_args-in-front-of-output_args.patch \
11 file://0003-native_bindir.patch \
12 file://0004-Prettifying-some-output-with-pathlib.patch \
13 file://0005-Set-the-meson-command-to-use-when-we-know-what-it-is.patch \
14 "
15SRC_URI[md5sum] = "1698f6526574839de5dcdc45e3f7d582"
16SRC_URI[sha256sum] = "19497a03e7e5b303d8d11f98789a79aba59b5ad4a81bd00f4d099be0212cee78"
17UPSTREAM_CHECK_URI = "https://github.com/mesonbuild/meson/releases"
18
19inherit setuptools3
20
21RDEPENDS_${PN} = "ninja python3-core python3-modules"
22 2
23BBCLASSEXTEND = "native" 3BBCLASSEXTEND = "native"
diff --git a/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb b/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
new file mode 100644
index 0000000000..53503aa998
--- /dev/null
+++ b/meta/recipes-devtools/meson/nativesdk-meson_0.46.1.bb
@@ -0,0 +1,74 @@
1include 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}"