Jobboerse/packages/jobboerse/build.rs
Skgland d3c5453d47
fix clippy for rust 1.64
- newer versions may still lint
2023-01-28 19:46:13 +01:00

43 lines
1.4 KiB
Rust

// https://doc.rust-lang.org/cargo/reference/build-scripts.html
use std::fs::File;
use std::io::{BufReader, BufWriter};
use std::path::Path;
fn main() -> Result<(), std::io::Error> {
let mut logger_builder = pretty_env_logger::formatted_builder();
logger_builder
.filter_level(log::LevelFilter::Error)
.format_timestamp_secs();
if let Ok(value) = std::env::var("RUST_LOG") {
logger_builder.parse_filters(&value);
}
logger_builder.init();
let out_dir = std::env::var("OUT_DIR").unwrap();
let licenses = Path::new(&out_dir).join("licenses.toml");
let thirdparty = Path::new("THIRDPARTY.toml");
println!("cargo:rerun-if-changed=Cargo.lock");
println!("cargo:rerun-if-changed=THIRDPARTY.toml");
let input = BufReader::new(File::open(thirdparty)?);
#[allow(clippy::expect_fun_call)]
let previous = bundle_licenses_lib::format::Format::Toml
.deserialize_from_reader(input)
.expect(&format!(
"{} file is valid toml containing the bundle licenses information",
thirdparty.display()
));
let bundle =
bundle_licenses_lib::bundle::BundleBuilder::exec_with_previous(Some(&previous)).unwrap();
let output = BufWriter::new(File::create(licenses)?);
bundle_licenses_lib::format::Format::Toml
.serialize_to_writer(output, &bundle)
.unwrap();
Ok(())
}