mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
refactor: rewrite
This commit is contained in:
25
gpservice/build.rs
Normal file
25
gpservice/build.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use common::sha256_digest;
|
||||
use std::path::Path;
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
let gpservice_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
let profile = env::var("PROFILE").unwrap();
|
||||
let gpclient_path = Path::new(&gpservice_dir)
|
||||
.join("../target")
|
||||
.join(profile)
|
||||
.join("gpclient");
|
||||
|
||||
if !gpclient_path.exists() {
|
||||
// error if gpclient doesn't exist
|
||||
panic!("Please build gpclient first");
|
||||
}
|
||||
|
||||
if let Ok(digest) = sha256_digest(gpclient_path) {
|
||||
let out_dir = env::var("OUT_DIR").unwrap();
|
||||
let dest_path = format!("{out_dir}/client_hash.rs");
|
||||
fs::write(dest_path, format!("pub const GPCLIENT_HASH: &str = \"{digest}\";")).unwrap();
|
||||
} else {
|
||||
panic!("Error: Unable to get gpclient hash");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user