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

Use static linking for the from-source feature #22

Merged
merged 20 commits into from
Oct 30, 2024
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
27 changes: 18 additions & 9 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,38 @@ jobs:
macos-latest,
macos-14,
ubuntu-latest,
windows-latest,
]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install bison
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'macos-14' }}
run: |
brew install bison
brew install bison gcc
- name: Test from-source
run: |
cargo b --features from-source -vv
cargo t --features from-source create
cargo t --features from-source --examples

# TODO: fix this, needs tbb
# windows-from-source:
# runs-on: windows-latest
# from-source-linux-arm-test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
#
# - name: Test from-source
# - name: Set up QEMU for ARM64 emulation
# uses: docker/setup-qemu-action@v2
# with:
# platforms: arm64
#
# - name: Run test in ARM64 environment
# run: |
# echo "${{ runner.workspace }}/vcpkg" >> $GITHUB_PATH
# cargo b --features from-source -vv
# cargo t --features from-source create
# cargo t --features from-source --examples
# docker run --rm --platform linux/arm64 \
# -v ${{ github.workspace }}:/workspace \
# -w /workspace \
# rust:latest /bin/bash -c "
# cargo build --features from-source -vv
# cargo test --features from-source create
# cargo test --features from-source --examples
# "
25 changes: 21 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,27 @@ fn main() -> Result<(), Box<dyn Error>> {
}
};

#[cfg(windows)]
println!("cargo:rustc-link-lib=libscip");
#[cfg(not(windows))]
println!("cargo:rustc-link-lib=scip");

#[cfg(windows)] {
println!("cargo:rustc-link-lib=libscip");
println!("cargo:rustc-link-lib=libsoplex");
}
#[cfg(not(windows))] {
println!("cargo:rustc-link-lib=scip");
println!("cargo:rustc-link-lib=soplex");
}

#[cfg(feature = "from-source")] {
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++");
}
}

let builder = builder
.blocklist_item("FP_NAN")
Expand Down
22 changes: 17 additions & 5 deletions from_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ pub fn download_scip_source() -> PathBuf {

#[cfg(feature = "from-source")]
pub fn download_scip_source() -> PathBuf {
let url = "https://github.com/scipopt/scip-sys/releases/download/v0.1.9/scipoptsuite-9.0.0.zip";
let scip_version = "9.1.1";
let url = format!("https://github.com/scipopt/scip-sys/releases/download/v0.1.9/scipoptsuite-{scip_version}.zip");
let target = env::var("OUT_DIR").unwrap();
let target = std::path::Path::new(&target);
if target.join("scipoptsuite-9.0.0").exists() {
if target.join(format!("scipoptsuite-{scip_version}")).exists() {
println!("cargo:warning=SCIP was previously downloaded, skipping download");
} else {
download_and_extract_zip(url, &*target).expect("Failed to download SCIP");
download_and_extract_zip(&url, &*target).expect("Failed to download SCIP");
}
target.join("scipoptsuite-9.0.0")
target.join(format!("scipoptsuite-{scip_version}"))
}


Expand All @@ -48,7 +49,18 @@ pub fn compile_scip(source_path: PathBuf) -> PathBuf {
use cmake::Config;
let mut dst = Config::new(source_path);

dst.define("AUTOBUILD", "ON").build()
dst
.define("IPOPT", "OFF")
.define("ZIMPL", "OFF")
.define("GMP", "OFF")
.define("READLINE", "OFF")
.define("BOOST", "OFF")
.define("AUTOBUILD","OFF")
.define("PAPILO", "OFF")
.define("SYM", "snauty")
.define("ZLIB", "OFF")
.define("SHARED", "OFF")
.build()
}

#[cfg(not(feature = "from-source"))]
Expand Down
Loading