Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame^] | 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 | export CC = "${BUILD_CC}" |
| 14 | export CXX = "${BUILD_CXX}" |
| 15 | export LD = "${BUILD_LD}" |
| 16 | export AR = "${BUILD_AR}" |
| 17 | |
| 18 | def noprefix(var, d): |
| 19 | return d.getVar(var, True).replace(d.getVar('prefix', True) + '/', '', 1) |
| 20 | |
| 21 | MESONOPTS = " --prefix ${prefix} \ |
| 22 | --bindir ${@noprefix('bindir', d)} \ |
| 23 | --sbindir ${@noprefix('sbindir', d)} \ |
| 24 | --datadir ${@noprefix('datadir', d)} \ |
| 25 | --libdir ${@noprefix('libdir', d)} \ |
| 26 | --libexecdir ${@noprefix('libexecdir', d)} \ |
| 27 | --includedir ${@noprefix('includedir', d)} \ |
| 28 | --mandir ${@noprefix('mandir', d)} \ |
| 29 | --infodir ${@noprefix('infodir', d)} \ |
| 30 | --localedir ${@noprefix('localedir', d)} \ |
| 31 | --sysconfdir ${sysconfdir} \ |
| 32 | --localstatedir ${localstatedir} \ |
| 33 | --sharedstatedir ${sharedstatedir}" |
| 34 | |
| 35 | MESON_C_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}" |
| 36 | |
| 37 | MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be', 'big', 'little', d)}" |
| 38 | MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 'big', 'little', d)}" |
| 39 | |
| 40 | EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}" |
| 41 | |
| 42 | MESON_CROSS_FILE = "" |
| 43 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" |
| 44 | |
| 45 | def meson_array(var, d): |
| 46 | return "', '".join(d.getVar(var, True).split()).join(("'", "'")) |
| 47 | |
| 48 | addtask write_config before do_configure |
| 49 | do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS" |
| 50 | do_write_config() { |
| 51 | # This needs to be Py to split the args into single-element lists |
| 52 | cat >${WORKDIR}/meson.cross <<EOF |
| 53 | [binaries] |
| 54 | c = '${HOST_PREFIX}gcc' |
| 55 | cpp = '${HOST_PREFIX}g++' |
| 56 | ar = '${HOST_PREFIX}ar' |
| 57 | ld = '${HOST_PREFIX}ld' |
| 58 | strip = '${HOST_PREFIX}strip' |
| 59 | readelf = '${HOST_PREFIX}readelf' |
| 60 | pkgconfig = 'pkg-config' |
| 61 | |
| 62 | [properties] |
| 63 | c_args = [${@meson_array('MESON_C_ARGS', d)}] |
| 64 | cpp_args = [${@meson_array('TOOLCHAIN_OPTIONS', d)}] |
| 65 | c_link_args = [${@meson_array('TOOLCHAIN_OPTIONS', d)}] |
| 66 | cpp_link_args = [${@meson_array('TOOLCHAIN_OPTIONS', d)}] |
| 67 | |
| 68 | [host_machine] |
| 69 | system = '${HOST_OS}' |
| 70 | cpu_family = '${HOST_ARCH}' |
| 71 | cpu = '${HOST_ARCH}' |
| 72 | endian = '${MESON_HOST_ENDIAN}' |
| 73 | |
| 74 | [target_machine] |
| 75 | system = '${TARGET_OS}' |
| 76 | cpu_family = '${TARGET_ARCH}' |
| 77 | cpu = '${TARGET_ARCH}' |
| 78 | endian = '${MESON_TARGET_ENDIAN}' |
| 79 | EOF |
| 80 | } |
| 81 | |
| 82 | CONFIGURE_FILES = "meson.build" |
| 83 | |
| 84 | meson_do_configure() { |
| 85 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then |
| 86 | cat ${B}/meson-logs/meson-log.txt |
| 87 | bbfatal_log meson failed |
| 88 | fi |
| 89 | } |
| 90 | |
| 91 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" |
| 92 | meson_do_compile() { |
| 93 | ninja ${PARALLEL_MAKE} |
| 94 | } |
| 95 | |
| 96 | meson_do_install() { |
| 97 | DESTDIR='${D}' ninja ${PARALLEL_MAKEINST} install |
| 98 | } |
| 99 | |
| 100 | EXPORT_FUNCTIONS do_configure do_compile do_install |