diff options
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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) } |