diff options
author | Alexander Kanavin <alexander.kanavin@linux.intel.com> | 2018-01-04 15:12:30 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-01-05 11:55:35 +0000 |
commit | 0d2020fcffa00cc2464ce80e749fe99b9dfab2a0 (patch) | |
tree | a75b4e792e2ea6ab8293a3c9806816cc33ee7878 /meta/classes/meson.bbclass | |
parent | f2b03953b28755277437641645669396f285919a (diff) | |
download | poky-0d2020fcffa00cc2464ce80e749fe99b9dfab2a0.tar.gz |
meson: add a recipe and class from meta-oe
The original recipe has been provided and improved by:
Ross Burton <ross.burton@intel.com>
Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Adam C. Foltzer <acfoltzer@galois.com>
Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Linus Svensson <linussn@axis.com>
I have added patches to fix up gtk-doc and
gobject-introspection in cross-compilation environments,
and also change the order of linker arguments to replicate
autotools more closely (and fix linking errors in some corner
cases).
(From OE-Core rev: 1f8dea686cdfd6d360ba4a97f62d274c39eaeb8e)
Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/meson.bbclass')
-rw-r--r-- | meta/classes/meson.bbclass | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass new file mode 100644 index 0000000000..5953b5d698 --- /dev/null +++ b/meta/classes/meson.bbclass | |||
@@ -0,0 +1,108 @@ | |||
1 | inherit python3native | ||
2 | |||
3 | DEPENDS_append = " meson-native ninja-native" | ||
4 | |||
5 | # As Meson enforces out-of-tree builds we can just use cleandirs | ||
6 | B = "${WORKDIR}/build" | ||
7 | do_configure[cleandirs] = "${B}" | ||
8 | |||
9 | # Where the meson.build build configuration is | ||
10 | MESON_SOURCEPATH = "${S}" | ||
11 | |||
12 | # These variables in the environment override meson's *native* tools settings. | ||
13 | # We have to unset them, so that meson doesn't pick up the cross tools and | ||
14 | # use them for native builds. | ||
15 | unset CC | ||
16 | unset CXX | ||
17 | unset AR | ||
18 | |||
19 | def noprefix(var, d): | ||
20 | return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) | ||
21 | |||
22 | MESONOPTS = " --prefix ${prefix} \ | ||
23 | --bindir ${@noprefix('bindir', d)} \ | ||
24 | --sbindir ${@noprefix('sbindir', d)} \ | ||
25 | --datadir ${@noprefix('datadir', d)} \ | ||
26 | --libdir ${@noprefix('libdir', d)} \ | ||
27 | --libexecdir ${@noprefix('libexecdir', d)} \ | ||
28 | --includedir ${@noprefix('includedir', d)} \ | ||
29 | --mandir ${@noprefix('mandir', d)} \ | ||
30 | --infodir ${@noprefix('infodir', d)} \ | ||
31 | --sysconfdir ${sysconfdir} \ | ||
32 | --localstatedir ${localstatedir} \ | ||
33 | --sharedstatedir ${sharedstatedir}" | ||
34 | |||
35 | MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}" | ||
36 | MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}" | ||
37 | |||
38 | # both are required but not used by meson | ||
39 | MESON_HOST_ENDIAN = "bogus-endian" | ||
40 | MESON_TARGET_ENDIAN = "bogus-endian" | ||
41 | |||
42 | EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" | ||
43 | |||
44 | MESON_CROSS_FILE = "" | ||
45 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" | ||
46 | |||
47 | def meson_array(var, d): | ||
48 | return "', '".join(d.getVar(var).split()).join(("'", "'")) | ||
49 | |||
50 | addtask write_config before do_configure | ||
51 | do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS" | ||
52 | do_write_config() { | ||
53 | # This needs to be Py to split the args into single-element lists | ||
54 | cat >${WORKDIR}/meson.cross <<EOF | ||
55 | [binaries] | ||
56 | c = '${HOST_PREFIX}gcc' | ||
57 | cpp = '${HOST_PREFIX}g++' | ||
58 | ar = '${HOST_PREFIX}ar' | ||
59 | ld = '${HOST_PREFIX}ld' | ||
60 | strip = '${HOST_PREFIX}strip' | ||
61 | readelf = '${HOST_PREFIX}readelf' | ||
62 | pkgconfig = 'pkg-config' | ||
63 | |||
64 | [properties] | ||
65 | needs_exe_wrapper = true | ||
66 | c_args = [${@meson_array('MESON_C_ARGS', d)}] | ||
67 | c_link_args = [${@meson_array('MESON_LINK_ARGS', d)}] | ||
68 | cpp_args = [${@meson_array('MESON_C_ARGS', d)}] | ||
69 | cpp_link_args = [${@meson_array('MESON_LINK_ARGS', d)}] | ||
70 | gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper' | ||
71 | |||
72 | [host_machine] | ||
73 | system = '${HOST_OS}' | ||
74 | cpu_family = '${HOST_ARCH}' | ||
75 | cpu = '${HOST_ARCH}' | ||
76 | endian = '${MESON_HOST_ENDIAN}' | ||
77 | |||
78 | [target_machine] | ||
79 | system = '${TARGET_OS}' | ||
80 | cpu_family = '${TARGET_ARCH}' | ||
81 | cpu = '${TARGET_ARCH}' | ||
82 | endian = '${MESON_TARGET_ENDIAN}' | ||
83 | EOF | ||
84 | } | ||
85 | |||
86 | CONFIGURE_FILES = "meson.build" | ||
87 | |||
88 | meson_do_configure() { | ||
89 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then | ||
90 | cat ${B}/meson-logs/meson-log.txt | ||
91 | bbfatal_log meson failed | ||
92 | fi | ||
93 | } | ||
94 | |||
95 | meson_do_configure_prepend_class-native() { | ||
96 | export PKG_CONFIG="pkg-config-native" | ||
97 | } | ||
98 | |||
99 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" | ||
100 | meson_do_compile() { | ||
101 | ninja ${PARALLEL_MAKE} | ||
102 | } | ||
103 | |||
104 | meson_do_install() { | ||
105 | DESTDIR='${D}' ninja ${PARALLEL_MAKEINST} install | ||
106 | } | ||
107 | |||
108 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||