diff options
author | Melody Horn <melody@boringcactus.com> | 2021-05-14 21:36:50 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-05-14 21:36:50 -0600 |
commit | 167d83ca4521e7e604747142d2a2b79ecb3f7677 (patch) | |
tree | 72527056f88a0676953442ab5357423e9eda7167 /build.rs | |
parent | c6a84931c7489d72112ac13b7e597c3a456ef770 (diff) | |
download | tcl-sys-167d83ca4521e7e604747142d2a2b79ecb3f7677.tar.gz tcl-sys-167d83ca4521e7e604747142d2a2b79ecb3f7677.zip |
provide stdlib
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) } |