diff options
Diffstat (limited to 'meta/classes/meson.bbclass')
-rw-r--r-- | meta/classes/meson.bbclass | 189 |
1 files changed, 0 insertions, 189 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass deleted file mode 100644 index a7644e70cb..0000000000 --- a/meta/classes/meson.bbclass +++ /dev/null | |||
@@ -1,189 +0,0 @@ | |||
1 | inherit siteinfo python3native | ||
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 | |||
15 | MESON_BUILDTYPE ?= "plain" | ||
16 | MESONOPTS = " --prefix ${prefix} \ | ||
17 | --buildtype ${MESON_BUILDTYPE} \ | ||
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} \ | ||
28 | --sharedstatedir ${sharedstatedir} \ | ||
29 | --wrap-mode nodownload" | ||
30 | |||
31 | EXTRA_OEMESON_append = " ${PACKAGECONFIG_CONFARGS}" | ||
32 | |||
33 | MESON_CROSS_FILE = "" | ||
34 | MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross" | ||
35 | MESON_CROSS_FILE_class-nativesdk = "--cross-file ${WORKDIR}/meson.cross" | ||
36 | |||
37 | def meson_array(var, d): | ||
38 | items = d.getVar(var).split() | ||
39 | return repr(items[0] if len(items) == 1 else items) | ||
40 | |||
41 | # Map our ARCH values to what Meson expects: | ||
42 | # http://mesonbuild.com/Reference-tables.html#cpu-families | ||
43 | def meson_cpu_family(var, d): | ||
44 | import re | ||
45 | arch = d.getVar(var) | ||
46 | if arch == 'powerpc': | ||
47 | return 'ppc' | ||
48 | elif arch == 'powerpc64' or arch == 'powerpc64le': | ||
49 | return 'ppc64' | ||
50 | elif arch == 'armeb': | ||
51 | return 'arm' | ||
52 | elif arch == 'aarch64_be': | ||
53 | return 'aarch64' | ||
54 | elif arch == 'mipsel': | ||
55 | return 'mips' | ||
56 | elif arch == 'mips64el': | ||
57 | return 'mips64' | ||
58 | elif re.match(r"i[3-6]86", arch): | ||
59 | return "x86" | ||
60 | elif arch == "microblazeel": | ||
61 | return "microblaze" | ||
62 | else: | ||
63 | return arch | ||
64 | |||
65 | # Map our OS values to what Meson expects: | ||
66 | # https://mesonbuild.com/Reference-tables.html#operating-system-names | ||
67 | def meson_operating_system(var, d): | ||
68 | os = d.getVar(var) | ||
69 | if "mingw" in os: | ||
70 | return "windows" | ||
71 | # avoid e.g 'linux-gnueabi' | ||
72 | elif "linux" in os: | ||
73 | return "linux" | ||
74 | else: | ||
75 | return os | ||
76 | |||
77 | def meson_endian(prefix, d): | ||
78 | arch, os = d.getVar(prefix + "_ARCH"), d.getVar(prefix + "_OS") | ||
79 | sitedata = siteinfo_data_for_machine(arch, os, d) | ||
80 | if "endian-little" in sitedata: | ||
81 | return "little" | ||
82 | elif "endian-big" in sitedata: | ||
83 | return "big" | ||
84 | else: | ||
85 | bb.fatal("Cannot determine endianism for %s-%s" % (arch, os)) | ||
86 | |||
87 | addtask write_config before do_configure | ||
88 | do_write_config[vardeps] += "CC CXX LD AR NM STRIP READELF CFLAGS CXXFLAGS LDFLAGS" | ||
89 | do_write_config() { | ||
90 | # This needs to be Py to split the args into single-element lists | ||
91 | cat >${WORKDIR}/meson.cross <<EOF | ||
92 | [binaries] | ||
93 | c = ${@meson_array('CC', d)} | ||
94 | cpp = ${@meson_array('CXX', d)} | ||
95 | ar = ${@meson_array('AR', d)} | ||
96 | nm = ${@meson_array('NM', d)} | ||
97 | strip = ${@meson_array('STRIP', d)} | ||
98 | readelf = ${@meson_array('READELF', d)} | ||
99 | pkgconfig = 'pkg-config' | ||
100 | llvm-config = 'llvm-config${LLVMVERSION}' | ||
101 | cups-config = 'cups-config' | ||
102 | g-ir-scanner = '${STAGING_BINDIR}/g-ir-scanner-wrapper' | ||
103 | g-ir-compiler = '${STAGING_BINDIR}/g-ir-compiler-wrapper' | ||
104 | |||
105 | [properties] | ||
106 | needs_exe_wrapper = true | ||
107 | c_args = ${@meson_array('CFLAGS', d)} | ||
108 | c_link_args = ${@meson_array('LDFLAGS', d)} | ||
109 | cpp_args = ${@meson_array('CXXFLAGS', d)} | ||
110 | cpp_link_args = ${@meson_array('LDFLAGS', d)} | ||
111 | gtkdoc_exe_wrapper = '${B}/gtkdoc-qemuwrapper' | ||
112 | |||
113 | [host_machine] | ||
114 | system = '${@meson_operating_system('HOST_OS', d)}' | ||
115 | cpu_family = '${@meson_cpu_family('HOST_ARCH', d)}' | ||
116 | cpu = '${HOST_ARCH}' | ||
117 | endian = '${@meson_endian('HOST', d)}' | ||
118 | |||
119 | [target_machine] | ||
120 | system = '${@meson_operating_system('TARGET_OS', d)}' | ||
121 | cpu_family = '${@meson_cpu_family('TARGET_ARCH', d)}' | ||
122 | cpu = '${TARGET_ARCH}' | ||
123 | endian = '${@meson_endian('TARGET', d)}' | ||
124 | EOF | ||
125 | } | ||
126 | |||
127 | CONFIGURE_FILES = "meson.build" | ||
128 | |||
129 | meson_do_configure() { | ||
130 | # Meson requires this to be 'bfd, 'lld' or 'gold' from 0.53 onwards | ||
131 | # https://github.com/mesonbuild/meson/commit/ef9aeb188ea2bc7353e59916c18901cde90fa2b3 | ||
132 | unset LD | ||
133 | |||
134 | # Work around "Meson fails if /tmp is mounted with noexec #2972" | ||
135 | mkdir -p "${B}/meson-private/tmp" | ||
136 | export TMPDIR="${B}/meson-private/tmp" | ||
137 | bbnote Executing meson ${EXTRA_OEMESON}... | ||
138 | if ! meson ${MESONOPTS} "${MESON_SOURCEPATH}" "${B}" ${MESON_CROSS_FILE} ${EXTRA_OEMESON}; then | ||
139 | bbfatal_log meson failed | ||
140 | fi | ||
141 | } | ||
142 | |||
143 | override_native_tools() { | ||
144 | # Set these so that meson uses the native tools for its build sanity tests, | ||
145 | # which require executables to be runnable. The cross file will still | ||
146 | # override these for the target build. | ||
147 | export CC="${BUILD_CC}" | ||
148 | export CXX="${BUILD_CXX}" | ||
149 | export LD="${BUILD_LD}" | ||
150 | export AR="${BUILD_AR}" | ||
151 | export STRIP="${BUILD_STRIP}" | ||
152 | # These contain *target* flags but will be used as *native* flags. The | ||
153 | # correct native flags will be passed via -Dc_args and so on, unset them so | ||
154 | # they don't interfere with tools invoked by Meson (such as g-ir-scanner) | ||
155 | unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS | ||
156 | } | ||
157 | |||
158 | meson_do_configure_prepend_class-target() { | ||
159 | override_native_tools | ||
160 | } | ||
161 | |||
162 | meson_do_configure_prepend_class-nativesdk() { | ||
163 | override_native_tools | ||
164 | } | ||
165 | |||
166 | meson_do_configure_prepend_class-native() { | ||
167 | export PKG_CONFIG="pkg-config-native" | ||
168 | } | ||
169 | |||
170 | python meson_do_qa_configure() { | ||
171 | import re | ||
172 | warn_re = re.compile(r"^WARNING: Cross property (.+) is using default value (.+)$", re.MULTILINE) | ||
173 | with open(d.expand("${B}/meson-logs/meson-log.txt")) as logfile: | ||
174 | log = logfile.read() | ||
175 | for (prop, value) in warn_re.findall(log): | ||
176 | bb.warn("Meson cross property %s used without explicit assignment, defaulting to %s" % (prop, value)) | ||
177 | } | ||
178 | do_configure[postfuncs] += "meson_do_qa_configure" | ||
179 | |||
180 | do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+" | ||
181 | meson_do_compile() { | ||
182 | ninja -v ${PARALLEL_MAKE} | ||
183 | } | ||
184 | |||
185 | meson_do_install() { | ||
186 | DESTDIR='${D}' ninja -v ${PARALLEL_MAKEINST} install | ||
187 | } | ||
188 | |||
189 | EXPORT_FUNCTIONS do_configure do_compile do_install | ||