Skip to content

Commit 1f06a88

Browse files
authored
Merge pull request #30 from scipopt/linux-arm
Add support for linux arm
2 parents d46153f + 632d7ba commit 1f06a88

File tree

5 files changed

+37
-27
lines changed

5 files changed

+37
-27
lines changed

.github/workflows/build_and_test.yml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
macos-13,
1818
macos-14, # macOS arm runner
1919
windows-latest,
20+
ubuntu-24.04-arm
2021
]
2122
runs-on: ${{ matrix.os }}
2223
steps:
@@ -27,23 +28,23 @@ jobs:
2728
cargo t --features bundled --release create
2829
cargo t --features bundled --release --examples
2930
30-
bundled-debug-test:
31-
strategy:
32-
matrix:
33-
os: [
34-
ubuntu-latest,
35-
macos-13,
36-
macos-14, # macOS arm runner
37-
windows-latest,
38-
]
39-
runs-on: ${{ matrix.os }}
40-
steps:
41-
- uses: actions/checkout@v3
42-
- name: Test bundled
43-
run: |
44-
cargo b --features bundled
45-
cargo t --features bundled create
46-
cargo t --features bundled --examples
31+
# bundled-debug-test:
32+
# strategy:
33+
# matrix:
34+
# os: [
35+
# ubuntu-latest,
36+
# macos-13,
37+
# macos-14, # macOS arm runner
38+
# windows-latest,
39+
# ]
40+
# runs-on: ${{ matrix.os }}
41+
# steps:
42+
# - uses: actions/checkout@v3
43+
# - name: Test bundled
44+
# run: |
45+
# cargo b --features bundled
46+
# cargo t --features bundled create
47+
# cargo t --features bundled --examples
4748

4849
from-source-test:
4950
strategy:

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ bundled = ["ureq", "zip", "tempfile", "zip-extract"]
1212
from-source = ["ureq", "zip", "tempfile", "zip-extract", "cmake"]
1313

1414
[build-dependencies]
15-
bindgen = "0.64"
16-
cc = "1.0.73"
15+
bindgen = "0.72.0"
1716
glob = "0.3.1"
1817
ureq = { version = "2.9.6", optional = true }
1918
zip = { version = "0.5", optional = true }

bundled.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ pub fn download_scip() {
2626

2727
let os_string = if os == "linux" && arch == "x86_64" {
2828
"linux"
29-
} else if os == "macos" && arch == "x86_64" {
29+
} else if os == "linux" && arch == "aarch64" {
30+
"linux-arm"
31+
}
32+
else if os == "macos" && arch == "x86_64" {
3033
"macos-intel"
3134
} else if os == "macos" && arch == "aarch64" {
3235
"macos-arm"
@@ -42,8 +45,12 @@ pub fn download_scip() {
4245
#[cfg(not(debug_assertions))]
4346
let debug_str = "";
4447

48+
// TODO: enable this when debug builds are available
49+
// let url = format!(
50+
// "https://github.com/scipopt/scipoptsuite-deploy/releases/download/v0.8.0/libscip-{os_string}{debug_str}.zip",
51+
// );
4552
let url = format!(
46-
"https://github.com/scipopt/scipoptsuite-deploy/releases/download/v0.7.0/libscip-{os_string}{debug_str}.zip",
53+
"https://github.com/scipopt/scipoptsuite-deploy/releases/download/v0.8.0/libscip-{os_string}.zip",
4754
);
4855

4956
download_and_extract_zip(&url, &extract_path)

examples/create.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::ffi::CString;
12
use scip_sys::*;
23
use std::mem::MaybeUninit;
34

@@ -9,15 +10,15 @@ fn main() {
910
// include default plugins
1011
unsafe { SCIPincludeDefaultPlugins(scip_ptr) };
1112

12-
unsafe { SCIPcreateProbBasic(scip_ptr, "test".as_ptr() as *const i8) };
13+
unsafe { SCIPcreateProbBasic(scip_ptr, CString::new("test").unwrap().as_ptr()) };
1314

1415
// add a variable
1516
let mut var_ptr = MaybeUninit::uninit();
1617
unsafe {
1718
SCIPcreateVarBasic(
1819
scip_ptr,
1920
var_ptr.as_mut_ptr(),
20-
"x".as_ptr() as *const i8,
21+
CString::new("x").unwrap().as_ptr(),
2122
0.0,
2223
1.0,
2324
1.0,
@@ -33,7 +34,7 @@ fn main() {
3334
SCIPcreateConsBasicLinear(
3435
scip_ptr,
3536
cons_ptr.as_mut_ptr(),
36-
"c".as_ptr() as *const i8,
37+
CString::new("c").unwrap().as_ptr(),
3738
1,
3839
&mut var_ptr,
3940
&mut 1.0,

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
1010

1111
#[cfg(test)]
1212
mod tests {
13+
use std::ffi::CString;
1314
use super::*;
1415
use std::mem::MaybeUninit;
1516

@@ -22,15 +23,16 @@ mod tests {
2223
// include default plugins
2324
unsafe { SCIPincludeDefaultPlugins(scip_ptr) };
2425

25-
unsafe { SCIPcreateProbBasic(scip_ptr, "test".as_ptr() as *const i8) };
26+
let name = CString::new("test").unwrap();
27+
unsafe { SCIPcreateProbBasic(scip_ptr, name.as_ptr()) };
2628

2729
// add a variable
2830
let mut var_ptr = MaybeUninit::uninit();
2931
unsafe {
3032
SCIPcreateVarBasic(
3133
scip_ptr,
3234
var_ptr.as_mut_ptr(),
33-
"x".as_ptr() as *const i8,
35+
CString::new("x").unwrap().as_ptr(),
3436
0.0,
3537
1.0,
3638
1.0,
@@ -46,7 +48,7 @@ mod tests {
4648
SCIPcreateConsBasicLinear(
4749
scip_ptr,
4850
cons_ptr.as_mut_ptr(),
49-
"c".as_ptr() as *const i8,
51+
CString::new("c").unwrap().as_ptr(),
5052
1,
5153
&mut var_ptr,
5254
&mut 1.0,

0 commit comments

Comments
 (0)