Skip to content

Commit a4b7ee3

Browse files
committed
build: fixes for newer Rust
Adapt newest best practices according to Clippy, fix compiler warnings. Also build mbedTLS concurrently for faster CI builds. Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
1 parent ade6f06 commit a4b7ee3

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

ci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ git clone https://github.com/ARMmbed/mbedtls.git
5959
pushd mbedtls
6060
git checkout v3.0.0
6161
./scripts/config.py crypto
62-
SHARED=1 make
62+
SHARED=1 make -j$(nproc)
6363
popd
6464

6565
# Clean before to only build the interface

psa-crypto-sys/build.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ mod common {
160160
) -> Result<()> {
161161
let header = mbed_include_dir.clone() + "/psa/crypto.h";
162162

163-
println!("using mbedtls include directory of: {}", mbed_include_dir);
164-
println!("cargo:rerun-if-changed={}", header);
163+
println!("using mbedtls include directory of: {mbed_include_dir}");
164+
println!("cargo:rerun-if-changed={header}");
165165

166166
let out_dir = env::var("OUT_DIR").unwrap();
167167

168168
// Common shim builder settings
169169
let mut shim_builder = bindgen::Builder::default()
170-
.clang_arg(format!("-I{}", out_dir))
171-
.clang_arg(format!("-I{}", mbed_include_dir))
170+
.clang_arg(format!("-I{out_dir}"))
171+
.clang_arg(format!("-I{mbed_include_dir}"))
172172
.header("src/c/shim.h")
173173
.blocklist_type("max_align_t")
174174
.generate_comments(false)
@@ -181,7 +181,7 @@ mod common {
181181

182182
if !external_mbedtls {
183183
shim_builder =
184-
shim_builder.clang_arg(format!("-DMBEDTLS_CONFIG_FILE=\"{}\"", CONFIG_FILE));
184+
shim_builder.clang_arg(format!("-DMBEDTLS_CONFIG_FILE=\"{CONFIG_FILE}\""));
185185
}
186186

187187
// Build the bindings
@@ -219,7 +219,7 @@ mod common {
219219
.cargo_metadata(metadata);
220220

221221
if !external_mbedtls {
222-
_ = cfg.flag(&format!("-DMBEDTLS_CONFIG_FILE=\"{}\"", CONFIG_FILE));
222+
_ = cfg.flag(format!("-DMBEDTLS_CONFIG_FILE=\"{CONFIG_FILE}\""));
223223
}
224224

225225
cfg.try_compile(shimlib_name)
@@ -319,7 +319,7 @@ mod operations {
319319

320320
// Build the MbedTLS libraries
321321
let mbed_build_path = Config::new(&mbedtls_dir)
322-
.cflag(format!("-I{}", out_dir))
322+
.cflag(format!("-I{out_dir}"))
323323
.cflag(format!(
324324
"-DMBEDTLS_CONFIG_FILE='\"{}\"'",
325325
common::CONFIG_FILE
@@ -336,8 +336,8 @@ mod operations {
336336
let link_type = if link_statically { "static" } else { "dylib" };
337337

338338
// Request rustc to link the Mbed Crypto library
339-
println!("cargo:rustc-link-search=native={}", lib_path,);
340-
println!("cargo:rustc-link-lib={}=mbedcrypto", link_type);
339+
println!("cargo:rustc-link-search=native={lib_path}",);
340+
println!("cargo:rustc-link-lib={link_type}=mbedcrypto");
341341
}
342342

343343
#[cfg(not(feature = "prefix"))]

psa-crypto-sys/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
trivial_casts
2222
)]
2323
#[allow(clippy::all)]
24+
#[allow(unknown_lints)] // unnecessary_transmutes is only present in 1.88+
25+
#[allow(unnecessary_transmutes)]
2426
#[cfg(feature = "interface")]
2527
mod psa_crypto_binding {
2628
#![allow(unused_imports)]

psa-crypto/src/types/key.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Attributes {
6060
/// }),
6161
/// },
6262
/// };
63-
63+
///
6464
/// // Can not export because the export flag is set to false.
6565
/// attributes.can_export().unwrap_err();
6666
/// ```
@@ -237,7 +237,7 @@ impl Attributes {
237237
/// permitted_algorithms: permitted_alg,
238238
/// },
239239
/// };
240-
240+
///
241241
/// assert!(attributes.is_compatible_with_alg(alg));
242242
/// attributes.key_type = Type::RsaPublicKey;
243243
/// assert!(attributes.is_compatible_with_alg(alg));
@@ -562,15 +562,15 @@ impl fmt::Display for Type {
562562
Type::Chacha20 => write!(f, "Key for an algorithm based on ChaCha20"),
563563
Type::RsaPublicKey => write!(f, "RSA public key"),
564564
Type::RsaKeyPair => write!(f, "RSA key pair"),
565-
Type::EccKeyPair { curve_family } => write!(f, "ECC key pair (using {})", curve_family),
565+
Type::EccKeyPair { curve_family } => write!(f, "ECC key pair (using {curve_family})"),
566566
Type::EccPublicKey { curve_family } => {
567-
write!(f, "ECC public key (using {})", curve_family)
567+
write!(f, "ECC public key (using {curve_family})")
568568
}
569569
Type::DhKeyPair { group_family } => {
570-
write!(f, "Diffie-Hellman key pair (using {})", group_family)
570+
write!(f, "Diffie-Hellman key pair (using {group_family})")
571571
}
572572
Type::DhPublicKey { group_family } => {
573-
write!(f, "Diffie-Hellman public key (using {})", group_family)
573+
write!(f, "Diffie-Hellman public key (using {group_family})")
574574
}
575575
}
576576
}

0 commit comments

Comments
 (0)