remove anyhow dep from build.rs
This commit is contained in:
parent
9242cbb09e
commit
310886f2ca
|
@ -18,5 +18,4 @@ serde = { version = "1", features = ["derive"] }
|
||||||
tokio = { version = "1", features = ["rt-multi-thread"] }
|
tokio = { version = "1", features = ["rt-multi-thread"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "1"
|
|
||||||
zip = { version = "0.6", default-features = false, features = ["deflate"] }
|
zip = { version = "0.6", default-features = false, features = ["deflate"] }
|
||||||
|
|
24
build.rs
24
build.rs
|
@ -1,31 +1,33 @@
|
||||||
use anyhow::{ensure, Result};
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use zip::ZipWriter;
|
use zip::ZipWriter;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() {
|
||||||
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
|
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
|
||||||
|
|
||||||
let output = Command::new("cargo")
|
let output = Command::new("cargo")
|
||||||
.args(["package", "--list", "--allow-dirty"])
|
.args(["package", "--list", "--allow-dirty"])
|
||||||
.output()?;
|
.output()
|
||||||
ensure!(output.status.success(), "unsuccessful");
|
.unwrap();
|
||||||
|
if !output.status.success() {
|
||||||
|
panic!("cargo package failed");
|
||||||
|
}
|
||||||
|
|
||||||
let mut writer = ZipWriter::new(File::create(out_dir.join("source.zip"))?);
|
let mut writer = ZipWriter::new(File::create(out_dir.join("source.zip")).unwrap());
|
||||||
for path in String::from_utf8(output.stdout)?.lines() {
|
for path in String::from_utf8(output.stdout).unwrap().lines() {
|
||||||
if path == "Cargo.toml.orig" {
|
if path == "Cargo.toml.orig" {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.start_file(path, Default::default())?;
|
writer.start_file(path, Default::default()).unwrap();
|
||||||
io::copy(
|
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,
|
&mut writer,
|
||||||
)?;
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.finish()?;
|
writer.finish().unwrap();
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue