blob: 2beed89d11396a60bac8ddf1bf3460d49936136b [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 Geissler82c905d2020-04-13 13:39:40 -050015MESON_BUILDTYPE ?= "plain"
Brad Bishop316dfdd2018-06-25 12:45:53 -040016MESONOPTS = " --prefix ${prefix} \
Andrew Geissler82c905d2020-04-13 13:39:40 -050017 --buildtype ${MESON_BUILDTYPE} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040018 --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 Geissler82c905d2020-04-13 13:39:40 -050028 --sharedstatedir ${sharedstatedir} \
Andrew Geissler95ac1b82021-03-31 14:34:31 -050029 --wrap-mode nodownload \
30 --native-file ${WORKDIR}/meson.native"
Brad Bishop316dfdd2018-06-25 12:45:53 -040031
Patrick Williams213cb262021-08-07 19:21:33 -050032EXTRA_OEMESON:append = " ${PACKAGECONFIG_CONFARGS}"
Brad Bishop316dfdd2018-06-25 12:45:53 -040033
34MESON_CROSS_FILE = ""
Patrick Williams213cb262021-08-07 19:21:33 -050035MESON_CROSS_FILE:class-target = "--cross-file ${WORKDIR}/meson.cross"
36MESON_CROSS_FILE:class-nativesdk = "--cross-file ${WORKDIR}/meson.cross"
Brad Bishop316dfdd2018-06-25 12:45:53 -040037
Brad Bishop316dfdd2018-06-25 12:45:53 -040038addtask write_config before do_configure
Brad Bishop96ff1982019-08-19 13:50:42 -040039do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS"
Brad Bishop316dfdd2018-06-25 12:45:53 -040040do_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 Bishop1a4b7ee2018-12-16 17:11:34 -080044c = ${@meson_array('CC', d)}
45cpp = ${@meson_array('CXX', d)}
46ar = ${@meson_array('AR', d)}
47nm = ${@meson_array('NM', d)}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080048strip = ${@meson_array('STRIP', d)}
49readelf = ${@meson_array('READELF', d)}
Brad Bishop316dfdd2018-06-25 12:45:53 -040050pkgconfig = 'pkg-config'
Brad Bishop08902b02019-08-20 09:16:51 -040051llvm-config = 'llvm-config${LLVMVERSION}'
Andrew Geissler635e0e42020-08-21 15:58:33 -050052cups-config = 'cups-config'
Andrew Geissler90fd73c2021-03-05 15:25:55 -060053g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper'
54g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper'
Brad Bishop316dfdd2018-06-25 12:45:53 -040055
Andrew Geissler95ac1b82021-03-31 14:34:31 -050056[built-in options]
Brad Bishop96ff1982019-08-19 13:50:42 -040057c_args = ${@meson_array('CFLAGS', d)}
58c_link_args = ${@meson_array('LDFLAGS', d)}
59cpp_args = ${@meson_array('CXXFLAGS', d)}
60cpp_link_args = ${@meson_array('LDFLAGS', d)}
Andrew Geissler95ac1b82021-03-31 14:34:31 -050061
62[properties]
63needs_exe_wrapper = true
Brad Bishop316dfdd2018-06-25 12:45:53 -040064gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper'
65
66[host_machine]
Andrew Geissler82c905d2020-04-13 13:39:40 -050067system = '${@meson_operating_system('HOST_OS', d)}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080068cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040069cpu = '${HOST_ARCH}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080070endian = '${@meson_endian('HOST', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040071
72[target_machine]
Andrew Geissler82c905d2020-04-13 13:39:40 -050073system = '${@meson_operating_system('TARGET_OS', d)}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080074cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040075cpu = '${TARGET_ARCH}'
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080076endian = '${@meson_endian('TARGET', d)}'
Brad Bishop316dfdd2018-06-25 12:45:53 -040077EOF
Andrew Geissler95ac1b82021-03-31 14:34:31 -050078
79 cat >${WORKDIR}/meson.native <<EOF
80[binaries]
81c = ${@meson_array('BUILD_CC', d)}
82cpp = ${@meson_array('BUILD_CXX', d)}
83ar = ${@meson_array('BUILD_AR', d)}
84nm = ${@meson_array('BUILD_NM', d)}
85strip = ${@meson_array('BUILD_STRIP', d)}
86readelf = ${@meson_array('BUILD_READELF', d)}
87pkgconfig = 'pkg-config-native'
88
89[built-in options]
90c_args = ${@meson_array('BUILD_CFLAGS', d)}
91c_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
92cpp_args = ${@meson_array('BUILD_CXXFLAGS', d)}
93cpp_link_args = ${@meson_array('BUILD_LDFLAGS', d)}
94EOF
Brad Bishop316dfdd2018-06-25 12:45:53 -040095}
96
Andrew Geissler95ac1b82021-03-31 14:34:31 -050097# Tell externalsrc that changes to this file require a reconfigure
Brad Bishop316dfdd2018-06-25 12:45:53 -040098CONFIGURE_FILES = "meson.build"
99
100meson_do_configure() {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500101 # 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 Bishop1a4b7ee2018-12-16 17:11:34 -0800105 # 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 Bishop316dfdd2018-06-25 12:45:53 -0400109 if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then
Brad Bishop316dfdd2018-06-25 12:45:53 -0400110 bbfatal_log meson failed
111 fi
112}
113
Andrew Geissler82c905d2020-04-13 13:39:40 -0500114python meson_do_qa_configure() {
115 import re
116 warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE)
Andrew Geisslerc182c622020-05-15 14:13:32 -0500117 with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile:
118 log = logfile.read()
Andrew Geissler82c905d2020-04-13 13:39:40 -0500119 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}
122do_configure[postfuncs] += "meson_do_qa_configure"
123
Brad Bishop316dfdd2018-06-25 12:45:53 -0400124do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
125meson_do_compile() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800126 ninja -v ${PARALLEL_MAKE}
Brad Bishop316dfdd2018-06-25 12:45:53 -0400127}
128
129meson_do_install() {
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800130 DESTDIR='${D}' ninja -v ${PARALLEL_MAKEINST} install
Brad Bishop316dfdd2018-06-25 12:45:53 -0400131}
132
133EXPORT_FUNCTIONS do_configure do_compile do_install