Skip to content

Commit

Permalink
fixing windows path
Browse files Browse the repository at this point in the history
  • Loading branch information
EdorianDark committed Oct 25, 2020
1 parent ec8c376 commit a755ab0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
19 changes: 8 additions & 11 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 @@ -21,9 +19,7 @@ jobs:
run: cargo test --verbose --all

windows:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: Prepare dependencies
Expand All @@ -33,11 +29,12 @@ jobs:
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: |
echo "C:\Cbc\lib" >> $GITHUB_PATH
cargo build --verbose --all
run: cargo build --verbose --all
- name: Run tests
run: |
echo "C:\Cbc\lib" >> $GITHUB_PATH
cargo test --verbose --all
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;
}
}
2 changes: 0 additions & 2 deletions coin_cbc_sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ pub type cbc_callback = Option<
),
>;

#[cfg_attr(unix, link(name = "CbcSolver"))]
#[cfg_attr(windows, link(name = "libCbcSolver"))]
extern "C" {
pub fn Cbc_newModel() -> *mut Cbc_Model;
pub fn Cbc_deleteModel(model: *mut Cbc_Model);
Expand Down

0 comments on commit a755ab0

Please sign in to comment.