summaryrefslogtreecommitdiffstats
path: root/meta/classes/meson.bbclass
diff options
context:
space:
mode:
authorAlexander Kanavin <alexander.kanavin@linux.intel.com>2018-01-04 15:12:30 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-05 11:55:35 +0000
commit0d2020fcffa00cc2464ce80e749fe99b9dfab2a0 (patch)
treea75b4e792e2ea6ab8293a3c9806816cc33ee7878 /meta/classes/meson.bbclass
parentf2b03953b28755277437641645669396f285919a (diff)
downloadpoky-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.bbclass108
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 @@
1inherit python3native
2
3DEPENDS_append = " meson-native ninja-native"
4
5# As Meson enforces out-of-tree builds we can just use cleandirs
6B = "${WORKDIR}/build"
7do_configure[cleandirs] = "${B}"
8
9# Where the meson.build build configuration is
10MESON_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.
15unset CC
16unset CXX
17unset AR
18
19def noprefix(var, d):
20 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
21
22MESONOPTS = " --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
35MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}"
36MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}"
37
38# both are required but not used by meson
39MESON_HOST_ENDIAN = "bogus-endian"
40MESON_TARGET_ENDIAN = "bogus-endian"
41
42EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
43
44MESON_CROSS_FILE = ""
45MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
46
47def meson_array(var, d):
48 return "', '".join(d.getVar(var).split()).join(("'", "'"))
49
50addtask write_config before do_configure
51do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS"
52do_write_config() {
53 # This needs to be Py to split the args into single-element lists
54 cat >${WORKDIR}/meson.cross <<EOF
55[binaries]
56c = '${HOST_PREFIX}gcc'
57cpp = '${HOST_PREFIX}g++'
58ar = '${HOST_PREFIX}ar'
59ld = '${HOST_PREFIX}ld'
60strip = '${HOST_PREFIX}strip'
61readelf = '${HOST_PREFIX}readelf'
62pkgconfig = 'pkg-config'
63
64[properties]
65needs_exe_wrapper = true
66c_args = [${@meson_array('MESON_C_ARGS', d)}]
67c_link_args = [${@meson_array('MESON_LINK_ARGS', d)}]
68cpp_args = [${@meson_array('MESON_C_ARGS', d)}]
69cpp_link_args = [${@meson_array('MESON_LINK_ARGS', d)}]
70gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
71
72[host_machine]
73system = '${HOST_OS}'
74cpu_family = '${HOST_ARCH}'
75cpu = '${HOST_ARCH}'
76endian = '${MESON_HOST_ENDIAN}'
77
78[target_machine]
79system = '${TARGET_OS}'
80cpu_family = '${TARGET_ARCH}'
81cpu = '${TARGET_ARCH}'
82endian = '${MESON_TARGET_ENDIAN}'
83EOF
84}
85
86CONFIGURE_FILES = "meson.build"
87
88meson_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
95meson_do_configure_prepend_class-native() {
96 export PKG_CONFIG="pkg-config-native"
97}
98
99do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
100meson_do_compile() {
101 ninja ${PARALLEL_MAKE}
102}
103
104meson_do_install() {
105 DESTDIR='${D}' ninja ${PARALLEL_MAKEINST} install
106}
107
108EXPORT_FUNCTIONS do_configure do_compile do_install