aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml6
-rw-r--r--build.rs44
2 files changed, 40 insertions, 10 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 0050fd5..53943d1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,10 +3,12 @@ name = "tcl-sys"
version = "0.1.0"
authors = ["Melody Horn <melody@boringcactus.com>"]
edition = "2018"
+description = "bindings to the Tcl C API"
+license = "BlueOak-1.0.0"
+keywords = ["tcl", "bindings"]
+categories = ["external-ffi-bindings"]
links = "tcl"
-# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
[dependencies]
libc = "0.2.94"
diff --git a/build.rs b/build.rs
index 4234c90..f0c42a4 100644
--- a/build.rs
+++ b/build.rs
@@ -90,6 +90,7 @@ fn download_tcl() -> PathBuf {
// compile a static lib
fn compile_tcl(tcl_build_path: &Path, target_os: &str) -> PathBuf {
let out_dir = env::var("OUT_DIR").unwrap();
+ let install_dir = Path::new(&out_dir).join("install");
if target_os == "windows-msvc" {
let vswhere =
Command::new(r"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe")
@@ -111,12 +112,11 @@ fn compile_tcl(tcl_build_path: &Path, target_os: &str) -> PathBuf {
if vs_root.lines().count() != 1 {
panic!("vswhere found multiple roots??");
}
- let install_dir = Path::new(&out_dir).join("install");
// TODO i am going to stab a bitch why is this the easiest way to do this
let bat = format!(
r#"
call "{}\Common7\Tools\VSDevCmd.bat" -arch=amd64 -host_arch=amd64
- nmake -nologo -f makefile.vc release install OPTS=msvcrt,static,staticpkg "INSTALLDIR={}"
+ nmake -nologo -f makefile.vc shell install OPTS=msvcrt,static,staticpkg "INSTALLDIR={}"
"#,
vs_root,
install_dir.to_str().unwrap(),
@@ -131,24 +131,52 @@ fn compile_tcl(tcl_build_path: &Path, target_os: &str) -> PathBuf {
.status()
.unwrap();
if !build.success() {
- panic!("nmake failed??")
+ panic!("nmake failed??");
}
- install_dir
+ } else if target_os == "windows-gnu" {
+ todo!("need to run configure in bash but how to find bash??")
} else {
- todo!()
+ let unix_dir = tcl_build_path.join("unix");
+ let configure = Command::new("./configure")
+ .args(&[
+ &format!("--prefix={}", install_dir.to_str().unwrap()),
+ "--enable-shared=no",
+ ])
+ .current_dir(&unix_dir)
+ .status()
+ .unwrap();
+ if !configure.success() {
+ panic!("configure failed??");
+ }
+ let make = Command::new("make")
+ .args(&["binaries", "install"])
+ .current_dir(&unix_dir)
+ .status()
+ .unwrap();
+ if !make.success() {
+ panic!("make failed??");
+ }
}
+ install_dir
}
fn link_tcl(target_os: &str) {
- println!("cargo:rustc-link-lib=static=tcl86tsx");
- println!("cargo:rustc-link-lib=static=tclstub86");
+ if target_os == "windows-msvc" {
+ println!("cargo:rustc-link-lib=static=tcl86tsx");
+ println!("cargo:rustc-link-lib=static=tclstub86");
+ } else if target_os == "windows-gnu" {
+ todo!("which things get built under msys")
+ } else {
+ println!("cargo:rustc-link-lib=static=tcl8.6");
+ println!("cargo:rustc-link-lib=static=tclstub8.6");
+ }
// Also linked to any required libraries for each supported platform
if target_os.contains("windows") {
println!("cargo:rustc-link-lib=user32");
println!("cargo:rustc-link-lib=netapi32");
} else {
- // TODO: Add other platform linker options here.
+ println!("cargo:rustc-link-lib=z"); // TODO does this always get used or only sometimes
}
}