blob: e124d18144d655fcbafb2272309e30b0246d3b30 [file] [log] [blame]
William A. Kennington IIIac69b482021-06-02 12:28:27 -07001inherit python3native meson-routines
Brad Bishop316dfdd2018-06-25 12:45:53 -04002
Patrick Williams213cb262021-08-07 19:21:33 -05003DEPENDS:append = " meson-native ninja-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -04004
5# As Meson enforces out-of-tree builds we can just use cleandirs
6B = "${WORKDIR}/build"
7do_configure[cleandirs] = "${B}"
8
9# Where the meson.build build configuration is
10MESON_SOURCEPATH = "${S}"
11
12def noprefix(var, d):
13 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
14
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050015MESON_BUILDTYPE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'debug', 'plain', d)}"
16MESON_BUILDTYPE[vardeps] += "DEBUG_BUILD"
Brad Bishop316dfdd2018-06-25 12:45:53 -040017MESONOPTS = " --prefix ${prefix} \
Andrew Geissler82c905d2020-04-13 13:39:40 -050018 --buildtype ${MESON_BUILDTYPE} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040019 --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 Geissler82c905d2020-04-13 13:39:40 -050029 --sharedstatedir ${sharedstatedir} \
Andrew Geissler95ac1b82021-03-31 14:34:31 -050030 --wrap-mode nodownload \
31 --native-file ${WORKDIR}/meson.native"
Brad Bishop316dfdd2018-06-25 12:45:53 -040032
Patrick Williams213cb262021-08-07 19:21:33 -050033EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040034
35MESON_CROSS_FILE = ""
Patrick Williams213cb262021-08-07 19:21:33 -050036MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross"
37MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross"
Brad Bishop316dfdd2018-06-25 12:45:53 -040038
Brad Bishop316dfdd2018-06-25 12:45:53 -040039addtask write_config before do_configure
Brad Bishop96ff1982019-08-19 13:50:42 -040040do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS"
Brad Bishop316dfdd2018-06-25 12:45:53 -040041do_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 Bishop1a4b7ee2018-12-16 17:11:34 -080045c = ${@meson_array('CC', d)}
46cpp = ${@meson_array('CXX', d)}
47ar = ${@meson_array('AR', d)}
48nm = ${@meson_array('NM', d)}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049strip = ${@meson_array('STRIP', d)}
50readelf = ${@meson_array('READELF', d)}
Brad Bishop316dfdd2018-06-25 12:45:53 -040051pkgconfig = 'pkg-config'
Brad Bishop08902b02019-08-20 09:16:51 -040052llvm-config = 'llvm-config${LLVMVERSION}'
Andrew Geissler635e0e42020-08-21 15:58:33 -050053cups-config = 'cups-config'
Andrew Geissler90fd73c2021-03-05 15:25:55 -060054g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper'
55g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper'
Brad Bishop316dfdd2018-06-25 12:45:53 -040056
Andrew Geissler95ac1b82021-03-31 14:34:31 -050057[built-in options]
Brad Bishop96ff1982019-08-19 13:50:42 -040058c_args = ${@meson_array('CFLAGS', d)}
59c_link_args = ${@meson_array('LDFLAGS', d)}
60cpp_args = ${@meson_array('CXXFLAGS', d)}
61cpp_link_args = ${@meson_array('LDFLAGS', d)}
Andrew Geissler95ac1b82021-03-31 14:34:31 -050062
63[properties]
64needs_exe_wrapper = true
Brad Bishop316dfdd2018-06-25 12:45:53 -040065gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
66
67[host_machine]
Andrew Geissler82c905d2020-04-13 13:39:40 -050068system = '${@meson_operating_system('HOST_OS', d)}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080069cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040070cpu = '${HOST_ARCH}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080071endian = '${@meson_endian('HOST', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040072
73[target_machine]
Andrew Geissler82c905d2020-04-13 13:39:40 -050074system = '${@meson_operating_system('TARGET_OS', d)}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080075cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040076cpu = '${TARGET_ARCH}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080077endian = '${@meson_endian('TARGET', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040078EOF
Andrew Geissler95ac1b82021-03-31 14:34:31 -050079
80 cat >${WORKDIR}/meson.native <<EOF
81[binaries]
82c = ${@meson_array('BUILD_CC', d)}
83cpp = ${@meson_array('BUILD_CXX', d)}
84ar = ${@meson_array('BUILD_AR', d)}
85nm = ${@meson_array('BUILD_NM', d)}
86strip = ${@meson_array('BUILD_STRIP', d)}
87readelf = ${@meson_array('BUILD_READELF', d)}
88pkgconfig = 'pkg-config-native'
89
90[built-in options]
91c_args = ${@meson_array('BUILD_CFLAGS', d)}
92c_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
93cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)}
94cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
95EOF
Brad Bishop316dfdd2018-06-25 12:45:53 -040096}
97
Andrew Geissler95ac1b82021-03-31 14:34:31 -050098# Tell externalsrc that changes to this file require a reconfigure
Brad Bishop316dfdd2018-06-25 12:45:53 -040099CONFIGURE_FILES = "meson.build"
100
101meson_do_configure() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500102 # 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 Bishop1a4b7ee2018-12-16 17:11:34 -0800106 # 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 Bishop316dfdd2018-06-25 12:45:53 -0400110 if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then
Brad Bishop316dfdd2018-06-25 12:45:53 -0400111 bbfatal_log meson failed
112 fi
113}
114
Andrew Geissler82c905d2020-04-13 13:39:40 -0500115python meson_do_qa_configure() {
116 import re
117 warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE)
Andrew Geisslerc182c622020-05-15 14:13:32 -0500118 with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile:
119 log = logfile.read()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500120 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}
123do_configure[postfuncs] += "meson_do_qa_configure"
124
Brad Bishop316dfdd2018-06-25 12:45:53 -0400125do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
126meson_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800127 ninja -v ${PARALLEL_MAKE}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400128}
129
130meson_do_install() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800131 DESTDIR='${D}' ninja -v ${PARALLEL_MAKEINST} install
Brad Bishop316dfdd2018-06-25 12:45:53 -0400132}
133
134EXPORT_FUNCTIONS do_configure do_compile do_install