Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ keywords = ["linear-programming", "optimization", "math", "solver"]
bindgen = "0.71.1"
cmake = { version = "0.1.49", optional = true }
pkg-config = { version = "0.3.27", optional = true }
ureq = { version = "2.0", optional = true }
tempfile = { version = "3.0", optional = true }
flate2 = { version = "1.0", optional = true }
tar = { version = "0.4", optional = true }

[features]
default = ["build", "highs_release"]
discover = ["dep:pkg-config"]
build = ["dep:cmake"]
bundled = ["dep:ureq", "dep:tempfile", "dep:flate2", "dep:tar"]
highs_release = []
ninja = []
libz = []
45 changes: 2 additions & 43 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::env;
use std::path::{Path, PathBuf};

mod download;

fn generate_bindings<'a>(include_paths: impl Iterator<Item = &'a Path>) {
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
Expand Down Expand Up @@ -102,45 +100,6 @@ fn discover() -> bool {
false
}

#[cfg(feature = "bundled")]
fn bundled() -> bool {
download::download_highs();

let out_dir = env::var("OUT_DIR").unwrap();
let install_path = PathBuf::from(&out_dir).join("highs_install");

// The binary structure after extraction should contain include and lib directories
let include_path = install_path.join("include").join("highs");
let lib_path = install_path.join("lib");

if !include_path.exists() || !lib_path.exists() {
panic!("Downloaded HiGHS binary doesn't contain expected include or lib directories");
}

generate_bindings(Some(include_path.as_path()).into_iter());

println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=dylib=highs");

let target = env::var("TARGET").unwrap();
let apple = target.contains("apple");
let linux = target.contains("linux");
let mingw = target.contains("pc-windows-gnu");

if apple {
println!("cargo:rustc-link-lib=dylib=c++");
} else if linux || mingw {
println!("cargo:rustc-link-lib=dylib=stdc++");
}

true
}

#[cfg(not(feature = "bundled"))]
fn bundled() -> bool {
false
}

fn main() {
if cfg!(all(
any(
Expand All @@ -154,7 +113,7 @@ fn main() {
Thus, your features will never have any effect. Please enable the 'build' feature on highs-sys if you want to build HiGHS or disable the 'libz', 'ninja' and 'highs_release' features.");
}

if !discover() && !bundled() && !build() {
panic!("Could neither discover, download bundled binary, nor build HiGHS");
if !discover() && !build() {
panic!("Could neither discover nor build HiGHS");
}
}
109 changes: 0 additions & 109 deletions download.rs

This file was deleted.

Loading