mesa/subprojects/packagefiles/rustix-1-rs/meson.build

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.6 KiB
Meson
Raw Normal View History

# Copyright © 2025 Google
# SPDX-License-Identifier: MIT
project(
'rustix-1-rs',
'rust',
version : '1.1.2',
license : 'Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT',
meson_version : '>= 1.7.0',
)
meson: rename Rust subprojects to NAME-SEMVER-rs Use the convention for Rust subprojects that was adopted by Meson 1.5.0 and newer. Distros would prefer to avoid vendored crate sources, and instead use local sources from e.g. /usr/share/cargo/registry. While Meson does not support a local registry, it can be emulated with MESON_PACKAGE_CACHE_DIR. However, because the distro might not be using the exact version of the package, but only one that has the same semver, packagers need to add some hacks to rewrite the wrap files. For example, in Fedora: export MESON_PACKAGE_CACHE_DIR="%{cargo_registry}/" # So... Meson can't actually find them without tweaks %define inst_crate_nameversion() %(basename %{cargo_registry}/%{1}-*) %define rewrite_wrap_file() sed -e "/source.*/d" -e "s/%{1}-.*/%{inst_crate_nameversion %{1}}/" -i subprojects/%{1}.wrap %rewrite_wrap_file proc-macro2 %rewrite_wrap_file quote %rewrite_wrap_file syn %rewrite_wrap_file unicode-ident %rewrite_wrap_file paste Having a common convention for the name of Rust wraps makes it possible to perform this transformation with a script without listing the wraps one by one, and to share the script across multiple packages (which will be useful when QEMU starts using Rust in a similar way to Mesa). For an example of such a script, see https://lore.kernel.org/r/20250722083507.678542-1-pbonzini@redhat.com/. Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36284>
2025-07-22 08:43:52 +02:00
errno = subproject('errno-0.3-rs').get_variable('lib')
libc = subproject('libc-0.2-rs').get_variable('lib')
bitflags = subproject('bitflags-2-rs').get_variable('lib')
rustix_args = []
os_deps = []
if host_machine.system() == 'linux' or host_machine.system() == 'android'
rustix_args += [
'--cfg', 'libc',
'--cfg', 'feature="use-libc"',
'--cfg', 'linux_like',
'--cfg', 'linux_kernel',
'--cfg', 'feature="std"',
'--cfg', 'feature="alloc"',
'--cfg', 'feature="event"',
'--cfg', 'feature="fs"',
'--cfg', 'feature="mm"',
'--cfg', 'feature="net"',
'--cfg', 'feature="param"',
'--cfg', 'feature="pipe"',
]
elif host_machine.system() == 'darwin' or host_machine.system() == 'macos'
rustix_args += [
'--cfg', 'apple',
'--cfg', 'bsd',
'--cfg', 'libc',
'--cfg', 'feature="use-libc"',
'--cfg', 'feature="std"',
'--cfg', 'feature="alloc"',
'--cfg', 'feature="fs"',
'--cfg', 'feature="net"',
'--cfg', 'feature="pipe"',
]
elif host_machine.system() == 'windows'
rustix_args += [
'--cfg', 'libc',
'--cfg', 'feature="use-libc"',
]
os_deps += subproject('windows-sys-0.6-rs').get_variable('lib')
endif
lib = static_library(
'rustix',
'src/lib.rs',
override_options : ['rust_std=2021', 'build.rust_std=2021', 'warning_level=0'],
link_with : [errno, libc, bitflags] + os_deps,
rust_abi : 'rust',
rust_args: rustix_args,
)
dep_rustix = declare_dependency(
link_with : [lib, errno, libc, bitflags] + os_deps,
)