diff options
Diffstat (limited to 'meta/classes/meson.bbclass')
| -rw-r--r-- | meta/classes/meson.bbclass | 179 |
1 files changed, 0 insertions, 179 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass deleted file mode 100644 index 765e81bc4f..0000000000 --- a/meta/classes/meson.bbclass +++ /dev/null | |||
| @@ -1,179 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Copyright OpenEmbedded Contributors | ||
| 3 | # | ||
| 4 | # SPDX-License-Identifier: MIT | ||
| 5 | # | ||
| 6 | |||
| 7 | inherit python3native meson-routines qemu | ||
| 8 | |||
| 9 | DEPENDS:append = " meson-native ninja-native" | ||
| 10 | |||
| 11 | EXEWRAPPER_ENABLED:class-native = "False" | ||
| 12 | EXEWRAPPER_ENABLED:class-nativesdk = "False" | ||
| 13 | EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}" | ||
| 14 | DEPENDS:append = "${@' qemu-native' if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ''}" | ||
| 15 | |||
| 16 | # As Meson enforces out-of-tree builds we can just use cleandirs | ||
| 17 | B = "${WORKDIR}/build" | ||
| 18 | do_configure[cleandirs] = "${B}" | ||
| 19 | |||
| 20 | # Where the meson.build build configuration is | ||
| 21 | MESON_SOURCEPATH = "${S}" | ||
| 22 | |||
| 23 | def noprefix(var, d): | ||
| 24 | return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) | ||
| 25 | |||
| 26 | MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}" | ||
| 27 | MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD" | ||
| 28 | MESONOPTS = " --prefix ${prefix} \ | ||
| 29 | --buildtype ${MESON_BUILDTYPE} \ | ||
| 30 | --bindir ${@noprefix('bindir', d)} \ | ||
| 31 | --sbindir ${@noprefix('sbindir', d)} \ | ||
| 32 | --datadir ${@noprefix('datadir', d)} \ | ||
| 33 | --libdir ${@noprefix('libdir', d)} \ | ||
| 34 | --libexecdir ${@noprefix('libexecdir', d)} \ | ||
| 35 | --includedir ${@noprefix('includedir', d)} \ | ||
| 36 | --mandir ${@noprefix('mandir', d)} \ | ||
| 37 | --infodir ${@noprefix('infodir', d)} \ | ||
| 38 | --sysconfdir ${sysconfdir} \ | ||
| 39 | --localstatedir ${localstatedir} \ | ||
| 40 | --sharedstatedir ${sharedstatedir} \ | ||
| 41 | --wrap-mode nodownload \ | ||
| 42 | --native-file ${WORKDIR}/meson.native" | ||
| 43 | |||
| 44 | EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}" | ||
| 45 | |||
| 46 | MESON_CROSS_FILE = "" | ||
| 47 | MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross" | ||
| 48 | MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" | ||
| 49 | |||
| 50 | # Needed to set up qemu wrapper below | ||
| 51 | export STAGING_DIR_HOST | ||
| 52 | |||
| 53 | def rust_tool(d, target_var): | ||
| 54 | rustc = d.getVar('RUSTC') | ||
| 55 | if not rustc: | ||
| 56 | return "" | ||
| 57 | cmd = [rustc, "--target", d.getVar(target_var)] + d.getVar("RUSTFLAGS").split() | ||
| 58 | return "rust = %s" % repr(cmd) | ||
| 59 | |||
| 60 | addtask write_config before do_configure | ||
| 61 | do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS RUSTC RUSTFLAGS" | ||
| 62 | do_write_config() { | ||
| 63 | # This needs to be Py to split the args into single-element lists | ||
| 64 | cat >${WORKDIR}/meson.cross <<EOF | ||
| 65 | [binaries] | ||
| 66 | c = ${@meson_array('CC', d)} | ||
| 67 | cpp = ${@meson_array('CXX', d)} | ||
| 68 | cython = 'cython3' | ||
| 69 | ar = ${@meson_array('AR', d)} | ||
| 70 | nm = ${@meson_array('NM', d)} | ||
| 71 | strip = ${@meson_array('STRIP', d)} | ||
| 72 | readelf = ${@meson_array('READELF', d)} | ||
| 73 | objcopy = ${@meson_array('OBJCOPY', d)} | ||
| 74 | pkgconfig = 'pkg-config' | ||
| 75 | llvm-config = 'llvm-config${LLVMVERSION}' | ||
| 76 | cups-config = 'cups-config' | ||
| 77 | g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper' | ||
| 78 | g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper' | ||
| 79 | ${@rust_tool(d, "HOST_SYS")} | ||
| 80 | ${@"exe_wrapper = '${WORKDIR}/meson-qemuwrapper'" if d.getVar('EXEWRAPPER_ENABLED') == 'True' else ""} | ||
| 81 | |||
| 82 | [built-in options] | ||
| 83 | c_args = ${@meson_array('CFLAGS', d)} | ||
| 84 | c_link_args = ${@meson_array('LDFLAGS', d)} | ||
| 85 | cpp_args = ${@meson_array('CXXFLAGS', d)} | ||
| 86 | cpp_link_args = ${@meson_array('LDFLAGS', d)} | ||
| 87 | |||
| 88 | [properties] | ||
| 89 | needs_exe_wrapper = true | ||
| 90 | |||
| 91 | [host_machine] | ||
| 92 | system = '${@meson_operating_system('HOST_OS', d)}' | ||
| 93 | cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' | ||
| 94 | cpu = '${HOST_ARCH}' | ||
| 95 | endian = '${@meson_endian('HOST', d)}' | ||
| 96 | |||
| 97 | [target_machine] | ||
| 98 | system = '${@meson_operating_system('TARGET_OS', d)}' | ||
| 99 | cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' | ||
| 100 | cpu = '${TARGET_ARCH}' | ||
| 101 | endian = '${@meson_endian('TARGET', d)}' | ||
| 102 | EOF | ||
| 103 | |||
| 104 | cat >${WORKDIR}/meson.native <<EOF | ||
| 105 | [binaries] | ||
| 106 | c = ${@meson_array('BUILD_CC', d)} | ||
| 107 | cpp = ${@meson_array('BUILD_CXX', d)} | ||
| 108 | cython = 'cython3' | ||
| 109 | ar = ${@meson_array('BUILD_AR', d)} | ||
| 110 | nm = ${@meson_array('BUILD_NM', d)} | ||
| 111 | strip = ${@meson_array('BUILD_STRIP', d)} | ||
| 112 | readelf = ${@meson_array('BUILD_READELF', d)} | ||
| 113 | objcopy = ${@meson_array('BUILD_OBJCOPY', d)} | ||
| 114 | pkgconfig = 'pkg-config-native' | ||
| 115 | ${@rust_tool(d, "BUILD_SYS")} | ||
| 116 | |||
| 117 | [built-in options] | ||
| 118 | c_args = ${@meson_array('BUILD_CFLAGS', d)} | ||
| 119 | c_link_args = ${@meson_array('BUILD_LDFLAGS', d)} | ||
| 120 | cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)} | ||
| 121 | cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)} | ||
| 122 | EOF | ||
| 123 | } | ||
| 124 | |||
| 125 | do_write_config:append:class-target() { | ||
| 126 | # Write out a qemu wrapper that will be used as exe_wrapper so that meson | ||
| 127 | # can run target helper binaries through that. | ||
| 128 | qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" | ||
| 129 | cat > ${WORKDIR}/meson-qemuwrapper << EOF | ||
| 130 | #!/bin/sh | ||
| 131 | # Use a modules directory which doesn't exist so we don't load random things | ||
| 132 | # which may then get deleted (or their dependencies) and potentially segfault | ||
| 133 | export GIO_MODULE_DIR=${STAGING_LIBDIR}/gio/modules-dummy | ||
| 134 | |||
| 135 | # meson sets this wrongly (only to libs in build-dir), qemu_wrapper_cmdline() and GIR_EXTRA_LIBS_PATH take care of it properly | ||
| 136 | unset LD_LIBRARY_PATH | ||
| 137 | |||
| 138 | $qemu_binary "\$@" | ||
| 139 | EOF | ||
| 140 | chmod +x ${WORKDIR}/meson-qemuwrapper | ||
| 141 | } | ||
| 142 | |||
| 143 | # Tell externalsrc that changes to this file require a reconfigure | ||
| 144 | CONFIGURE_FILES = "meson.build" | ||
| 145 | |||
| 146 | meson_do_configure() { | ||
| 147 | # Meson requires this to be 'bfd, 'lld' or 'gold' from 0.53 onwards | ||
| 148 | # https://github.com/mesonbuild/meson/commit/ef9aeb188ea2bc7353e59916c18901cde90fa2b3 | ||
| 149 | unset LD | ||
| 150 | |||
| 151 | # Work around "Meson fails if /tmp is mounted with noexec #2972" | ||
| 152 | mkdir -p "${B}/meson-private/tmp" | ||
| 153 | export TMPDIR="${B}/meson-private/tmp" | ||
| 154 | bbnote Executing meson ${EXTRA_OEMESON}... | ||
| 155 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then | ||
| 156 | bbfatal_log meson failed | ||
| 157 | fi | ||
| 158 | } | ||
| 159 | |||
| 160 | python meson_do_qa_configure() { | ||
| 161 | import re | ||
| 162 | warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE) | ||
| 163 | with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile: | ||
| 164 | log = logfile.read() | ||
| 165 | for (prop, value) in warn_re.findall(log): | ||
| 166 | bb.warn("Meson cross property %s used without explicit assignment, defaulting to %s" % (prop, value)) | ||
| 167 | } | ||
| 168 | do_configure[postfuncs] += "meson_do_qa_configure" | ||
| 169 | |||
| 170 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" | ||
| 171 | meson_do_compile() { | ||
| 172 | ninja -v ${PARALLEL_MAKE} | ||
| 173 | } | ||
| 174 | |||
| 175 | meson_do_install() { | ||
| 176 | DESTDIR='${D}' ninja -v ${PARALLEL_MAKEINST} install | ||
| 177 | } | ||
| 178 | |||
| 179 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||
