From 167d83ca4521e7e604747142d2a2b79ecb3f7677 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Fri, 14 May 2021 21:36:50 -0600 Subject: provide stdlib --- build.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'build.rs') diff --git a/build.rs b/build.rs index acbf264..8baa99f 100644 --- a/build.rs +++ b/build.rs @@ -199,6 +199,7 @@ fn main() { generate_bindings(target.as_str(), host.as_str(), include_paths.as_slice()); link_tcl(target_os); + compress_stdlib(tcl_lib_path.join("tcl8.6")); println!("cargo:rerun-if-changed=build.rs"); } @@ -250,6 +251,26 @@ fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) { .expect("Couldn't write bindings!"); } +fn compress_stdlib(stdlib_root: PathBuf) { + let out_dir = env::var("OUT_DIR").unwrap(); + let tcl_stdlib_archive_path = Path::new(&out_dir).join("stdlib.tar.gz"); + let writer = flate2::write::GzEncoder::new( + fs::File::create(tcl_stdlib_archive_path).unwrap(), + flate2::Compression::best(), + ); + let mut ar = tar::Builder::new(writer); + + for child in stdlib_root.read_dir().unwrap() { + let child = child.unwrap(); + if child.path().is_dir() { + ar.append_dir_all(child.file_name(), child.path()).unwrap(); + } else { + ar.append_path_with_name(child.path(), child.file_name()) + .unwrap(); + } + } +} + fn get_os_from_triple(triple: &str) -> Option<&str> { triple.splitn(3, "-").nth(2) } -- cgit v1.2.3