From d520b2bfd6882136d2238474e485938fb46bb062 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 08:50:55 +0100 Subject: [PATCH 01/16] Put all bundled feature logic in one file --- Cargo.toml | 1 + build.rs | 84 +++--------------------------------------------------- bundled.rs | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 80 deletions(-) create mode 100644 bundled.rs diff --git a/Cargo.toml b/Cargo.toml index 97b54c5..1ccdc5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ links = "scip" [features] bundled = ["reqwest", "zip", "tempfile", "zip-extract"] +from_source = ["reqwest", "zip", "tempfile", "zip-extract"] [build-dependencies] bindgen = "0.64" diff --git a/build.rs b/build.rs index 8f00122..4653395 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,5 @@ +mod bundled; + extern crate bindgen; use glob::glob; @@ -5,22 +7,7 @@ use std::env; use std::error::Error; use std::path::PathBuf; -#[cfg(feature = "bundled")] -use tempfile::tempdir; -#[cfg(feature = "bundled")] -use std::fs::File; -#[cfg(feature = "bundled")] -use std::io::Cursor; -#[cfg(feature = "bundled")] -use std::io::Write; -#[cfg(feature = "bundled")] -use std::path::Path; - - -#[cfg(feature = "bundled")] -pub fn is_bundled_feature_enabled() -> bool { - true -} +use bundled::*; #[cfg(not(feature = "bundled"))] pub fn is_bundled_feature_enabled() -> bool { @@ -155,67 +142,4 @@ fn main() -> Result<(), Box> { bindings.write_to_file(out_path.join("bindings.rs"))?; Ok(()) -} - -#[cfg(feature = "bundled")] -fn download_scip() { - let extract_path = PathBuf::from(env::var("OUT_DIR").unwrap()); - - if extract_path.join("scip_install").exists() { - println!("cargo:warning=SCIP was previously downloaded, skipping download"); - return; - } - - let os = env::consts::OS; - let arch = std::env::consts::ARCH; - println!("cargo:warning=Detected OS: {}", os); - println!("cargo:warning=Detected arch: {}", arch); - - let os_string = if os == "linux" && arch == "x86_64" { - "linux" - } else if os == "macos" && arch == "x86_64" { - "macos" - } else if os == "macos" && arch == "aarch64" { - "macos-arm" - } else if os == "windows" && arch == "x86_64" { - "windows" - } else { - panic!("Unsupported OS-arch combination: {}-{}", os, arch); - }; - - let url = format!( - "https://github.com/scipopt/scip-sys/releases/download/v0.1.9/libscip-{os_string}.zip" - ); - - download_and_extract_zip(&url, &extract_path).unwrap_or_else( - |e| panic!("Failed to download and extract SCIP: {}", e), - ); -} - - -#[cfg(not(feature = "bundled"))] -fn download_scip() {} - - -#[cfg(feature = "bundled")] -fn download_and_extract_zip(url: &str, extract_path: &Path) -> Result<(), Box> { - // Download the ZIP file - println!("cargo:warning=Downloading from {}", url); - let response = reqwest::blocking::Client::new().get(url).send()?; - let content = response.bytes()?; - - // Create a temporary file to store the ZIP - let dir = tempdir()?; - let zip_path = dir.path().join("scip.zip"); - let mut temp_file = File::create(&zip_path)?; - temp_file.write_all(&content)?; - let target_dir = PathBuf::from(extract_path); - - println!("cargo:warning=Downloaded to {:?}", zip_path); - println!("cargo:warning=Extracting to {:?}", target_dir); - zip_extract::extract(Cursor::new( - std::fs::read(zip_path).unwrap(), - ), &target_dir, false)?; - - Ok(()) -} +} \ No newline at end of file diff --git a/bundled.rs b/bundled.rs new file mode 100644 index 0000000..c6bf40f --- /dev/null +++ b/bundled.rs @@ -0,0 +1,84 @@ +use std::env; +use std::error::Error; +#[cfg(feature = "bundled")] +use tempfile::tempdir; +#[cfg(feature = "bundled")] +use std::fs::File; +#[cfg(feature = "bundled")] +use std::io::Cursor; +#[cfg(feature = "bundled")] +use std::io::Write; +#[cfg(feature = "bundled")] +use std::path::Path; +#[cfg(feature = "bundled")] +use std::path::PathBuf; + + +#[cfg(feature = "bundled")] +pub fn is_bundled_feature_enabled() -> bool { + true +} + + +#[cfg(feature = "bundled")] +pub fn download_scip() { + let extract_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + + if extract_path.join("scip_install").exists() { + println!("cargo:warning=SCIP was previously downloaded, skipping download"); + return; + } + + let os = env::consts::OS; + let arch = std::env::consts::ARCH; + println!("cargo:warning=Detected OS: {}", os); + println!("cargo:warning=Detected arch: {}", arch); + + let os_string = if os == "linux" && arch == "x86_64" { + "linux" + } else if os == "macos" && arch == "x86_64" { + "macos" + } else if os == "macos" && arch == "aarch64" { + "macos-arm" + } else if os == "windows" && arch == "x86_64" { + "windows" + } else { + panic!("Unsupported OS-arch combination: {}-{}", os, arch); + }; + + let url = format!( + "https://github.com/scipopt/scip-sys/releases/download/v0.1.9/libscip-{os_string}.zip" + ); + + download_and_extract_zip(&url, &extract_path).unwrap_or_else( + |e| panic!("Failed to download and extract SCIP: {}", e), + ); +} + + +#[cfg(not(feature = "bundled"))] +pub fn download_scip() {} + + +#[cfg(feature = "bundled")] +pub fn download_and_extract_zip(url: &str, extract_path: &Path) -> Result<(), Box> { + // Download the ZIP file + println!("cargo:warning=Downloading from {}", url); + let response = reqwest::blocking::Client::new().get(url).send()?; + let content = response.bytes()?; + + // Create a temporary file to store the ZIP + let dir = tempdir()?; + let zip_path = dir.path().join("scip.zip"); + let mut temp_file = File::create(&zip_path)?; + temp_file.write_all(&content)?; + let target_dir = PathBuf::from(extract_path); + + println!("cargo:warning=Downloaded to {:?}", zip_path); + println!("cargo:warning=Extracting to {:?}", target_dir); + zip_extract::extract(Cursor::new( + std::fs::read(zip_path).unwrap(), + ), &target_dir, false)?; + + Ok(()) +} From df4b28dbe43d4785b6ab109c1f158e68084a9c90 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:07:30 +0100 Subject: [PATCH 02/16] Fetch and compile scipoptsuite from source --- .github/workflows/build_and_test.yml | 12 +++-- Cargo.toml | 7 ++- build.rs | 81 +++++++++++++++------------- bundled.rs | 37 ++----------- download.rs | 35 ++++++++++++ from_source.rs | 58 ++++++++++++++++++++ 6 files changed, 154 insertions(+), 76 deletions(-) create mode 100644 download.rs create mode 100644 from_source.rs diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 496ce0b..76a5837 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,7 +9,7 @@ on: - main jobs: - bundled-test: + bundled-and-from-source-test: strategy: matrix: os: [ @@ -21,7 +21,13 @@ jobs: runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Test + - name: Test bundled run: | + cargo b --features bundled -vv cargo t --features bundled create - cargo t --features bundled --examples \ No newline at end of file + cargo t --features bundled --examples + - name: Test from-source + run: | + cargo b --features from-source -vv + cargo t --features from-source create + cargo t --features from-source --examples diff --git a/Cargo.toml b/Cargo.toml index 1ccdc5c..202e932 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,14 +9,17 @@ links = "scip" [features] bundled = ["reqwest", "zip", "tempfile", "zip-extract"] -from_source = ["reqwest", "zip", "tempfile", "zip-extract"] +from-source = ["reqwest", "zip", "tempfile", "zip-extract", "cmake"] [build-dependencies] bindgen = "0.64" cc = "1.0.73" glob = "0.3.1" -# dependencies for the static feature reqwest = { version = "0.11", features = ["blocking", "json"], optional = true } zip = { version = "0.5", optional = true } tempfile = { version = "3.2", optional = true } zip-extract = { version = "0.1.3", optional = true } +cmake = { version = "0.1.50", optional = true } + +[dependencies] +cmake = "0.1.50" \ No newline at end of file diff --git a/build.rs b/build.rs index 4653395..13eedaf 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,6 @@ mod bundled; +mod from_source; +mod download; extern crate bindgen; @@ -8,6 +10,7 @@ use std::error::Error; use std::path::PathBuf; use bundled::*; +use crate::from_source::{download_scip_source, is_from_source_feature_enabled, compile_scip}; #[cfg(not(feature = "bundled"))] pub fn is_bundled_feature_enabled() -> bool { @@ -23,10 +26,9 @@ fn _build_from_scip_dir(path: &str) -> bindgen::Builder { println!("cargo:rustc-link-search={}", lib_dir_path); #[cfg(windows)] - let lib_dir_path = PathBuf::from(&path).join("bin"); + let lib_dir_path = PathBuf::from(&path).join("bin"); #[cfg(windows)] println!("cargo:rustc-link-search={}", lib_dir_path.to_str().unwrap()); - } else { panic!( "{}", @@ -85,44 +87,49 @@ fn look_in_scipoptdir_and_conda_env() -> Option { } } - return None + return None; } + fn main() -> Result<(), Box> { let builder = - if is_bundled_feature_enabled() { - download_scip(); - let path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("scip_install"); - _build_from_scip_dir(path.to_str().unwrap()) - } else { - let builder = look_in_scipoptdir_and_conda_env(); - if builder.is_some() { - builder.unwrap() + if is_bundled_feature_enabled() { + download_scip(); + let path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("scip_install"); + _build_from_scip_dir(path.to_str().unwrap()) + } else if is_from_source_feature_enabled() { + let source_path = download_scip_source(); + let build_path = compile_scip(source_path); + _build_from_scip_dir(build_path.to_str().unwrap()) } else { - println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt"); - println!("cargo:warning=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(); - - bindgen::Builder::default() - .header(scip_header_file) - .header(scipdefplugins_header_file) - .parse_callbacks(Box::new(bindgen::CargoCallbacks)) - .clang_arg(format!("-I{}", headers_dir_path)) - } - }; + let builder = look_in_scipoptdir_and_conda_env(); + if builder.is_some() { + builder.unwrap() + } else { + println!("cargo:warning=SCIP was not found in SCIPOPTDIR or in Conda environemnt"); + println!("cargo:warning=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(); + + bindgen::Builder::default() + .header(scip_header_file) + .header(scipdefplugins_header_file) + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) + .clang_arg(format!("-I{}", headers_dir_path)) + } + }; #[cfg(windows)] println!("cargo:rustc-link-lib=libscip"); @@ -142,4 +149,4 @@ fn main() -> Result<(), Box> { bindings.write_to_file(out_path.join("bindings.rs"))?; Ok(()) -} \ No newline at end of file +} diff --git a/bundled.rs b/bundled.rs index c6bf40f..b4929ab 100644 --- a/bundled.rs +++ b/bundled.rs @@ -1,18 +1,10 @@ -use std::env; -use std::error::Error; -#[cfg(feature = "bundled")] -use tempfile::tempdir; -#[cfg(feature = "bundled")] -use std::fs::File; -#[cfg(feature = "bundled")] -use std::io::Cursor; #[cfg(feature = "bundled")] -use std::io::Write; -#[cfg(feature = "bundled")] -use std::path::Path; +use std::env; #[cfg(feature = "bundled")] use std::path::PathBuf; +#[cfg(feature = "bundled")] +use crate::download::download_and_extract_zip; #[cfg(feature = "bundled")] pub fn is_bundled_feature_enabled() -> bool { @@ -59,26 +51,3 @@ pub fn download_scip() { #[cfg(not(feature = "bundled"))] pub fn download_scip() {} - -#[cfg(feature = "bundled")] -pub fn download_and_extract_zip(url: &str, extract_path: &Path) -> Result<(), Box> { - // Download the ZIP file - println!("cargo:warning=Downloading from {}", url); - let response = reqwest::blocking::Client::new().get(url).send()?; - let content = response.bytes()?; - - // Create a temporary file to store the ZIP - let dir = tempdir()?; - let zip_path = dir.path().join("scip.zip"); - let mut temp_file = File::create(&zip_path)?; - temp_file.write_all(&content)?; - let target_dir = PathBuf::from(extract_path); - - println!("cargo:warning=Downloaded to {:?}", zip_path); - println!("cargo:warning=Extracting to {:?}", target_dir); - zip_extract::extract(Cursor::new( - std::fs::read(zip_path).unwrap(), - ), &target_dir, false)?; - - Ok(()) -} diff --git a/download.rs b/download.rs new file mode 100644 index 0000000..e6047e6 --- /dev/null +++ b/download.rs @@ -0,0 +1,35 @@ +use std::env; +use std::error::Error; +use tempfile::tempdir; +use std::fs::File; +use std::io::Cursor; +use std::io::Write; +use std::path::Path; +use std::path::PathBuf; +use zip_extract::extract; + + +pub fn download_and_extract_zip(url: &str, extract_path: &Path) -> Result<(), Box> { + // Download the ZIP file + println!("cargo:warning=Downloading from {}", url); + let response = reqwest::blocking::Client::new().get(url).send()?; + let content = response.bytes()?; + + // Create a temporary file to store the ZIP + let dir = tempdir()?; + let zip_path = dir.path().join("scip.zip"); + + + + let mut temp_file = File::create(&zip_path)?; + temp_file.write_all(&content)?; + let target_dir = PathBuf::from(extract_path); + + println!("cargo:warning=Downloaded to {:?}", zip_path); + println!("cargo:warning=Extracting to {:?}", target_dir); + extract(Cursor::new( + std::fs::read(zip_path).unwrap(), + ), &target_dir, false)?; + + Ok(()) +} diff --git a/from_source.rs b/from_source.rs new file mode 100644 index 0000000..5947246 --- /dev/null +++ b/from_source.rs @@ -0,0 +1,58 @@ +#[cfg(feature = "from-source")] +use std::env; +#[cfg(feature = "from-source")] +use std::path::PathBuf; +#[cfg(feature = "from-source")] +use crate::download::download_and_extract_zip; + +#[cfg(feature = "from-source")] +pub fn is_from_source_feature_enabled() -> bool { + true +} + +#[cfg(not(feature = "from-source"))] +pub fn is_from_source_feature_enabled() -> bool { + false +} + + +#[cfg(not(feature = "from-source"))] +pub fn download_scip_source() -> PathBuf { + unimplemented!("Cannot download SCIP source code without the `from-source` feature") +} + + +#[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 target = env::var("OUT_DIR").unwrap(); + let target = std::path::Path::new(&target); + if target.join("scipoptsuite-9.0.0").exists() { + println!("cargo:warning=SCIP was previously downloaded, skipping download"); + } else { + download_and_extract_zip(url, &*target).expect("Failed to download SCIP"); + } + target.join("scipoptsuite-9.0.0") +} + + +#[cfg(feature = "from-source")] +pub fn compile_scip(source_path: PathBuf) -> PathBuf { + let out_dir = env::var("OUT_DIR").unwrap(); + let out_dir = std::path::Path::new(&out_dir); + let lib_path = out_dir.join("lib"); + if lib_path.exists() { + println!("cargo:warning=SCIP was previously compiled, skipping compilation"); + return out_dir.to_path_buf(); + } + + use cmake::Config; + let mut dst = Config::new(source_path); + + dst.define("AUTOBUILD", "ON").build() +} + +#[cfg(not(feature = "from-source"))] +pub fn compile_scip(source_path: PathBuf) -> PathBuf { + unimplemented!("Cannot compile SCIP without the `from-source` feature") +} \ No newline at end of file From 2213b88f0ab1afa3a8f0af11d06a07ec9ce48c4c Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:11:47 +0100 Subject: [PATCH 03/16] Fix imports --- bundled.rs | 1 - from_source.rs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/bundled.rs b/bundled.rs index b4929ab..5edfd89 100644 --- a/bundled.rs +++ b/bundled.rs @@ -2,7 +2,6 @@ use std::env; #[cfg(feature = "bundled")] use std::path::PathBuf; - #[cfg(feature = "bundled")] use crate::download::download_and_extract_zip; diff --git a/from_source.rs b/from_source.rs index 5947246..d6b59a4 100644 --- a/from_source.rs +++ b/from_source.rs @@ -1,8 +1,7 @@ +use std::path::PathBuf; #[cfg(feature = "from-source")] use std::env; #[cfg(feature = "from-source")] -use std::path::PathBuf; -#[cfg(feature = "from-source")] use crate::download::download_and_extract_zip; #[cfg(feature = "from-source")] From 5ccdccf82367bf2a72d96a9e176ceae29f519b20 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:15:59 +0100 Subject: [PATCH 04/16] CI: start with only macos jobs to build from source for now --- .github/workflows/build_and_test.yml | 38 ++++++++++++++++++++-------- download.rs | 1 - 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 76a5837..730bd7a 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,25 +9,43 @@ on: - main jobs: - bundled-and-from-source-test: +# bundled-test: +# strategy: +# matrix: +# os: [ +# ubuntu-latest, +# macos-latest, +# macos-14, # macOS arm runner +# windows-latest, +# ] +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v3 +# - name: Test bundled +# run: | +# cargo b --features bundled -vv +# cargo t --features bundled create +# cargo t --features bundled --examples +# - name: Test from-source +# run: | +# cargo b --features from-source -vv +# cargo t --features from-source create +# cargo t --features from-source --examples + + + macos-from-source: strategy: matrix: os: [ - ubuntu-latest, macos-latest, - macos-14, # macOS arm runner - windows-latest, + macos-14, ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - - name: Test bundled - run: | - cargo b --features bundled -vv - cargo t --features bundled create - cargo t --features bundled --examples - name: Test from-source run: | + brew install bison cargo b --features from-source -vv cargo t --features from-source create - cargo t --features from-source --examples + cargo t --features from-source --examples \ No newline at end of file diff --git a/download.rs b/download.rs index e6047e6..991441d 100644 --- a/download.rs +++ b/download.rs @@ -1,4 +1,3 @@ -use std::env; use std::error::Error; use tempfile::tempdir; use std::fs::File; From 38b8d37be854c8cf19e581fe1a8eb7b95e8eed81 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:26:59 +0100 Subject: [PATCH 05/16] CI: Test from source feature on ubuntu --- .github/workflows/build_and_test.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 730bd7a..ddbc191 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -33,19 +33,29 @@ jobs: # cargo t --features from-source --examples - macos-from-source: - strategy: - matrix: - os: [ - macos-latest, - macos-14, - ] - runs-on: ${{ matrix.os }} +# macos-from-source: +# strategy: +# matrix: +# os: [ +# macos-latest, +# macos-14, +# ] +# runs-on: ${{ matrix.os }} +# steps: +# - uses: actions/checkout@v3 +# - name: Test from-source +# run: | +# brew install bison +# cargo b --features from-source -vv +# cargo t --features from-source create +# cargo t --features from-source --examples + + ubuntu-from-source: + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Test from-source run: | - brew install bison cargo b --features from-source -vv cargo t --features from-source create cargo t --features from-source --examples \ No newline at end of file From 8ccb0e72996dbbc02a5fa347bc83022907e818b7 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:31:31 +0100 Subject: [PATCH 06/16] CI: Test from source feature on windows --- .github/workflows/build_and_test.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index ddbc191..e56ac79 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -50,8 +50,19 @@ jobs: # cargo t --features from-source create # cargo t --features from-source --examples - ubuntu-from-source: - runs-on: ubuntu-latest +# ubuntu-from-source: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: Test from-source +# run: | +# cargo b --features from-source -vv +# cargo t --features from-source create +# cargo t --features from-source --examples + + + windows-from-source: + runs-on: windows-latest steps: - uses: actions/checkout@v3 - name: Test from-source From eb39459d1a14892e5835a907fa82ab86cc8d3593 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:49:23 +0100 Subject: [PATCH 07/16] Try installing tbb on windows --- .github/workflows/build_and_test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e56ac79..2ba924d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -65,8 +65,29 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v3 + + - name: Setup vcpkg + uses: lukka/run-vcpkg@v9 + with: + vcpkgArguments: 'tbb' + vcpkgDirectory: '${{ runner.workspace }}/vcpkg/' + appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }} + vcpkgGitURL: 'https://github.com/microsoft/vcpkg.git' + setupOnly: true + + - name: Cache vcpkg artifacts + uses: actions/cache@v2 + with: + path: | + ${{ runner.workspace }}/vcpkg/installed + !**/packages + key: ${{ runner.os }}-tbb-${{ hashFiles('**/vcpkg.json') }} + restore-keys: | + ${{ runner.os }}-tbb- + - name: Test from-source 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 \ No newline at end of file From 6dce19c7b88091717fc9a919a8a03434bd3e2b20 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 10:51:32 +0100 Subject: [PATCH 08/16] Update vcpkg workflow version --- .github/workflows/build_and_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 2ba924d..44e9cdf 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -67,7 +67,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup vcpkg - uses: lukka/run-vcpkg@v9 + uses: lukka/run-vcpkg@v11 with: vcpkgArguments: 'tbb' vcpkgDirectory: '${{ runner.workspace }}/vcpkg/' @@ -76,7 +76,7 @@ jobs: setupOnly: true - name: Cache vcpkg artifacts - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | ${{ runner.workspace }}/vcpkg/installed From 8e3cfcca659bd1b8e40030704daff0b31a984446 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:01:22 +0100 Subject: [PATCH 09/16] Try to fix tbb install on windows --- .github/workflows/build_and_test.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 44e9cdf..c50623f 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -68,22 +68,8 @@ jobs: - name: Setup vcpkg uses: lukka/run-vcpkg@v11 - with: - vcpkgArguments: 'tbb' - vcpkgDirectory: '${{ runner.workspace }}/vcpkg/' - appendedCacheKey: ${{ hashFiles( '**/vcpkg.json' ) }} - vcpkgGitURL: 'https://github.com/microsoft/vcpkg.git' - setupOnly: true - - - name: Cache vcpkg artifacts - uses: actions/cache@v4 - with: - path: | - ${{ runner.workspace }}/vcpkg/installed - !**/packages - key: ${{ runner.os }}-tbb-${{ hashFiles('**/vcpkg.json') }} - restore-keys: | - ${{ runner.os }}-tbb- + run: | + vcpkg install tbb:x64-windows - name: Test from-source run: | From 15cafe4010806fa8c3462e1a8d65bff3e3a3006a Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:04:08 +0100 Subject: [PATCH 10/16] Try to fix tbb install on windows --- .github/workflows/build_and_test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index c50623f..25c85b9 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -68,11 +68,10 @@ jobs: - name: Setup vcpkg uses: lukka/run-vcpkg@v11 - run: | - vcpkg install tbb:x64-windows - name: Test from-source run: | + vcpkg install tbb:x64-windows echo "${{ runner.workspace }}/vcpkg" >> $GITHUB_PATH cargo b --features from-source -vv cargo t --features from-source create From a40d7d185224587a6152916f34d3c32735260218 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:04:14 +0100 Subject: [PATCH 11/16] Try to fix tbb install on windows --- .github/workflows/build_and_test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 25c85b9..bd512e1 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -65,10 +65,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v3 - - - name: Setup vcpkg - uses: lukka/run-vcpkg@v11 - + - uses: lukka/run-vcpkg@v11 - name: Test from-source run: | vcpkg install tbb:x64-windows From b9f548df2e2acfd832e808eef82d71a3c8d3184f Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:06:08 +0100 Subject: [PATCH 12/16] Add cmake install in CI --- .github/workflows/build_and_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index bd512e1..1e009e3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -65,6 +65,7 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v3 + - uses: lukka/get-cmake@latest - uses: lukka/run-vcpkg@v11 - name: Test from-source run: | From 43df3b97fe67ead1412c42aaf42a78a3893ecb6f Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:12:47 +0100 Subject: [PATCH 13/16] Try commit id for vcpkg --- .github/workflows/build_and_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 1e009e3..19d1af3 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -67,6 +67,9 @@ jobs: - uses: actions/checkout@v3 - uses: lukka/get-cmake@latest - uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: "6c296b9" + - name: Test from-source run: | vcpkg install tbb:x64-windows From 25765b99991940aba202feb4c5185fe97378de98 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:29:56 +0100 Subject: [PATCH 14/16] Fix build without features enabled --- .github/workflows/build_and_test.yml | 63 ++++++++++++---------------- build.rs | 2 + 2 files changed, 28 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 19d1af3..e6b1bfa 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -33,47 +33,36 @@ jobs: # cargo t --features from-source --examples -# macos-from-source: -# strategy: -# matrix: -# os: [ -# macos-latest, -# macos-14, -# ] -# runs-on: ${{ matrix.os }} -# steps: -# - uses: actions/checkout@v3 -# - name: Test from-source -# run: | -# brew install bison -# cargo b --features from-source -vv -# cargo t --features from-source create -# cargo t --features from-source --examples + from-source-test: + strategy: + matrix: + os: [ + macos-latest, + macos-14, + ubuntu-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 + - name: Test from-source + run: | + cargo b --features from-source -vv + cargo t --features from-source create + cargo t --features from-source --examples -# ubuntu-from-source: -# runs-on: ubuntu-latest +# TODO: fix this, needs tbb +# windows-from-source: +# runs-on: windows-latest # steps: # - uses: actions/checkout@v3 +# # - name: Test from-source # 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 - - - windows-from-source: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - uses: lukka/get-cmake@latest - - uses: lukka/run-vcpkg@v11 - with: - vcpkgGitCommitId: "6c296b9" - - - name: Test from-source - run: | - vcpkg install tbb:x64-windows - echo "${{ runner.workspace }}/vcpkg" >> $GITHUB_PATH - cargo b --features from-source -vv - cargo t --features from-source create - cargo t --features from-source --examples \ No newline at end of file +# cargo t --features from-source --examples \ No newline at end of file diff --git a/build.rs b/build.rs index 13eedaf..cc0fa16 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,7 @@ mod bundled; mod from_source; + +#[cfg(any(feature = "bundled", feature = "from-source"))] mod download; extern crate bindgen; From 693dddfddbd1d7c2ba9fc2d1071f19e9b74c72b7 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:31:00 +0100 Subject: [PATCH 15/16] Enable all workflows again and disable windows-from-source for now --- .github/workflows/build_and_test.yml | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e6b1bfa..cff265e 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,28 +9,28 @@ on: - main jobs: -# bundled-test: -# strategy: -# matrix: -# os: [ -# ubuntu-latest, -# macos-latest, -# macos-14, # macOS arm runner -# windows-latest, -# ] -# runs-on: ${{ matrix.os }} -# steps: -# - uses: actions/checkout@v3 -# - name: Test bundled -# run: | -# cargo b --features bundled -vv -# cargo t --features bundled create -# cargo t --features bundled --examples -# - name: Test from-source -# run: | -# cargo b --features from-source -vv -# cargo t --features from-source create -# cargo t --features from-source --examples + bundled-test: + strategy: + matrix: + os: [ + ubuntu-latest, + macos-latest, + macos-14, # macOS arm runner + windows-latest, + ] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Test bundled + run: | + cargo b --features bundled -vv + cargo t --features bundled create + cargo t --features bundled --examples + - name: Test from-source + run: | + cargo b --features from-source -vv + cargo t --features from-source create + cargo t --features from-source --examples from-source-test: From fc10bf1dd666eb81ca7508edc03e385c1c673412 Mon Sep 17 00:00:00 2001 From: Mohammed Ghannam Date: Sat, 30 Mar 2024 11:35:45 +0100 Subject: [PATCH 16/16] Remove duplicate test --- .github/workflows/build_and_test.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index cff265e..27f04c1 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -26,12 +26,6 @@ jobs: cargo b --features bundled -vv cargo t --features bundled create cargo t --features bundled --examples - - name: Test from-source - run: | - cargo b --features from-source -vv - cargo t --features from-source create - cargo t --features from-source --examples - from-source-test: strategy: