aboutsummaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-05-14 19:36:19 -0600
committerMelody Horn <melody@boringcactus.com>2021-05-14 19:36:19 -0600
commit0e2632a72f9d59d27b6938ce770e6ebf497458c9 (patch)
tree325761c063300478901160bfacea7e3dc1c4e527 /build.rs
parentca72a896dcbf631971a564413bd684bb637b747e (diff)
downloadtcl-sys-0e2632a72f9d59d27b6938ce770e6ebf497458c9.tar.gz
tcl-sys-0e2632a72f9d59d27b6938ce770e6ebf497458c9.zip
pass the tests locally on linux-gnu
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs44
1 files changed, 36 insertions, 8 deletions
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
}
}