diff options
| author | Linus Svensson <linussn@axis.com> | 2017-02-16 12:53:59 +0100 |
|---|---|---|
| committer | Martin Jansa <Martin.Jansa@gmail.com> | 2017-02-20 11:50:12 +0100 |
| commit | c4445538f86929f2cb90f1c2fb42be1aa97911fc (patch) | |
| tree | 617cd8ecf70227a7ee03980323edbded4dd5c94e | |
| parent | b8f6712bd98569df432d4e8eeb34a4182902a5b5 (diff) | |
| download | meta-openembedded-c4445538f86929f2cb90f1c2fb42be1aa97911fc.tar.gz | |
meson.bbclass: Add meson.bbclass
Add a class for packages that uses the meson build system.
Meson uses a cross-file that contain needed tools and information about
the host and target system. Such a file will be created in {WORKDIR}.
Meson only allows installation directories to be specified as relative
to prefix, except for sysconfdir, which can be absolute.
This patch is based on a prototype patch by
Ross Burton <ross.burton@intel.com>.
Signed-off-by: Linus Svensson <linussn@axis.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
| -rw-r--r-- | meta-oe/classes/meson.bbclass | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/meta-oe/classes/meson.bbclass b/meta-oe/classes/meson.bbclass new file mode 100644 index 0000000000..5a04134f05 --- /dev/null +++ b/meta-oe/classes/meson.bbclass | |||
| @@ -0,0 +1,86 @@ | |||
| 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 the *native* tools not the cross, | ||
| 13 | # so they need to be unexported. | ||
| 14 | CC[unexport] = "1" | ||
| 15 | |||
| 16 | def noprefix(var, d): | ||
| 17 | return d.getVar(var, True).replace(d.getVar('prefix', True) + '/', '', 1) | ||
| 18 | |||
| 19 | MESONOPTS = " --prefix ${prefix} \ | ||
| 20 | --bindir ${@noprefix('bindir', d)} \ | ||
| 21 | --datadir ${@noprefix('datadir', d)} \ | ||
| 22 | --libdir ${@noprefix('libdir', d)} \ | ||
| 23 | --libexecdir ${@noprefix('libexecdir', d)} \ | ||
| 24 | --includedir ${@noprefix('includedir', d)} \ | ||
| 25 | --mandir ${@noprefix('mandir', d)} \ | ||
| 26 | --localedir ${@noprefix('localedir', d)} \ | ||
| 27 | --sysconfdir ${sysconfdir}" | ||
| 28 | |||
| 29 | MESON_C_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" | ||
| 30 | |||
| 31 | MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be', 'big', 'little', d)}" | ||
| 32 | MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 'big', 'little', d)}" | ||
| 33 | |||
| 34 | EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" | ||
| 35 | |||
| 36 | def meson_array(var, d): | ||
| 37 | return "', '".join(d.getVar(var, True).split()).join(("'", "'")) | ||
| 38 | |||
| 39 | addtask write_config before do_configure | ||
| 40 | do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS" | ||
| 41 | do_write_config() { | ||
| 42 | # This needs to be Py to split the args into single-element lists | ||
| 43 | cat >${WORKDIR}/meson.cross <<EOF | ||
| 44 | [binaries] | ||
| 45 | c = '${HOST_PREFIX}gcc' | ||
| 46 | cpp = '${HOST_PREFIX}gcc' | ||
| 47 | ar = '${HOST_PREFIX}ar' | ||
| 48 | ld = '${HOST_PREFIX}ld' | ||
| 49 | strip = '${HOST_PREFIX}strip' | ||
| 50 | readelf = '${HOST_PREFIX}readelf' | ||
| 51 | pkgconfig = 'pkg-config' | ||
| 52 | |||
| 53 | [properties] | ||
| 54 | c_args = [${@meson_array('MESON_C_ARGS', d)}] | ||
| 55 | c_link_args = [${@meson_array('TOOLCHAIN_OPTIONS', d)}] | ||
| 56 | |||
| 57 | [host_machine] | ||
| 58 | system = '${HOST_OS}' | ||
| 59 | cpu_family = '${HOST_ARCH}' | ||
| 60 | cpu = '${HOST_ARCH}' | ||
| 61 | endian = '${MESON_HOST_ENDIAN}' | ||
| 62 | |||
| 63 | [target_machine] | ||
| 64 | system = '${TARGET_OS}' | ||
| 65 | cpu_family = '${TARGET_ARCH}' | ||
| 66 | cpu = '${TARGET_ARCH}' | ||
| 67 | endian = '${MESON_TARGET_ENDIAN}' | ||
| 68 | EOF | ||
| 69 | } | ||
| 70 | |||
| 71 | meson_do_configure() { | ||
| 72 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" --cross-file ${WORKDIR}/meson.cross ${EXTRA_OEMESON}; then | ||
| 73 | cat ${B}/meson-logs/meson-log.txt | ||
| 74 | bbfatal_log meson failed | ||
| 75 | fi | ||
| 76 | } | ||
| 77 | |||
| 78 | meson_do_compile() { | ||
| 79 | ninja ${PARALLEL_MAKE} | ||
| 80 | } | ||
| 81 | |||
| 82 | meson_do_install() { | ||
| 83 | DESTDIR='${D}' ninja ${PARALLEL_MAKEINST} install | ||
| 84 | } | ||
| 85 | |||
| 86 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||
