remove anyhow dep from build.rs

This commit is contained in:
iliana etaoin 2023-04-06 20:31:05 -07:00
parent 9242cbb09e
commit 310886f2ca
2 changed files with 13 additions and 12 deletions

View File

@ -18,5 +18,4 @@ serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["rt-multi-thread"] }
[build-dependencies]
anyhow = "1"
zip = { version = "0.6", default-features = false, features = ["deflate"] }

View File

@ -1,31 +1,33 @@
use anyhow::{ensure, Result};
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use zip::ZipWriter;
fn main() -> Result<()> {
fn main() {
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty"])
.output()?;
ensure!(output.status.success(), "unsuccessful");
.output()
.unwrap();
if !output.status.success() {
panic!("cargo package failed");
}
let mut writer = ZipWriter::new(File::create(out_dir.join("source.zip"))?);
for path in String::from_utf8(output.stdout)?.lines() {
let mut writer = ZipWriter::new(File::create(out_dir.join("source.zip")).unwrap());
for path in String::from_utf8(output.stdout).unwrap().lines() {
if path == "Cargo.toml.orig" {
continue;
}
writer.start_file(path, Default::default())?;
writer.start_file(path, Default::default()).unwrap();
io::copy(
&mut File::open(Path::new(env!("CARGO_MANIFEST_DIR")).join(path))?,
&mut File::open(Path::new(env!("CARGO_MANIFEST_DIR")).join(path)).unwrap(),
&mut writer,
)?;
)
.unwrap();
}
writer.finish()?;
Ok(())
writer.finish().unwrap();
}