blob: c38d88fe61f72f6589855a475224df2b7b164256 [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001HOMEPAGE = "http://mesonbuild.com"
2SUMMARY = "A high performance build system"
3DESCRIPTION = "Meson is a build system designed to increase programmer \
4productivity. It does this by providing a fast, simple and easy to use \
5interface for modern software development tools and practices."
6
7LICENSE = "Apache-2.0"
8LIC_FILES_CHKSUM = "file://COPYING;md5=3b83ef96387f14655fc854ddc3c6bd57"
9
10GITHUB_BASE_URI = "https://github.com/mesonbuild/meson/releases/"
11SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/meson-${PV}.tar.gz \
12 file://meson-setup.py \
13 file://meson-wrapper \
14 file://0001-python-module-do-not-manipulate-the-environment-when.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060015 file://0001-Make-CPU-family-warnings-fatal.patch \
16 file://0002-Support-building-allarch-recipes-again.patch \
Andrew Geissler517393d2023-01-13 08:55:19 -060017 "
Andrew Geissler20137392023-10-12 04:59:14 -060018SRC_URI[sha256sum] = "4a0f04de331fbc7af3b802a844fc8838f4ccd1ded1e792ba4f8f2faf8c5fe4d6"
Andrew Geissler517393d2023-01-13 08:55:19 -060019
20inherit python_setuptools_build_meta github-releases
21
22RDEPENDS:${PN} = "ninja python3-modules python3-pkg-resources"
23
24FILES:${PN} += "${datadir}/polkit-1"
25
26do_install:append () {
27 # As per the same issue in the python recipe itself:
28 # Unfortunately the following pyc files are non-deterministc due to 'frozenset'
29 # being written without strict ordering, even with PYTHONHASHSEED = 0
30 # Upstream is discussing ways to solve the issue properly, until then let's
31 # just not install the problematic files.
32 # More info: http://benno.id.au/blog/2013/01/15/python-determinism
Andrew Geissler5082cc72023-09-11 08:41:39 -040033 rm -f ${D}${libdir}/python*/site-packages/mesonbuild/dependencies/__pycache__/mpi.cpython*
Andrew Geissler517393d2023-01-13 08:55:19 -060034}
35
36BBCLASSEXTEND = "native nativesdk"
37
38inherit meson-routines
39
40# The cross file logic is similar but not identical to that in meson.bbclass,
41# since it's generating for an SDK rather than a cross-compile. Important
42# differences are:
43# - We can't set vars like CC, CXX, etc. yet because they will be filled in with
44# real paths by meson-setup.sh when the SDK is extracted.
45# - Some overrides aren't needed, since the SDK injects paths that take care of
46# them.
47def var_list2str(var, d):
48 items = d.getVar(var).split()
49 return items[0] if len(items) == 1 else ', '.join(repr(s) for s in items)
50
51def generate_native_link_template(d):
52 val = ['-L@{OECORE_NATIVE_SYSROOT}${libdir_native}',
53 '-L@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
54 '-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${libdir_native}',
55 '-Wl,-rpath-link,@{OECORE_NATIVE_SYSROOT}${base_libdir_native}',
56 '-Wl,--allow-shlib-undefined'
57 ]
58 build_arch = d.getVar('BUILD_ARCH')
59 if 'x86_64' in build_arch:
60 loader = 'ld-linux-x86-64.so.2'
61 elif 'i686' in build_arch:
62 loader = 'ld-linux.so.2'
63 elif 'aarch64' in build_arch:
64 loader = 'ld-linux-aarch64.so.1'
65 elif 'ppc64le' in build_arch:
66 loader = 'ld64.so.2'
Patrick Williams864cc432023-02-09 14:54:44 -060067 elif 'loongarch64' in build_arch:
68 loader = 'ld-linux-loongarch-lp64d.so.1'
Patrick Williamsac13d5f2023-11-24 18:59:46 -060069 elif 'riscv64' in build_arch:
70 loader = 'ld-linux-riscv64-lp64d.so.1'
Andrew Geissler517393d2023-01-13 08:55:19 -060071
72 if loader:
73 val += ['-Wl,--dynamic-linker=@{OECORE_NATIVE_SYSROOT}${base_libdir_native}/' + loader]
74
75 return repr(val)
76
77install_templates() {
78 install -d ${D}${datadir}/meson
79
80 cat >${D}${datadir}/meson/meson.native.template <<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 = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
92c_link_args = ${@generate_native_link_template(d)}
93cpp_args = ['-isystem@{OECORE_NATIVE_SYSROOT}${includedir_native}' , ${@var_list2str('BUILD_OPTIMIZATION', d)}]
94cpp_link_args = ${@generate_native_link_template(d)}
95[properties]
96sys_root = '@OECORE_NATIVE_SYSROOT'
97EOF
98
99 cat >${D}${datadir}/meson/meson.cross.template <<EOF
100[binaries]
101c = @CC
102cpp = @CXX
103ar = @AR
104nm = @NM
105strip = @STRIP
106pkgconfig = 'pkg-config'
107
108[built-in options]
109c_args = @CFLAGS
110c_link_args = @LDFLAGS
111cpp_args = @CPPFLAGS
112cpp_link_args = @LDFLAGS
113
114[properties]
115needs_exe_wrapper = true
116sys_root = @OECORE_TARGET_SYSROOT
117
118[host_machine]
119system = '$host_system'
120cpu_family = '$host_cpu_family'
121cpu = '$host_cpu'
122endian = '$host_endian'
123EOF
124}
125
126do_install:append:class-nativesdk() {
127 host_system=${SDK_OS}
128 host_cpu_family=${@meson_cpu_family("SDK_ARCH", d)}
129 host_cpu=${SDK_ARCH}
130 host_endian=${@meson_endian("SDK", d)}
131 install_templates
132
133 install -d ${D}${SDKPATHNATIVE}/post-relocate-setup.d
134 install -m 0755 ${WORKDIR}/meson-setup.py ${D}${SDKPATHNATIVE}/post-relocate-setup.d/
135
136 # We need to wrap the real meson with a thin env setup wrapper.
137 mv ${D}${bindir}/meson ${D}${bindir}/meson.real
138 install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
139}
140
141FILES:${PN}:append:class-nativesdk = "${datadir}/meson ${SDKPATHNATIVE}"
142
143do_install:append:class-native() {
144 host_system=${HOST_OS}
145 host_cpu_family=${@meson_cpu_family("HOST_ARCH", d)}
146 host_cpu=${HOST_ARCH}
147 host_endian=${@meson_endian("HOST", d)}
148 install_templates
149
150 install -d ${D}${datadir}/post-relocate-setup.d
151 install -m 0755 ${WORKDIR}/meson-setup.py ${D}${datadir}/post-relocate-setup.d/
152
153 # We need to wrap the real meson with a thin wrapper that substitues native/cross files
154 # when running in a direct SDK environment.
155 mv ${D}${bindir}/meson ${D}${bindir}/meson.real
156 install -m 0755 ${WORKDIR}/meson-wrapper ${D}${bindir}/meson
157}