| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1 | inherit python3native meson-routines | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 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 | def noprefix(var, d): | 
|  | 13 | return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) | 
|  | 14 |  | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 15 | MESON_BUILDTYPE ?= "plain" | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 16 | MESONOPTS = " --prefix ${prefix} \ | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 17 | --buildtype ${MESON_BUILDTYPE} \ | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 18 | --bindir ${@noprefix('bindir', d)} \ | 
|  | 19 | --sbindir ${@noprefix('sbindir', d)} \ | 
|  | 20 | --datadir ${@noprefix('datadir', d)} \ | 
|  | 21 | --libdir ${@noprefix('libdir', d)} \ | 
|  | 22 | --libexecdir ${@noprefix('libexecdir', d)} \ | 
|  | 23 | --includedir ${@noprefix('includedir', d)} \ | 
|  | 24 | --mandir ${@noprefix('mandir', d)} \ | 
|  | 25 | --infodir ${@noprefix('infodir', d)} \ | 
|  | 26 | --sysconfdir ${sysconfdir} \ | 
|  | 27 | --localstatedir ${localstatedir} \ | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 28 | --sharedstatedir ${sharedstatedir} \ | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 29 | --wrap-mode nodownload \ | 
|  | 30 | --native-file ${WORKDIR}/meson.native" | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 32 | EXTRA_OEMESON_append = " ${PACKAGECONFIG_CONFARGS}" | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 33 |  | 
|  | 34 | MESON_CROSS_FILE = "" | 
|  | 35 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" | 
|  | 36 | MESON_CROSS_FILE_class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" | 
|  | 37 |  | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 38 | addtask write_config before do_configure | 
| Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 39 | do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 40 | do_write_config() { | 
|  | 41 | # This needs to be Py to split the args into single-element lists | 
|  | 42 | cat >${WORKDIR}/meson.cross <<EOF | 
|  | 43 | [binaries] | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | c = ${@meson_array('CC', d)} | 
|  | 45 | cpp = ${@meson_array('CXX', d)} | 
|  | 46 | ar = ${@meson_array('AR', d)} | 
|  | 47 | nm = ${@meson_array('NM', d)} | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | strip = ${@meson_array('STRIP', d)} | 
|  | 49 | readelf = ${@meson_array('READELF', d)} | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 50 | pkgconfig = 'pkg-config' | 
| Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 51 | llvm-config = 'llvm-config${LLVMVERSION}' | 
| Andrew Geissler | 635e0e4 | 2020-08-21 15:58:33 -0500 | [diff] [blame] | 52 | cups-config = 'cups-config' | 
| Andrew Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 53 | g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper' | 
|  | 54 | g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper' | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 55 |  | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 56 | [built-in options] | 
| Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame] | 57 | c_args = ${@meson_array('CFLAGS', d)} | 
|  | 58 | c_link_args = ${@meson_array('LDFLAGS', d)} | 
|  | 59 | cpp_args = ${@meson_array('CXXFLAGS', d)} | 
|  | 60 | cpp_link_args = ${@meson_array('LDFLAGS', d)} | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 61 |  | 
|  | 62 | [properties] | 
|  | 63 | needs_exe_wrapper = true | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper' | 
|  | 65 |  | 
|  | 66 | [host_machine] | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 67 | system = '${@meson_operating_system('HOST_OS', d)}' | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 68 | cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 69 | cpu = '${HOST_ARCH}' | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 70 | endian = '${@meson_endian('HOST', d)}' | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 71 |  | 
|  | 72 | [target_machine] | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 73 | system = '${@meson_operating_system('TARGET_OS', d)}' | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 74 | cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 75 | cpu = '${TARGET_ARCH}' | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 76 | endian = '${@meson_endian('TARGET', d)}' | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 77 | EOF | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 78 |  | 
|  | 79 | cat >${WORKDIR}/meson.native <<EOF | 
|  | 80 | [binaries] | 
|  | 81 | c = ${@meson_array('BUILD_CC', d)} | 
|  | 82 | cpp = ${@meson_array('BUILD_CXX', d)} | 
|  | 83 | ar = ${@meson_array('BUILD_AR', d)} | 
|  | 84 | nm = ${@meson_array('BUILD_NM', d)} | 
|  | 85 | strip = ${@meson_array('BUILD_STRIP', d)} | 
|  | 86 | readelf = ${@meson_array('BUILD_READELF', d)} | 
|  | 87 | pkgconfig = 'pkg-config-native' | 
|  | 88 |  | 
|  | 89 | [built-in options] | 
|  | 90 | c_args = ${@meson_array('BUILD_CFLAGS', d)} | 
|  | 91 | c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} | 
|  | 92 | cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} | 
|  | 93 | cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)} | 
|  | 94 | EOF | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 95 | } | 
|  | 96 |  | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 97 | # Tell externalsrc that changes to this file require a reconfigure | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 98 | CONFIGURE_FILES = "meson.build" | 
|  | 99 |  | 
|  | 100 | meson_do_configure() { | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 101 | # Meson requires this to be 'bfd, 'lld' or 'gold' from 0.53 onwards | 
|  | 102 | # https://github.com/mesonbuild/meson/commit/ef9aeb188ea2bc7353e59916c18901cde90fa2b3 | 
|  | 103 | unset LD | 
|  | 104 |  | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 105 | # Work around "Meson fails if /tmp is mounted with noexec #2972" | 
|  | 106 | mkdir -p "${B}/meson-private/tmp" | 
|  | 107 | export TMPDIR="${B}/meson-private/tmp" | 
|  | 108 | bbnote Executing meson ${EXTRA_OEMESON}... | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 109 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 110 | bbfatal_log meson failed | 
|  | 111 | fi | 
|  | 112 | } | 
|  | 113 |  | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 114 | python meson_do_qa_configure() { | 
|  | 115 | import re | 
|  | 116 | warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE) | 
| Andrew Geissler | c182c62 | 2020-05-15 14:13:32 -0500 | [diff] [blame] | 117 | with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile: | 
|  | 118 | log = logfile.read() | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 119 | for (prop, value) in warn_re.findall(log): | 
|  | 120 | bb.warn("Meson cross property %s used without explicit assignment, defaulting to %s" % (prop, value)) | 
|  | 121 | } | 
|  | 122 | do_configure[postfuncs] += "meson_do_qa_configure" | 
|  | 123 |  | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 124 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" | 
|  | 125 | meson_do_compile() { | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 126 | ninja -v ${PARALLEL_MAKE} | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 127 | } | 
|  | 128 |  | 
|  | 129 | meson_do_install() { | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 130 | DESTDIR='${D}' ninja -v ${PARALLEL_MAKEINST} install | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 131 | } | 
|  | 132 |  | 
|  | 133 | EXPORT_FUNCTIONS do_configure do_compile do_install |