fix(tfhe-lints): linter was not run, missing compile time env var

This commit is contained in:
Nicolas Sarlin
2024-12-05 14:11:54 +01:00
committed by Nicolas Sarlin
parent 3dcf7f2492
commit e363b76f17
4 changed files with 21 additions and 9 deletions

View File

@@ -27,6 +27,11 @@ fn main() {
(tool_args.as_slice(), &[] as &[String])
};
// The linter calls rustc without cargo, so these variables won't be set. Since we use them in
// our code, we need to set them to any value to avoid a compilation error.
std::env::set_var("CARGO_PKG_VERSION_MAJOR", "X");
std::env::set_var("CARGO_PKG_VERSION_MINOR", "Y");
rustc_tools::cargo_integration(&cargo_args, |args| {
let mut args = args.to_vec();
args.extend(rustc_args.iter().skip(1).cloned());

View File

@@ -1,4 +1,7 @@
use std::process::{exit, Command};
use std::{
io::{Error, ErrorKind},
process::{exit, Command},
};
fn get_supported_rustc_version() -> &'static str {
const TOOLCHAIN_FILE: &str = include_str!("../../cargo-tfhe-lints-inner/rust-toolchain.toml");
@@ -26,8 +29,17 @@ fn main() {
.arg(toolchain.as_str())
.arg("tfhe-lints-inner")
.args(&cargo_args)
.spawn()
.and_then(|mut child| child.wait())
.status()
.and_then(|res| {
if !res.success() {
Err(Error::new(
ErrorKind::Other,
format!("Inner process failed with {res}"),
))
} else {
Ok(())
}
})
{
eprintln!(
"Command `cargo {toolchain} tfhe-lints-inner {}` failed: {err:?}",