diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7dd6147..eaf04b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,6 +75,9 @@ jobs: - name: "Run Analyzer" run: cargo check ${CI_CARGO_ARGS} + - name: "Run Clippy" + run: cargo clippy ${CI_CARGO_ARGS} + # # A complete but basic build of the project, running on common x86-64 ubuntu # machines. This should catch most compilation errors or test-suite failures diff --git a/Cargo.toml b/Cargo.toml index 344c95e..1ee5630 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,18 @@ osi = { path = "./lib/osi", version = "1.0.0" } sys = { path = "./lib/sys", version = "1.0.0" } tmp = { path = "./lib/tmp", version = "1.0.0" } +[workspace.lints.clippy] +assertions_on_constants = "allow" +explicit_auto_deref = "allow" +identity_op = "allow" +inherent_to_string_shadow_display = "allow" +len_zero = "allow" +manual_range_contains = "allow" +needless_late_init = "allow" +new_without_default = "allow" +should_implement_trait = "allow" +redundant_field_names = "allow" + [workspace.lints.rust.unexpected_cfgs] level = "warn" check-cfg = [ diff --git a/lib/osi/src/lib.rs b/lib/osi/src/lib.rs index c3a9eca..a7c547c 100644 --- a/lib/osi/src/lib.rs +++ b/lib/osi/src/lib.rs @@ -35,12 +35,6 @@ // that these can be greatly optimized by the compiler, they seem a worthy // fit for the standard library. -#![allow(clippy::assertions_on_constants)] -#![allow(clippy::identity_op)] -#![allow(clippy::manual_range_contains)] -#![allow(clippy::should_implement_trait)] -#![allow(clippy::redundant_field_names)] - #![no_std] extern crate alloc; diff --git a/lib/tmp/src/fmt/dbus/dvar.rs b/lib/tmp/src/fmt/dbus/dvar.rs index a7df98c..b6d635f 100644 --- a/lib/tmp/src/fmt/dbus/dvar.rs +++ b/lib/tmp/src/fmt/dbus/dvar.rs @@ -76,31 +76,31 @@ impl Format { } } - fn u8(&self, v: u8) -> [u8; 1] { + fn en_u8(&self, v: u8) -> [u8; 1] { [v] } - fn u16(&self, v: u16) -> [u8; 2] { + fn en_u16(&self, v: u16) -> [u8; 2] { if self.is_be() { v.to_be_bytes() } else { v.to_le_bytes() } } - fn u32(&self, v: u32) -> [u8; 4] { + fn en_u32(&self, v: u32) -> [u8; 4] { if self.is_be() { v.to_be_bytes() } else { v.to_le_bytes() } } - fn u64(&self, v: u64) -> [u8; 8] { + fn en_u64(&self, v: u64) -> [u8; 8] { if self.is_be() { v.to_be_bytes() } else { v.to_le_bytes() } } - fn to_u8(&self, v: [u8; 1]) -> u8 { + fn de_u8(&self, v: [u8; 1]) -> u8 { if self.is_be() { u8::from_be_bytes(v) } else { u8::from_le_bytes(v) } } - fn to_u16(&self, v: [u8; 2]) -> u16 { + fn de_u16(&self, v: [u8; 2]) -> u16 { if self.is_be() { u16::from_be_bytes(v) } else { u16::from_le_bytes(v) } } - fn to_u32(&self, v: [u8; 4]) -> u32 { + fn de_u32(&self, v: [u8; 4]) -> u32 { if self.is_be() { u32::from_be_bytes(v) } else { u32::from_le_bytes(v) } } } @@ -256,7 +256,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { let mut idx = self.level.idx; Self::align(self.write, &mut idx, dbus::Element::U8.dvar_alignment_exp())?; - Self::write(self.write, &mut idx, &self.format.u8(n))?; + Self::write(self.write, &mut idx, &self.format.en_u8(n))?; Self::write(self.write, &mut idx, data.as_bytes())?; Self::zero(self.write, &mut idx, 1)?; self.level.idx = idx; @@ -279,7 +279,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { let mut idx = self.level.idx; Self::align(self.write, &mut idx, dbus::Element::U32.dvar_alignment_exp())?; - Self::write(self.write, &mut idx, &self.format.u32(n))?; + Self::write(self.write, &mut idx, &self.format.en_u32(n))?; Self::write(self.write, &mut idx, data.as_bytes())?; Self::zero(self.write, &mut idx, 1)?; self.level.idx = idx; @@ -289,15 +289,15 @@ impl<'sig, 'write> Enc<'sig, 'write> { } pub fn u16(&mut self, data: u16) -> Flow, &mut Self> { - self.fixed(dbus::Element::U16, &self.format.u16(data)) + self.fixed(dbus::Element::U16, &self.format.en_u16(data)) } pub fn u32(&mut self, data: u32) -> Flow, &mut Self> { - self.fixed(dbus::Element::U32, &self.format.u32(data)) + self.fixed(dbus::Element::U32, &self.format.en_u32(data)) } pub fn u64(&mut self, data: u64) -> Flow, &mut Self> { - self.fixed(dbus::Element::U64, &self.format.u64(data)) + self.fixed(dbus::Element::U64, &self.format.en_u64(data)) } pub fn string(&mut self, data: &str) -> Flow, &mut Self> { @@ -325,7 +325,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { let mut level = self.level.clone(); Self::align(self.write, &mut level.idx, dbus::Element::U8.dvar_alignment_exp())?; - Self::write(self.write, &mut level.idx, &self.format.u8(n))?; + Self::write(self.write, &mut level.idx, &self.format.en_u8(n))?; Self::write_iter(self.write, &mut level.idx, &mut sig.into_iter().map(|v| v.code()))?; Self::zero(self.write, &mut level.idx, 1)?; level.meta = level.idx; @@ -352,7 +352,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { let align = self.cursor.down().unwrap().dvar_alignment_exp(); Self::align(self.write, &mut level.idx, dbus::Element::U32.dvar_alignment_exp())?; level.meta = level.idx; - Self::write(self.write, &mut level.idx, &self.format.u32(0))?; + Self::write(self.write, &mut level.idx, &self.format.en_u32(0))?; Self::align(self.write, &mut level.idx, align)?; level.from = level.idx; @@ -422,7 +422,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { return Flow::Break(Some(dbus::Error::DataOverflow)); }; let mut idx = self.level.meta; - Self::write(self.write, &mut idx, &self.format.u32(n))?; + Self::write(self.write, &mut idx, &self.format.en_u32(n))?; } }, dbus::Element::StructOpen => { @@ -598,7 +598,7 @@ impl<'sig, 'read> Dec<'sig, 'read> { let mut len_u = [0; _]; Self::align(self.read, &mut idx, dbus::Element::U8.dvar_alignment_exp())?; Self::read(self.read, &mut idx, &mut len_u)?; - let len = self.format.to_u8(len_u) as usize; + let len = self.format.de_u8(len_u) as usize; // Read the string. let mut buffer = alloc::vec::Vec::with_capacity(len); @@ -637,7 +637,7 @@ impl<'sig, 'read> Dec<'sig, 'read> { let mut len_u = [0; _]; Self::align(self.read, &mut idx, dbus::Element::U32.dvar_alignment_exp())?; Self::read(self.read, &mut idx, &mut len_u)?; - let len = self.format.to_u32(len_u) as usize; + let len = self.format.de_u32(len_u) as usize; // Read the string. let mut buffer = alloc::vec::Vec::with_capacity(len); @@ -664,7 +664,7 @@ impl<'sig, 'read> Dec<'sig, 'read> { pub fn u16(&mut self, data: &mut u16) -> Flow, &mut Self> { let mut v = [0; _]; self.fixed(dbus::Element::U16, &mut v)?; - *data = self.format.to_u16(v); + *data = self.format.de_u16(v); Flow::Continue(self) } @@ -687,7 +687,7 @@ impl<'sig, 'read> Dec<'sig, 'read> { let mut len_u = [0; _]; Self::align(self.read, &mut level.idx, dbus::Element::U32.dvar_alignment_exp())?; Self::read(self.read, &mut level.idx, &mut len_u)?; - level.meta = self.format.to_u32(len_u) as usize; + level.meta = self.format.de_u32(len_u) as usize; Self::align(self.read, &mut level.idx, align)?; core::mem::swap(&mut level, &mut self.level); @@ -739,6 +739,7 @@ impl<'sig, 'read> Dec<'sig, 'read> { } } +#[allow(clippy::octal_escapes)] #[cfg(test)] mod test { use super::*; diff --git a/lib/tmp/src/fmt/dbus/element.rs b/lib/tmp/src/fmt/dbus/element.rs index 42a5169..242c99a 100644 --- a/lib/tmp/src/fmt/dbus/element.rs +++ b/lib/tmp/src/fmt/dbus/element.rs @@ -156,6 +156,7 @@ struct ElementMeta { gvar_size: u8, } +#[allow(clippy::too_many_arguments)] const fn element( code: u8, element: Element, @@ -391,8 +392,9 @@ impl Element { /// Create a new element from its id. This is a simple transmute that does /// not modify the value. /// - /// SAFETY: `id` must be a valid element id gained from a call to - /// `Self::id()`. + /// ## Safety + /// + /// `id` must be a valid element id gained from a call to `Self::id()`. pub const unsafe fn from_id(id: u8) -> Self { // SAFETY: The caller guarantees `id` was acquired via `Self::id()`, // hence we can rely on `repr(u8)` to guarantee that we can @@ -792,7 +794,7 @@ mod test { assert!(!v.all(FLAG_OPEN | FLAG_CLOSE)); // ...has FLAG_OPEN or FLAG_CLOSE if it has a pair. assert!( - !v.pair().is_some() + v.pair().is_none() || v.any(FLAG_OPEN | FLAG_CLOSE) ); // ...has FLAG_CLOSE only if it has a pair. diff --git a/lib/tmp/src/fmt/dbus/ende.rs b/lib/tmp/src/fmt/dbus/ende.rs index eb4021f..f5703a7 100644 --- a/lib/tmp/src/fmt/dbus/ende.rs +++ b/lib/tmp/src/fmt/dbus/ende.rs @@ -48,6 +48,7 @@ impl<'sig, 'write> Enc<'sig, 'write> { loop { if dec.more() { + #[allow(clippy::match_single_binding)] match cur.element().unwrap() { _ => core::unreachable!(), } diff --git a/lib/tmp/src/fmt/dbus/signature.rs b/lib/tmp/src/fmt/dbus/signature.rs index 1e69f5b..6dd814b 100644 --- a/lib/tmp/src/fmt/dbus/signature.rs +++ b/lib/tmp/src/fmt/dbus/signature.rs @@ -27,21 +27,21 @@ //! D-Bus type-system. These might not be well defined outside of this module. //! //! - *element*: An element is a single ASCII character that can be used in -//! a type signature. This can either refer to a primitive type, or be -//! part of a compound type signature. Hence, not all elements are -//! valid types by themselves, but might only be valid in combination -//! with other elements as part of a signature. +//! a type signature. This can either refer to a primitive type, or be +//! part of a compound type signature. Hence, not all elements are +//! valid types by themselves, but might only be valid in combination +//! with other elements as part of a signature. //! - *primitive type*: A type with signature length of 1 is called a -//! primitive type. +//! primitive type. //! - *compound type*: A non-primitive type is called a compound type. //! - *bound container*: A bound container has an opening element, but no -//! closing element and thus forms a compound type with its following -//! single complete type. +//! closing element and thus forms a compound type with its following +//! single complete type. //! - *unbound container*: An unbound container has both an opening and -//! closing element and thus forms a compound type with all its -//! enclosed types. +//! closing element and thus forms a compound type with all its +//! enclosed types. //! - *DVariant*: The D-Bus type encoding as introduced in the original D-Bus -//! specification v0.8. +//! specification v0.8. //! - *GVariant*: The D-Bus type encoding as introduced by glib. // NB: This implementation avoids several standard Rust interfaces, because @@ -170,14 +170,14 @@ enum NodeRef<'node> { /// representations. The following representations are used by this module: /// /// - `Sig<[u64]>`: This is the default representation, which can also be -/// referenced as `Sig`. It is a dynamically sized type (DST) and is -/// thus usually used behind a reference as `&Sig`. -/// This representation is used by default for any function that -/// required access to a D-Bus Signature. +/// referenced as `Sig`. It is a dynamically sized type (DST) and is +/// thus usually used behind a reference as `&Sig`. +/// This representation is used by default for any function that +/// required access to a D-Bus Signature. /// - `Sig<[u64; N]>: This is a statically sized representation used to -/// create signatures on the stack. It uses const-generics to encode -/// the size of the data buffer. -/// This representation is used by default to create literals. +/// create signatures on the stack. It uses const-generics to encode +/// the size of the data buffer. +/// This representation is used by default to create literals. #[repr(transparent)] pub struct Sig { nodes: Nodes, @@ -334,6 +334,7 @@ impl<'node> NodeRef<'node> { macro_rules! impl_node { ($node:ty, $int:ty, $id:expr) => { + #[allow(clippy::modulo_one)] impl $node { const ID: u8 = $id; const SIZE_COEFF: usize = mem::size_of::() / mem::size_of::(); @@ -692,6 +693,7 @@ macro_rules! impl_node!(Node8, u8, 0); impl_node!(Node64, u64, 3); +#[allow(clippy::len_without_is_empty)] impl Sig { /// Calculate the required signature data buffer size given a signature /// length. @@ -705,9 +707,9 @@ impl Sig { /// otherwise. #[doc(hidden)] pub const fn size_for_length(length: usize) -> usize { - assert!(mem::size_of::() % mem::size_of::() == 0); + assert!(mem::size_of::().is_multiple_of(mem::size_of::())); assert!(mem::align_of::() <= mem::align_of::()); - assert!(mem::size_of::() % mem::size_of::() == 0); + assert!(mem::size_of::().is_multiple_of(mem::size_of::())); assert!(mem::align_of::() <= mem::align_of::()); if length <= Node8::LENGTH_MAX { @@ -858,7 +860,7 @@ impl Sig { Some(mem::transmute::<&[u64], &Self>( // Use `split_at()` rather than range-indexing, since the // latter is not available in const-fn. - &self.nodes + self.nodes .split_at(idx.strict_mul(coeff)).1 .split_at(len.strict_mul(coeff)).0 )) @@ -910,7 +912,12 @@ impl Sig<[u64; SIZE]> { // MSRV(unknown): This is available upstream as `transpose()` in // `feature(maybe_uninit_uninit_array_transpose)` (#96097). buf = mem::MaybeUninit::uninit(); - buf_v = unsafe { mem::transmute(&mut buf) }; + buf_v = unsafe { + mem::transmute::< + &mut mem::MaybeUninit<[u64; SIZE]>, + &mut [mem::MaybeUninit; SIZE], + >(&mut buf) + }; match Sig::<[u64]>::parse(buf_v, signature) { // SAFETY: `Sig::parse()` always initializes the entire data @@ -1193,7 +1200,7 @@ where /// `None`. pub fn dvar_alignment_exp(&self) -> Option { self.flags_at(self.idx) - .and_then(|v| Some(v.dvar_alignment_exp())) + .map(|v| v.dvar_alignment_exp()) } /// Return the GVar alignment exponent at the current index. @@ -1205,7 +1212,7 @@ where /// `None`. pub fn gvar_alignment_exp(&self) -> Option { self.flags_at(self.idx) - .and_then(|v| Some(v.gvar_alignment_exp())) + .map(|v| v.gvar_alignment_exp()) } } @@ -1305,12 +1312,7 @@ impl core::cmp::PartialEq for Sig { impl core::cmp::PartialOrd for Sig { fn partial_cmp(&self, v: &Self) -> Option { - // Sort by code to ensure stable order. - self.into_iter() - .map(|v| v.code()) - .partial_cmp( - v.into_iter().map(|v| v.code()), - ) + Some(self.cmp(v)) } } diff --git a/lib/tmp/src/fmt/json/token.rs b/lib/tmp/src/fmt/json/token.rs index ea2e0c7..223f074 100644 --- a/lib/tmp/src/fmt/json/token.rs +++ b/lib/tmp/src/fmt/json/token.rs @@ -419,27 +419,24 @@ impl<'read> Dec<'read> { let map = self.read.map_while( &mut self.inner.idx, None, - |_, v| match v { - b' ' | b'\n' | b'\r' | b'\t' => true, - _ => false, - }, + |_, v| matches!(v, b' ' | b'\n' | b'\r' | b'\t'), )?; self.inner.done = Some(self.inner.idx); - return Flow::Continue(Some(self.inner.raise_whitespace(&map[..self.inner.idx]))); + Flow::Continue(Some(self.inner.raise_whitespace(&map[..self.inner.idx]))) } fn advance_item(&mut self) -> Flow>> { let map = self.read.map_while( &mut self.inner.idx, None, - |_, v| match v { + |_, v| matches!( + v, b'+' | b'-' | b'.' | b'0'..=b'9' - | b'a'..=b'z' | b'A'..=b'Z' => true, - _ => false, - }, + | b'a'..=b'z' | b'A'..=b'Z', + ), )?; self.inner.done = Some(self.inner.idx); - return Flow::Continue(Some(self.inner.raise_item(&map[..self.inner.idx]))); + Flow::Continue(Some(self.inner.raise_item(&map[..self.inner.idx]))) } fn advance_number(&mut self) -> Flow>> { @@ -556,10 +553,7 @@ impl<'read> Dec<'read> { let map = self.read.map_while( &mut self.inner.idx, None, - |_, v| match v { - b'"' | b'\\' | 0x00..0x1f => false, - _ => true, - }, + |_, v| !matches!(v, b'"' | b'\\' | 0x00..0x1f), )?; match map[self.inner.idx] { @@ -624,13 +618,11 @@ impl<'read> Dec<'read> { State::StringEscapeUnicode { idx_start } => { let max = idx_start.strict_add(4); + #[allow(clippy::manual_is_ascii_check)] let map = self.read.map_while( &mut self.inner.idx, Some(max), - |_, v| match v { - b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F' => true, - _ => false, - }, + |_, v| matches!(v, b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F'), )?; if self.inner.idx != idx_start.strict_add(4) { @@ -680,14 +672,14 @@ impl<'read> Dec<'read> { let map = self.read.map_while( &mut self.inner.idx, Some(max), - |idx, v| match (idx.strict_sub(idx_start), v) { - (0, b'\\') | (1, b'u') => true, - ( + |idx, v| matches!( + (idx.strict_sub(idx_start), v), + (0, b'\\') | (1, b'u') + | ( 2..=5, b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F' - ) => true, - _ => false, - }, + ), + ), )?; if self.inner.idx != idx_start.strict_add(6) { @@ -831,7 +823,9 @@ impl<'read> Dec<'read> { (polonius) { v }, { // SAFETY: Workaround for NLL, unneeded with Polonius. - unsafe { core::mem::transmute(v) } + unsafe { + core::mem::transmute::, Token<'this>>(v) + } }, } }; diff --git a/lib/tmp/src/io/map.rs b/lib/tmp/src/io/map.rs index f14822a..cfc076d 100644 --- a/lib/tmp/src/io/map.rs +++ b/lib/tmp/src/io/map.rs @@ -63,6 +63,12 @@ pub trait Read { /// `Write` allows chunked mutable access to logically linear data. pub trait Write { + /// Commit data + /// + /// ## Safety + /// + /// The caller must ensure that the first `len` bytes of the map have been + /// initialized via [`Self::map()`] or one of its derivatives. unsafe fn commit(&mut self, len: usize); fn map(&mut self, idx: usize, len: usize) -> Flow, &mut [Uninit]>; diff --git a/lib/tmp/src/io/stream.rs b/lib/tmp/src/io/stream.rs index 6f1d09c..a76f4e1 100644 --- a/lib/tmp/src/io/stream.rs +++ b/lib/tmp/src/io/stream.rs @@ -234,7 +234,7 @@ impl<'this> dyn Read + 'this { } } -impl<'data> Read for &'data [u8] { +impl Read for &[u8] { fn advance(&mut self, len: usize) { let v = core::mem::take(self); *self = &v[len..]; @@ -302,7 +302,7 @@ mod test { // Discard the previous temporary values and rewrite the next 16 values // again starting at 0 and immediately commit it. - let _ = vec.write( + vec.write( &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], ).continue_value().unwrap(); diff --git a/lib/util/cargo-query.py b/lib/util/cargo-query.py new file mode 100755 index 0000000..73f0096 --- /dev/null +++ b/lib/util/cargo-query.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# +# Parse `Cargo.toml` of the workspace and each package. Extract all data +# relevant to the Meson integration. +# +# Data is printed on `stdout`, for easy consumption in Meson. Note that +# Meson still lacks any parser for structured input like JSON, so instead +# newline and comma separated values are used. Since input is trusted and +# contains no comma or newline, this is safe (it would still be much nicer +# if we could use JSON). +# + +import os +import tomllib + +def toml_lints(toml): + groups = ['clippy', 'rust'] + acc_allow = '' + for g in groups: + for k in toml_ws['workspace']['lints'][g]: + v = toml_ws['workspace']['lints'][g][k] + level = v['level'] if isinstance(v, dict) else v + if level == 'allow': + acc_allow += ',' if acc_allow else '' + acc_allow += 'clippy::' + k + return acc_allow + +def toml_version(toml): + return toml['package']['version'] + +if __name__ == "__main__": + path_ws = os.environ.get('PATH_WS', '.') + + path_cargo_ws = os.path.join(path_ws, 'Cargo.toml') + path_cargo_osi = os.path.join(path_ws, 'lib/osi/Cargo.toml') + path_cargo_sys = os.path.join(path_ws, 'lib/sys/Cargo.toml') + path_cargo_tmp = os.path.join(path_ws, 'lib/tmp/Cargo.toml') + + with open(path_cargo_ws, mode="rb") as f: + toml_ws = tomllib.load(f) + with open(path_cargo_osi, mode="rb") as f: + toml_osi = tomllib.load(f) + with open(path_cargo_sys, mode="rb") as f: + toml_sys = tomllib.load(f) + with open(path_cargo_tmp, mode="rb") as f: + toml_tmp = tomllib.load(f) + + print(toml_version(toml_osi)) + print(toml_version(toml_sys)) + print(toml_version(toml_tmp)) + print(toml_lints(toml_ws)) diff --git a/lib/util/cargo-query.sh b/lib/util/cargo-query.sh deleted file mode 100755 index f156ffc..0000000 --- a/lib/util/cargo-query.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Run `cargo metadata` to figure out metadata from a Cargo package, which we -# use in external utilities. Print this on `stdout` and exit with 0. -# -# Paths to `cargo`, `jq`, and the manifest can be passed via environment -# variables. - -set -eo pipefail - -BIN_CARGO="${BIN_CARGO:-"cargo"}" -BIN_JQ="${BIN_JQ:-"jq"}" -PATH_CARGO_TOML="${PATH_CARGO_TOML:-"./Cargo.toml"}" - -MD=$(${BIN_CARGO} \ - metadata \ - --format-version 1 \ - --frozen \ - --manifest-path "${PATH_CARGO_TOML}" \ - --no-deps \ -) - -${BIN_JQ} \ - <<<"${MD}" \ - -cer \ - '.packages | map(select(.name == "osi")) | .[0].version' - -${BIN_JQ} \ - <<<"${MD}" \ - -cer \ - '.packages | map(select(.name == "sys")) | .[0].version' - -${BIN_JQ} \ - <<<"${MD}" \ - -cer \ - '.packages | map(select(.name == "tmp")) | .[0].version' diff --git a/meson.build b/meson.build index bdfc644..55187e8 100644 --- a/meson.build +++ b/meson.build @@ -28,16 +28,13 @@ if rust.version().version_compare('<' + rust_msv) error('Found Rust ' + rust.version() + ' but requires >=' + rust_msv) endif -cargo = find_program('cargo', native: true, required: true, version: '>=' + rust_msv) -jq = find_program('jq', native: true, required: true, version: '>=1.6') - # # Import cargo metadata # q = run_command( [ - './lib/util/cargo-query.sh', + './lib/util/cargo-query.py', # The script does not use any of these arguments, but meson # thinks it does, and triggers a reconfiguration if they @@ -51,15 +48,14 @@ q = run_command( capture: true, check: true, env: { - 'BIN_CARGO': cargo.full_path(), - 'BIN_JQ': jq.full_path(), - 'PATH_CARGO_TOML': meson.current_source_dir() / 'Cargo.toml', + 'PATH_WS': meson.current_source_dir(), }, ).stdout().splitlines() libosi_version = q[0] libsys_version = q[1] libtmp_version = q[2] +ws_lints = q[3] libosi_major = libosi_version.split('.')[0] libsys_major = libsys_version.split('.')[0] @@ -102,6 +98,10 @@ rlib_rust_args = [ '--check-cfg=cfg(test)', ] +foreach v: ws_lints.split(',') + rlib_rust_args += ['-A', v] +endforeach + # # Target: libosi #