Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vendor shared lib files #2

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5ab8f43
Add macos scipoptsuite lib files
mmghannam Jul 17, 2023
fb9e7f7
Add a simple testing github action
mmghannam Jul 17, 2023
75de227
-a
mmghannam Jul 17, 2023
364efbd
-a
mmghannam Jul 17, 2023
658d3b2
Fix workflow syntax error
mmghannam Jul 17, 2023
8ce73de
Clang arg to link against lib files
mmghannam Jul 17, 2023
3ed1880
Remove library symlink
mmghannam Jul 17, 2023
7dd95be
WIP
mmghannam Jul 17, 2023
12bbd46
WIP
mmghannam Jul 17, 2023
ed2fddc
WIP
mmghannam Jul 17, 2023
fdd0f29
Add linux lib files
mmghannam Jul 17, 2023
3d7e42d
Add linux github action
mmghannam Jul 17, 2023
dea66d3
Install linux dependencies
mmghannam Jul 17, 2023
a7a94f1
Update github action for checkout
mmghannam Jul 17, 2023
16c912d
Trial
mmghannam Jul 20, 2023
e3a98a5
Fix folder name
mmghannam Jul 20, 2023
b550a38
Use full path
mmghannam Jul 20, 2023
12ba153
Fix: Use full path
mmghannam Jul 20, 2023
3c8a148
Fix compile error
mmghannam Jul 20, 2023
fe7665c
Use lib files from precompiled package
mmghannam Jul 20, 2023
4420881
Trial
mmghannam Jul 20, 2023
e328561
Another trial
mmghannam Jul 20, 2023
55da350
Try linux
mmghannam Jul 20, 2023
d607c88
Try ubuntu 20
mmghannam Jul 20, 2023
250e210
Another trial for macos
mmghannam Jul 20, 2023
e91639d
Fix library loading in macos
mmghannam Jul 20, 2023
50f0cd0
Add a warning for macos
mmghannam Jul 21, 2023
ef5c3cc
Add debian test
mmghannam Jul 21, 2023
a6d0b7b
Another trial for debian
mmghannam Jul 21, 2023
bf6d32c
Remove sudo
mmghannam Jul 21, 2023
f78f17d
Trial
mmghannam Jul 21, 2023
4931712
Add rust
mmghannam Jul 21, 2023
2e096a6
Add curl
mmghannam Jul 21, 2023
87f6fcc
Add clang
mmghannam Jul 21, 2023
c9c0897
Use other libtbb
mmghannam Jul 21, 2023
0f8eb77
Trial
mmghannam Jul 21, 2023
7674812
Add lib files for debian
mmghannam Jul 21, 2023
2663cb3
Trial
mmghannam Jul 21, 2023
08c05ad
Use debian bullseye
mmghannam Jul 21, 2023
8422239
Try libtbb2 again
mmghannam Jul 21, 2023
d49c2c3
Uncomment macos job
mmghannam Jul 21, 2023
b9d54b4
Download scip lib files from github
mmghannam Sep 10, 2023
49c9384
Fix libs path and simplify code
mmghannam Sep 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
51 changes: 51 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: build_and_test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
macos-test:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Test
run: |
export DYLD_LIBRARY_PATH=${{ github.workspace }}/lib/macos/:$DYLD_LIBRARY_PATH
cargo test version

linux-test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Test
run: |
sudo apt install -y gcc g++ gfortran liblapack3 libtbb2 libcliquer1 libopenblas-dev libgsl23 patchelf
cargo test version


debian-test:
runs-on: ubuntu-20.04
container:
image: debian:bullseye
env:
RUSTFLAGS: "-C link-arg=-Wl,-rpath,/usr/lib/x86_64-linux-gnu"
LD_LIBRARY_PATH: "/usr/lib/x86_64-linux-gnu"
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
apt-get update
apt-get install -y gcc g++ gfortran liblapacke libtbb2 libcliquer1 libopenblas-dev libgsl-dev patchelf curl clang libclang-dev
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Test
run: |
cargo test version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
target
Cargo.lock
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ repository = "https://github.com/scipopt/scip-sys"
license = "Apache-2.0"
links = "scip"

[dependencies]

[build-dependencies]
bindgen = "0.64"
bindgen = "0.68"
cc = "1.0.73"
glob = "0.3.1"
glob = "0.3.1"
os_info = { version = "3", default-features = false }
flate2 = "1.0.27"
tar = "0.4.40"
83 changes: 60 additions & 23 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,64 @@
extern crate bindgen;

use glob::glob;
use flate2::read::GzDecoder;
use std::env;
use std::error::Error;
use std::fs::File;
use std::path::PathBuf;
use std::process::Stdio;
use tar::Archive;

use glob::glob;

// Download libscip files from GitHub releases
fn download_lib_files() -> Result<String, Box<dyn Error>> {
let info = os_info::get();
println!("cargo:warning=Detected OS: {}", info.os_type());

let os = match info.os_type() {
os_info::Type::Ubuntu => "linux-gnu-cxx11",
os_info::Type::Macos => "apple-darwin",
os_info::Type::Windows => "w64-mingw32-cxx11",
os => panic!("Unsupported OS: {}", os),
};

let arch = std::env::consts::ARCH;
println!("cargo:warning=Detected arch: {}", arch);

let url_base = "https://github.com/JuliaBinaryWrappers/SCIP_jll.jl/releases/download/SCIP-v800.0.301%2B0/SCIP.v800.0.301.";
let url = format!("{}{}-{}.tar.gz", url_base, arch, os);

let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = PathBuf::from(out_dir);
let out_dir = out_dir.join("lib");
let out_dir = out_dir.to_str().unwrap();

// Download libscip files using curl
println!("cargo:warning=Downloading libscip files from {}", url);
let output = std::process::Command::new("curl")
.args(&["-L", &url, "-o", "libscip.tar.gz"])
.stdout(Stdio::null())
.stderr(Stdio::null())
.output()
.map_err(|e| format!("Failed to download libscip files: {}", e))?;

if !output.status.success() {
panic!("Failed to download libscip files");
}

// Extract libscip files
println!("cargo:warning=Extracting libscip files to {}", out_dir);
let tar_gz = File::open("libscip.tar.gz")?;
let tar = GzDecoder::new(tar_gz);
let mut archive = Archive::new(tar);
archive.unpack(out_dir)?;

println!("cargo:warning=libscip files extracted to {}", out_dir);
println!("cargo:warning=cleaning up libscip.tar.gz");
std::fs::remove_file("libscip.tar.gz")?;

Ok(out_dir.to_owned())
}

fn _build_from_scip_dir(path: String) -> bindgen::Builder {
let lib_dir = PathBuf::from(&path).join("lib");
Expand All @@ -21,7 +76,7 @@ fn _build_from_scip_dir(path: String) -> bindgen::Builder {
)
);
}
println!("cargo:rustc-link-search={}", lib_dir_path);
println!("cargo:rustc-link-search={}/lib", lib_dir_path);
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir_path);

let include_dir = PathBuf::from(&path).join("include");
Expand Down Expand Up @@ -74,27 +129,9 @@ fn main() -> Result<(), Box<dyn Error>> {
}

if !found_scip {
println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt, looking for SCIP in system libraries");

let headers_dir_path = "headers/";
let headers_dir = PathBuf::from(headers_dir_path);
let scip_header_file = PathBuf::from(&headers_dir)
.join("scip")
.join("scip.h")
.to_str()
.unwrap()
.to_owned();
let scipdefplugins_header_file = PathBuf::from(&headers_dir)
.join("scip")
.join("scipdefplugins.h")
.to_str()
.unwrap()
.to_owned();
builder = bindgen::Builder::default()
.header(scip_header_file)
.header(scipdefplugins_header_file)
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.clang_arg(format!("-I{}", headers_dir_path));
println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt, downloading SCIP from GitHub releases");
let lib_path = download_lib_files().unwrap();
builder = _build_from_scip_dir(lib_path);
}

println!("cargo:rustc-link-lib=scip");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading