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