Skip to content
Open
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
25 changes: 22 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ on:
branches: [ master ]

jobs:
build:

linux:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Prepare dependencies
Expand All @@ -19,3 +17,24 @@ jobs:
run: cargo build --verbose --all
- name: Run tests
run: cargo test --verbose --all

windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Prepare dependencies
shell: powershell
run: |
Install-Module 7Zip4PowerShell -Force -Verbose
mkdir C:\Cbc
Invoke-WebRequest "https://bintray.com/coin-or/download/download_file?file_path=Cbc-2.9-win32-msvc14.zip" -OutFile "C:\Cbc\Cbc-2.9.zip"
7z x C:\Cbc\Cbc-2.9.zip -o"C:\Cbc\"
Get-ChildItem -Path "C:\Cbc"
Get-ChildItem -Path "C:\Cbc\lib"
echo "C:\Cbc\lib" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo $env:GITHUB_PATH
type $env:GITHUB_PATH
- name: Build
run: cargo build --verbose --all
- name: Run tests
run: cargo test --verbose --all
2 changes: 2 additions & 0 deletions coin_cbc_sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ repository = "https://github.com/KardinalAI/coin_cbc"
keywords = ["MILP", "MIP", "linear programming"]
categories = ["external-ffi-bindings", "mathematics", "science"]
license = "MIT "
build = "build.rs"
links = "CbcSolver"
22 changes: 22 additions & 0 deletions coin_cbc_sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
fn main() {
use std::env;

let is_linux = env::var("CARGO_CFG_UNIX");
if is_linux.is_ok() {
println!("cargo:rustc-link-lib=CbcSolver");
return;
}

let is_win = env::var("CARGO_CFG_WINDOWS");
if is_win.is_ok() {
println!("cargo:rustc-link-lib=libCbcSolver");
let path = env::var("PATH");
if let Ok(ok_path) = path {
let cbc_path = ok_path.split(";").find(|&s| s.contains("Cbc"));
if let Some(final_path) = cbc_path {
println!("cargo:rustc-link-search={}", final_path);
}
}
return;
}
}
3 changes: 1 addition & 2 deletions coin_cbc_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ pub type cbc_callback = Option<
),
>;

#[link(name = "CbcSolver")]
extern "C" {
extern "system" {
pub fn Cbc_newModel() -> *mut Cbc_Model;
pub fn Cbc_deleteModel(model: *mut Cbc_Model);
pub fn Cbc_getVersion() -> *const c_char;
Expand Down