From 47446e60b8d23642e36ceb09bd190153bf5579e2 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 12:44:53 +0200 Subject: [PATCH 01/98] Make bindgen run when using the prebuilt feature. --- build.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/build.rs b/build.rs index 658bb66..8ad4d62 100644 --- a/build.rs +++ b/build.rs @@ -13,14 +13,23 @@ use serde::{Deserialize, Serialize}; const BINDINGS_FILE: &str = "bindings.rs"; const WRAPPER_FILE: &str = "wrapper.h"; +const INCLUDE_DIR: &str = "assimp/include"; + +#[derive(Serialize, Deserialize, Debug, Clone)] +struct BuildManifest { + pub link_search_dir: PathBuf, + pub assimp_license: PathBuf, + pub link_libs: Vec, + pub bindings_rs: PathBuf, + pub target: String, +} fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) -> Result<(), ()> { - let mut builder = bindgen::Builder::default(); - if let Some(include_path) = include_path { - builder = builder.clang_arg(format!("-I{}", include_path.to_str().unwrap())); - } + let builder = bindgen::Builder::default(); + builder .header(WRAPPER_FILE) + .clang_arg(format!("-I{}", include_path.unwrap_or_else(|| Path::new(INCLUDE_DIR)).to_str().unwrap())) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .allowlist_type("ai.*") .allowlist_function("ai.*") @@ -33,16 +42,8 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) -> Re .generate()? .write_to_file(output_file.as_ref()) .unwrap(); - Ok(()) -} -#[derive(Serialize, Deserialize, Debug, Clone)] -struct BuildManifest { - pub link_search_dir: PathBuf, - pub assimp_license: PathBuf, - pub link_libs: Vec, - pub bindings_rs: PathBuf, - pub target: String, + Ok(()) } fn install(manifest: &BuildManifest) { @@ -65,9 +66,8 @@ fn install(manifest: &BuildManifest) { println!("cargo:rustc-link-lib={}", "c++"); } - // Write the bindings to the /bindings.rs file. - let bindings_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE); - fs::copy(&manifest.bindings_rs, bindings_path).unwrap(); + run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None) + .expect("russimp generate bindgen failed, for details see https://github.com/jkvargas/russimp-sys"); } fn build_from_source(target: &Target) -> BuildManifest { @@ -252,7 +252,7 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { bindings_rs: PathBuf::from("bindings.rs"), target: manifest.target.clone(), }) - .unwrap(); + .unwrap(); let manifest_json_date = manifest_json.as_bytes(); let mut header = tar::Header::new_gnu(); header.set_size(manifest_json_date.len() as u64); From 37b0c0d0ce4bb3e02617ddacca5278d34449a994 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 12:48:39 +0200 Subject: [PATCH 02/98] Update bindgen --- Cargo.toml | 2 +- build.rs | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f246ec..5d74227 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ nozlib = [] nolibcxx = [] [build-dependencies] -bindgen = "0.59.2" +bindgen = "0.63.0" vcpkg = "0.2.15" ureq = "2.5" serde_json = "1.0" diff --git a/build.rs b/build.rs index 8ad4d62..ebc1b04 100644 --- a/build.rs +++ b/build.rs @@ -24,7 +24,7 @@ struct BuildManifest { pub target: String, } -fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) -> Result<(), ()> { +fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { let builder = bindgen::Builder::default(); builder @@ -39,11 +39,10 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) -> Re .derive_eq(true) .derive_hash(true) .derive_debug(true) - .generate()? + .generate() + .unwrap() .write_to_file(output_file.as_ref()) - .unwrap(); - - Ok(()) + .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); } fn install(manifest: &BuildManifest) { @@ -66,8 +65,7 @@ fn install(manifest: &BuildManifest) { println!("cargo:rustc-link-lib={}", "c++"); } - run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None) - .expect("russimp generate bindgen failed, for details see https://github.com/jkvargas/russimp-sys"); + run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); } fn build_from_source(target: &Target) -> BuildManifest { @@ -202,7 +200,7 @@ fn build_from_source(target: &Target) -> BuildManifest { } // generate bindings.rs - run_bindgen(&bindings_rs, Some(&assimp_include_dir)).unwrap(); + run_bindgen(&bindings_rs, Some(&assimp_include_dir)); BuildManifest { link_search_dir: assimp_lib_dir, @@ -358,7 +356,7 @@ fn main() { run_bindgen( &PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), Some(&PathBuf::from(include)), - ).expect("russimp generate bindgen failed, for details see https://github.com/jkvargas/russimp-sys"); + ); println!("cargo:rustc-link-search=native={}", libdir); println!("cargo:rustc-link-lib={}", libname); } From 592ead722892aae9cd2a2528642d00332c55e341 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 13:11:19 +0200 Subject: [PATCH 03/98] Add version.h to the wrapper.h file --- wrapper.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wrapper.h b/wrapper.h index 50f1986..d47a2d2 100644 --- a/wrapper.h +++ b/wrapper.h @@ -1,3 +1,4 @@ #include #include -#include \ No newline at end of file +#include +#include From 7b2c673e54e15b00b811f43e3a35a87c990b4412 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 13:16:21 +0200 Subject: [PATCH 04/98] Apply clippy --- build.rs | 30 +++++++++++++----------------- build_support/mod.rs | 2 +- build_support/target.rs | 2 +- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/build.rs b/build.rs index ebc1b04..ff897da 100644 --- a/build.rs +++ b/build.rs @@ -7,7 +7,7 @@ use std::{ time::SystemTime, }; -use build_support::{static_lib_filename, Target}; +use build_support::{static_lib_filename}; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use serde::{Deserialize, Serialize}; @@ -48,7 +48,7 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { fn install(manifest: &BuildManifest) { println!( "cargo:rustc-link-search=native={}", - manifest.link_search_dir.display().to_string() + manifest.link_search_dir.display() ); for lib in &manifest.link_libs { @@ -58,14 +58,14 @@ fn install(manifest: &BuildManifest) { let target = Target::parse_target(&manifest.target); if target.system == "linux" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib={}", "stdc++"); + println!("cargo:rustc-link-lib=stdc++"); } if target.system == "darwin" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib={}", "c++"); + println!("cargo:rustc-link-lib=c++"); } - run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); + run_bindgen(PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); } fn build_from_source(target: &Target) -> BuildManifest { @@ -75,9 +75,9 @@ fn build_from_source(target: &Target) -> BuildManifest { // use or /assimp let assimp_source_dir = current_dir.join( env::var("ASSIMP_SOURCE_DIR") - .unwrap_or(current_dir.join("assimp").to_str().unwrap().to_string()), + .unwrap_or_else(|_| current_dir.join("assimp").to_str().unwrap().to_string()), ); - if assimp_source_dir.exists() == false { + if !assimp_source_dir.exists() { // source dir not exist, try to clone it let mut git_clone = Command::new("git"); git_clone @@ -91,12 +91,8 @@ fn build_from_source(target: &Target) -> BuildManifest { println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_OUT_DIR"); // use or /build-from-source let out_dir = current_dir.join( - env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or( - PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("build-from-source") - .to_string_lossy() - .to_string(), - ), + env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()) + .join("build-from-source").to_str().unwrap().to_string()), ); let assimp_build_dir = out_dir.join("assimp"); @@ -363,12 +359,12 @@ fn main() { } fn assimp_dynamic_linking() -> (String, String, String) { - let target = std::env::var("TARGET").unwrap(); - let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap_or("target/vcpkg".to_string()); + let target = env::var("TARGET").unwrap(); + let vcpkg_root = env::var("VCPKG_ROOT").unwrap_or("target/vcpkg".to_string()); let include_path = if target.contains("apple") { "/opt/homebrew/opt/assimp/include" - } else if std::env::var("DOCS_RS").is_ok() { + } else if env::var("DOCS_RS").is_ok() { "assimp/include" } else { "/usr/local/include" @@ -397,7 +393,7 @@ fn assimp_dynamic_linking() -> (String, String, String) { // vcpkg doesn't know how to find these system dependencies, so we list them here. println!("cargo:rustc-link-lib=user32"); println!("cargo:rustc-link-lib=gdi32"); - lib.link_paths[0] = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()) + lib.link_paths[0] = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) .join(lib.link_paths[0].as_path()) .into(); } diff --git a/build_support/mod.rs b/build_support/mod.rs index a233bb8..def5661 100644 --- a/build_support/mod.rs +++ b/build_support/mod.rs @@ -10,7 +10,7 @@ pub fn run_command(cmd: &mut Command, program: &str) { "current_dir: {:?}\nrunning: {:?}", cmd.get_current_dir() .map(|p| p.display().to_string()) - .unwrap_or("".to_string()), + .unwrap_or(String::new()), cmd ); let status = match cmd.status() { diff --git a/build_support/target.rs b/build_support/target.rs index 65c8e77..6a8a615 100644 --- a/build_support/target.rs +++ b/build_support/target.rs @@ -22,7 +22,7 @@ impl Display for Target { if let Some(ref abi) = self.abi { write!(f, "-{}", abi) } else { - Result::Ok(()) + Ok(()) } } } From 8e50d1aade1ef4957f52744d28b1b8f0220c1883 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 13:25:50 +0200 Subject: [PATCH 05/98] Revert "Apply clippy" This reverts commit 7b2c673e54e15b00b811f43e3a35a87c990b4412. --- build.rs | 30 +++++++++++++++++------------- build_support/mod.rs | 2 +- build_support/target.rs | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/build.rs b/build.rs index ff897da..ebc1b04 100644 --- a/build.rs +++ b/build.rs @@ -7,7 +7,7 @@ use std::{ time::SystemTime, }; -use build_support::{static_lib_filename}; +use build_support::{static_lib_filename, Target}; use flate2::{read::GzDecoder, write::GzEncoder, Compression}; use serde::{Deserialize, Serialize}; @@ -48,7 +48,7 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { fn install(manifest: &BuildManifest) { println!( "cargo:rustc-link-search=native={}", - manifest.link_search_dir.display() + manifest.link_search_dir.display().to_string() ); for lib in &manifest.link_libs { @@ -58,14 +58,14 @@ fn install(manifest: &BuildManifest) { let target = Target::parse_target(&manifest.target); if target.system == "linux" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib=stdc++"); + println!("cargo:rustc-link-lib={}", "stdc++"); } if target.system == "darwin" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib=c++"); + println!("cargo:rustc-link-lib={}", "c++"); } - run_bindgen(PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); + run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); } fn build_from_source(target: &Target) -> BuildManifest { @@ -75,9 +75,9 @@ fn build_from_source(target: &Target) -> BuildManifest { // use or /assimp let assimp_source_dir = current_dir.join( env::var("ASSIMP_SOURCE_DIR") - .unwrap_or_else(|_| current_dir.join("assimp").to_str().unwrap().to_string()), + .unwrap_or(current_dir.join("assimp").to_str().unwrap().to_string()), ); - if !assimp_source_dir.exists() { + if assimp_source_dir.exists() == false { // source dir not exist, try to clone it let mut git_clone = Command::new("git"); git_clone @@ -91,8 +91,12 @@ fn build_from_source(target: &Target) -> BuildManifest { println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_OUT_DIR"); // use or /build-from-source let out_dir = current_dir.join( - env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("build-from-source").to_str().unwrap().to_string()), + env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or( + PathBuf::from(env::var("OUT_DIR").unwrap()) + .join("build-from-source") + .to_string_lossy() + .to_string(), + ), ); let assimp_build_dir = out_dir.join("assimp"); @@ -359,12 +363,12 @@ fn main() { } fn assimp_dynamic_linking() -> (String, String, String) { - let target = env::var("TARGET").unwrap(); - let vcpkg_root = env::var("VCPKG_ROOT").unwrap_or("target/vcpkg".to_string()); + let target = std::env::var("TARGET").unwrap(); + let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap_or("target/vcpkg".to_string()); let include_path = if target.contains("apple") { "/opt/homebrew/opt/assimp/include" - } else if env::var("DOCS_RS").is_ok() { + } else if std::env::var("DOCS_RS").is_ok() { "assimp/include" } else { "/usr/local/include" @@ -393,7 +397,7 @@ fn assimp_dynamic_linking() -> (String, String, String) { // vcpkg doesn't know how to find these system dependencies, so we list them here. println!("cargo:rustc-link-lib=user32"); println!("cargo:rustc-link-lib=gdi32"); - lib.link_paths[0] = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) + lib.link_paths[0] = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()) .join(lib.link_paths[0].as_path()) .into(); } diff --git a/build_support/mod.rs b/build_support/mod.rs index def5661..a233bb8 100644 --- a/build_support/mod.rs +++ b/build_support/mod.rs @@ -10,7 +10,7 @@ pub fn run_command(cmd: &mut Command, program: &str) { "current_dir: {:?}\nrunning: {:?}", cmd.get_current_dir() .map(|p| p.display().to_string()) - .unwrap_or(String::new()), + .unwrap_or("".to_string()), cmd ); let status = match cmd.status() { diff --git a/build_support/target.rs b/build_support/target.rs index 6a8a615..65c8e77 100644 --- a/build_support/target.rs +++ b/build_support/target.rs @@ -22,7 +22,7 @@ impl Display for Target { if let Some(ref abi) = self.abi { write!(f, "-{}", abi) } else { - Ok(()) + Result::Ok(()) } } } From 39756214a87e5162b8c952a1384fc03b60c8e745 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 13:32:22 +0200 Subject: [PATCH 06/98] Apply clippy --- build.rs | 66 +++++++++++++++++++---------------------- build_support/mod.rs | 2 +- build_support/target.rs | 4 +-- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/build.rs b/build.rs index ebc1b04..a929099 100644 --- a/build.rs +++ b/build.rs @@ -48,7 +48,7 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { fn install(manifest: &BuildManifest) { println!( "cargo:rustc-link-search=native={}", - manifest.link_search_dir.display().to_string() + manifest.link_search_dir.display() ); for lib in &manifest.link_libs { @@ -58,14 +58,14 @@ fn install(manifest: &BuildManifest) { let target = Target::parse_target(&manifest.target); if target.system == "linux" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib={}", "stdc++"); + println!("cargo:rustc-link-lib=stdc++"); } if target.system == "darwin" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib={}", "c++"); + println!("cargo:rustc-link-lib=c++"); } - run_bindgen(&PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); + run_bindgen(PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); } fn build_from_source(target: &Target) -> BuildManifest { @@ -75,9 +75,9 @@ fn build_from_source(target: &Target) -> BuildManifest { // use or /assimp let assimp_source_dir = current_dir.join( env::var("ASSIMP_SOURCE_DIR") - .unwrap_or(current_dir.join("assimp").to_str().unwrap().to_string()), + .unwrap_or_else(|_| current_dir.join("assimp").to_str().unwrap().to_string()), ); - if assimp_source_dir.exists() == false { + if !assimp_source_dir.exists() { // source dir not exist, try to clone it let mut git_clone = Command::new("git"); git_clone @@ -91,12 +91,10 @@ fn build_from_source(target: &Target) -> BuildManifest { println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_OUT_DIR"); // use or /build-from-source let out_dir = current_dir.join( - env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or( - PathBuf::from(env::var("OUT_DIR").unwrap()) + env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()) .join("build-from-source") .to_string_lossy() - .to_string(), - ), + .to_string()), ); let assimp_build_dir = out_dir.join("assimp"); @@ -145,18 +143,18 @@ fn build_from_source(target: &Target) -> BuildManifest { assimp_cmake .env( "CMAKE_GENERATOR", - env::var("CMAKE_GENERATOR").unwrap_or("Ninja".to_string()), + env::var("CMAKE_GENERATOR").unwrap_or_else(|_| "Ninja".to_string()), ) - .env("CC", env::var("CC").unwrap_or("clang".to_string())) - .env("CXX", env::var("CXX").unwrap_or("clang++".to_string())) - .env("ASM", env::var("ASM").unwrap_or("clang".to_string())) + .env("CC", env::var("CC").unwrap_or_else(|_| "clang".to_string())) + .env("CXX", env::var("CXX").unwrap_or_else(|_| "clang++".to_string())) + .env("ASM", env::var("ASM").unwrap_or_else(|_| "clang".to_string())) .env( "CXXFLAGS", - env::var("CXXFLAGS").unwrap_or(format!("-target {}", target.to_string())), + env::var("CXXFLAGS").unwrap_or(format!("-target {}", target)), ) .env( "CFLAGS", - env::var("CFLAGS").unwrap_or(format!("-target {}", target.to_string())), + env::var("CFLAGS").unwrap_or(format!("-target {}", target)), ); } @@ -171,7 +169,7 @@ fn build_from_source(target: &Target) -> BuildManifest { .args(["--config", "Release"]) .args([ "--parallel", - &env::var("NUM_JOBS").unwrap_or(num_cpus::get().to_string()), + &env::var("NUM_JOBS").unwrap_or_else(|_| num_cpus::get().to_string()), ]); build_support::run_command(&mut assimp_cmake_install, "cmake"); @@ -234,11 +232,11 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { .unwrap(); for lib_name in &manifest.link_libs { - let filename = static_lib_filename(&lib_name); + let filename = static_lib_filename(lib_name); tar_builder .append_file( format!("lib/{}", filename), - &mut fs::File::open(&manifest.link_search_dir.join(filename)).unwrap(), + &mut fs::File::open(manifest.link_search_dir.join(filename)).unwrap(), ) .unwrap(); } @@ -260,7 +258,7 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { SystemTime::now() .duration_since(SystemTime::UNIX_EPOCH) .unwrap_or_default() - .as_secs() as u64, + .as_secs(), ); tar_builder @@ -279,7 +277,8 @@ fn download_from_cache(cache_tar_name: impl AsRef, version: impl AsRef println!("Downloading {}", download_url); let package = build_support::download(cache_tar_name, download_url).expect("Download Failed"); - return unpack(&package); + + unpack(package) } fn unpack(package: impl AsRef) -> BuildManifest { @@ -301,13 +300,13 @@ fn unpack(package: impl AsRef) -> BuildManifest { assimp_license: unpack_dir.join(manifest.assimp_license), link_libs: manifest.link_libs.clone(), bindings_rs: unpack_dir.join(manifest.bindings_rs), - target: manifest.target.clone(), + target: manifest.target, } } fn main() { if cfg!(feature = "static-link") { - let target = build_support::Target::target(); + let target = Target::new(); let version = env::var("CARGO_PKG_VERSION").unwrap(); let mut feature_suffix = String::new(); if cfg!(feature = "nozlib") { @@ -317,12 +316,12 @@ fn main() { let cache_tar_name = format!( "russimp-{}-{}{}.tar.gz", version, - target.to_string(), + target, feature_suffix ); println!("cargo:rerun-if-env-changed=RUSSIMP_PREBUILT"); - let use_cache = env::var("RUSSIMP_PREBUILT").unwrap_or("ON".to_string()) != "OFF" + let use_cache = env::var("RUSSIMP_PREBUILT").unwrap_or_else(|_| "ON".to_string()) != "OFF" && cfg!(feature = "prebuilt"); let build_manifest = if use_cache { @@ -354,7 +353,7 @@ fn main() { } run_bindgen( - &PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), + PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), Some(&PathBuf::from(include)), ); println!("cargo:rustc-link-search=native={}", libdir); @@ -363,12 +362,12 @@ fn main() { } fn assimp_dynamic_linking() -> (String, String, String) { - let target = std::env::var("TARGET").unwrap(); - let vcpkg_root = std::env::var("VCPKG_ROOT").unwrap_or("target/vcpkg".to_string()); + let target = env::var("TARGET").unwrap(); + let vcpkg_root = env::var("VCPKG_ROOT").unwrap_or_else(|_| "target/vcpkg".to_string()); let include_path = if target.contains("apple") { "/opt/homebrew/opt/assimp/include" - } else if std::env::var("DOCS_RS").is_ok() { + } else if env::var("DOCS_RS").is_ok() { "assimp/include" } else { "/usr/local/include" @@ -397,18 +396,15 @@ fn assimp_dynamic_linking() -> (String, String, String) { // vcpkg doesn't know how to find these system dependencies, so we list them here. println!("cargo:rustc-link-lib=user32"); println!("cargo:rustc-link-lib=gdi32"); - lib.link_paths[0] = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()) - .join(lib.link_paths[0].as_path()) - .into(); + lib.link_paths[0] = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) + .join(lib.link_paths[0].as_path()); } ( lib.include_paths[0].to_str().unwrap().to_owned(), lib.link_paths[0].to_str().unwrap().to_owned(), lib.found_names - .iter() - .filter(|n| n.starts_with("assimp")) - .nth(0) + .iter().find(|n| n.starts_with("assimp")) .unwrap() .to_owned(), ) diff --git a/build_support/mod.rs b/build_support/mod.rs index a233bb8..d25cafc 100644 --- a/build_support/mod.rs +++ b/build_support/mod.rs @@ -10,7 +10,7 @@ pub fn run_command(cmd: &mut Command, program: &str) { "current_dir: {:?}\nrunning: {:?}", cmd.get_current_dir() .map(|p| p.display().to_string()) - .unwrap_or("".to_string()), + .unwrap_or_else(|| "".to_string()), cmd ); let status = match cmd.status() { diff --git a/build_support/target.rs b/build_support/target.rs index 65c8e77..db0819a 100644 --- a/build_support/target.rs +++ b/build_support/target.rs @@ -22,13 +22,13 @@ impl Display for Target { if let Some(ref abi) = self.abi { write!(f, "-{}", abi) } else { - Result::Ok(()) + Ok(()) } } } impl Target { - pub fn target() -> Target { + pub fn new() -> Target { let target_str = env::var("TARGET").unwrap(); Target::parse_target(target_str) } From be338cb1145a280adcb78e9d3d3cba57dc73738e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 13:58:20 +0200 Subject: [PATCH 07/98] Apply rustfmt --- build.rs | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/build.rs b/build.rs index a929099..1b18d38 100644 --- a/build.rs +++ b/build.rs @@ -65,7 +65,10 @@ fn install(manifest: &BuildManifest) { println!("cargo:rustc-link-lib=c++"); } - run_bindgen(PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), None); + run_bindgen( + PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), + None, + ); } fn build_from_source(target: &Target) -> BuildManifest { @@ -77,6 +80,7 @@ fn build_from_source(target: &Target) -> BuildManifest { env::var("ASSIMP_SOURCE_DIR") .unwrap_or_else(|_| current_dir.join("assimp").to_str().unwrap().to_string()), ); + if !assimp_source_dir.exists() { // source dir not exist, try to clone it let mut git_clone = Command::new("git"); @@ -90,12 +94,12 @@ fn build_from_source(target: &Target) -> BuildManifest { println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_OUT_DIR"); // use or /build-from-source - let out_dir = current_dir.join( - env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("build-from-source") - .to_string_lossy() - .to_string()), - ); + let out_dir = current_dir.join(env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| { + PathBuf::from(env::var("OUT_DIR").unwrap()) + .join("build-from-source") + .to_string_lossy() + .to_string() + })); let assimp_build_dir = out_dir.join("assimp"); let assimp_install_dir = assimp_build_dir.join("out"); @@ -146,8 +150,14 @@ fn build_from_source(target: &Target) -> BuildManifest { env::var("CMAKE_GENERATOR").unwrap_or_else(|_| "Ninja".to_string()), ) .env("CC", env::var("CC").unwrap_or_else(|_| "clang".to_string())) - .env("CXX", env::var("CXX").unwrap_or_else(|_| "clang++".to_string())) - .env("ASM", env::var("ASM").unwrap_or_else(|_| "clang".to_string())) + .env( + "CXX", + env::var("CXX").unwrap_or_else(|_| "clang++".to_string()), + ) + .env( + "ASM", + env::var("ASM").unwrap_or_else(|_| "clang".to_string()), + ) .env( "CXXFLAGS", env::var("CXXFLAGS").unwrap_or(format!("-target {}", target)), @@ -248,7 +258,7 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { bindings_rs: PathBuf::from("bindings.rs"), target: manifest.target.clone(), }) - .unwrap(); + .unwrap(); let manifest_json_date = manifest_json.as_bytes(); let mut header = tar::Header::new_gnu(); header.set_size(manifest_json_date.len() as u64); @@ -313,12 +323,7 @@ fn main() { feature_suffix.push_str("-nozlib"); } - let cache_tar_name = format!( - "russimp-{}-{}{}.tar.gz", - version, - target, - feature_suffix - ); + let cache_tar_name = format!("russimp-{}-{}{}.tar.gz", version, target, feature_suffix); println!("cargo:rerun-if-env-changed=RUSSIMP_PREBUILT"); let use_cache = env::var("RUSSIMP_PREBUILT").unwrap_or_else(|_| "ON".to_string()) != "OFF" @@ -356,6 +361,7 @@ fn main() { PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), Some(&PathBuf::from(include)), ); + println!("cargo:rustc-link-search=native={}", libdir); println!("cargo:rustc-link-lib={}", libname); } @@ -404,7 +410,8 @@ fn assimp_dynamic_linking() -> (String, String, String) { lib.include_paths[0].to_str().unwrap().to_owned(), lib.link_paths[0].to_str().unwrap().to_owned(), lib.found_names - .iter().find(|n| n.starts_with("assimp")) + .iter() + .find(|n| n.starts_with("assimp")) .unwrap() .to_owned(), ) From de5233c1ccb1d635dd1a65172afdfca5d0105260 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 7 Jan 2023 14:01:19 +0200 Subject: [PATCH 08/98] Remove bindings.rs from tar package since we no longer use it --- assimp | 2 +- build.rs | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/assimp b/assimp index 02f0706..9ace81a 160000 --- a/assimp +++ b/assimp @@ -1 +1 @@ -Subproject commit 02f070667a142b6a54058d85af8a852a20625c78 +Subproject commit 9ace81a3d22fbb25039983eae27a818f09ef18a9 diff --git a/build.rs b/build.rs index 1b18d38..8e4cd48 100644 --- a/build.rs +++ b/build.rs @@ -224,12 +224,6 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { let enc = GzEncoder::new(file, Compression::default()); let mut tar_builder = tar::Builder::new(enc); - tar_builder - .append_file( - "bindings.rs", - &mut fs::File::open(&manifest.bindings_rs).unwrap(), - ) - .unwrap(); tar_builder .append_file( "LICENSE", @@ -255,10 +249,11 @@ fn package(manifest: &BuildManifest, output: impl AsRef) { link_search_dir: PathBuf::from("lib"), assimp_license: PathBuf::from("LICENSE"), link_libs: manifest.link_libs.clone(), - bindings_rs: PathBuf::from("bindings.rs"), + bindings_rs: PathBuf::from(BINDINGS_FILE), target: manifest.target.clone(), }) .unwrap(); + let manifest_json_date = manifest_json.as_bytes(); let mut header = tar::Header::new_gnu(); header.set_size(manifest_json_date.len() as u64); From 16ef16f23ea8179de00109c4552f021e6f1d40ec Mon Sep 17 00:00:00 2001 From: AregevDev Date: Tue, 10 Jan 2023 22:05:22 +0200 Subject: [PATCH 09/98] Rewrite build.rs --- Cargo.toml | 3 + build.rs | 441 ++++++++--------------------------------------------- 2 files changed, 63 insertions(+), 381 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5d74227..5ff31cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ exclude = ["/assimp", "*.bash", "*.ps1"] [lib] name = "russimp_sys" path = "src/lib.rs" +doctest = false [features] default = [] @@ -32,6 +33,8 @@ serde = { version = "1.0", features = ["derive"] } tar = "0.4" flate2 = "1.0" num_cpus = "1.13" +cmake = "0.1.49" +which = "4.3.0" [package.metadata.vcpkg] git = "https://github.com/microsoft/vcpkg" diff --git a/build.rs b/build.rs index 8e4cd48..a23953a 100644 --- a/build.rs +++ b/build.rs @@ -1,35 +1,74 @@ mod build_support; use std::{ - env, fs, io, + env, io, path::{Path, PathBuf}, process::Command, time::SystemTime, }; -use build_support::{static_lib_filename, Target}; -use flate2::{read::GzDecoder, write::GzEncoder, Compression}; -use serde::{Deserialize, Serialize}; - const BINDINGS_FILE: &str = "bindings.rs"; const WRAPPER_FILE: &str = "wrapper.h"; -const INCLUDE_DIR: &str = "assimp/include"; -#[derive(Serialize, Deserialize, Debug, Clone)] -struct BuildManifest { - pub link_search_dir: PathBuf, - pub assimp_license: PathBuf, - pub link_libs: Vec, - pub bindings_rs: PathBuf, - pub target: String, +// Compiler specific compiler flags for CMake +fn compiler_flags() -> Vec<&'static str> { + let mut flags = Vec::new(); + + if cfg!(target_env = "msvc") { + flags.push("/EHsc"); + + // Find Ninja + if which::which("ninja").is_ok() { + env::set_var("CMAKE_GENERATOR", "Ninja"); + } + } + + flags } -fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { - let builder = bindgen::Builder::default(); +fn lib_name() -> &'static str { + return if cfg!(target_env = "msvc") { + "assimp-vc143-mt" + } else { + "assimp" + }; +} + +fn main() { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + + // Build Zlib from source? + let build_zlib = if cfg!(feature = "nozlib") { + "OFF" + } else { + "ON" + }; + + // CMake + let mut cmake = cmake::Config::new("assimp"); + cmake + .profile("Release") + .static_crt(true) + .define("BUILD_SHARED_LIBS", "OFF") + .define("ASSIMP_BUILD_ASSIMP_TOOLS", "OFF") + .define("ASSIMP_BUILD_TESTS", "OFF") + .define("ASSIMP_BUILD_ZLIB", build_zlib); + + if cfg!(target_os = "windows") && cfg!(target_env = "gnu") { + panic!("Windows GNU is not supported, assimp fails to build for some reason\nSee https://github.com/assimp/assimp/issues/4868"); + } - builder + // Add compiler flags + for flag in compiler_flags().iter() { + cmake.cflag(flag); + cmake.cxxflag(flag); + } + + let cmake_dir = cmake.build(); + + bindgen::builder() .header(WRAPPER_FILE) - .clang_arg(format!("-I{}", include_path.unwrap_or_else(|| Path::new(INCLUDE_DIR)).to_str().unwrap())) + .clang_arg(format!("-I{}", out_dir.join("include").display())) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .allowlist_type("ai.*") .allowlist_function("ai.*") @@ -41,373 +80,13 @@ fn run_bindgen(output_file: impl AsRef, include_path: Option<&Path>) { .derive_debug(true) .generate() .unwrap() - .write_to_file(output_file.as_ref()) + .write_to_file(out_dir.join(BINDINGS_FILE)) .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); -} -fn install(manifest: &BuildManifest) { println!( "cargo:rustc-link-search=native={}", - manifest.link_search_dir.display() - ); - - for lib in &manifest.link_libs { - println!("cargo:rustc-link-lib=static={}", lib); - } - - let target = Target::parse_target(&manifest.target); - - if target.system == "linux" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib=stdc++"); - } - - if target.system == "darwin" && cfg!(not(feature = "nolibcxx")) { - println!("cargo:rustc-link-lib=c++"); - } - - run_bindgen( - PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), - None, - ); -} - -fn build_from_source(target: &Target) -> BuildManifest { - let current_dir = env::current_dir().expect("Failed to get current dir"); - - println!("cargo:rerun-if-env-changed=ASSIMP_SOURCE_DIR"); - // use or /assimp - let assimp_source_dir = current_dir.join( - env::var("ASSIMP_SOURCE_DIR") - .unwrap_or_else(|_| current_dir.join("assimp").to_str().unwrap().to_string()), - ); - - if !assimp_source_dir.exists() { - // source dir not exist, try to clone it - let mut git_clone = Command::new("git"); - git_clone - .arg("clone") - .arg("https://github.com/assimp/assimp.git") - .arg(&assimp_source_dir) - .arg("--depth=1"); - build_support::run_command(&mut git_clone, "git"); - } - - println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_OUT_DIR"); - // use or /build-from-source - let out_dir = current_dir.join(env::var("RUSSIMP_BUILD_OUT_DIR").unwrap_or_else(|_| { - PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("build-from-source") - .to_string_lossy() - .to_string() - })); - - let assimp_build_dir = out_dir.join("assimp"); - let assimp_install_dir = assimp_build_dir.join("out"); - let assimp_lib_dir = assimp_install_dir.join("lib"); - let assimp_include_dir = assimp_install_dir.join("include"); - let assimp_license = assimp_source_dir.join("LICENSE"); - let bindings_rs = out_dir.join("bindings.rs"); - - // configure assimp - fs::create_dir_all(&assimp_build_dir).unwrap(); - let mut assimp_cmake = Command::new("cmake"); - assimp_cmake - .current_dir(&assimp_build_dir) - .arg(&assimp_source_dir) - .arg(format!("-DCMAKE_BUILD_TYPE={}", "Release")) - .arg(format!( - "-DCMAKE_INSTALL_PREFIX={}", - assimp_install_dir.to_str().unwrap() - )) - .arg(format!("-DBUILD_SHARED_LIBS={}", "OFF")) - .arg(format!("-DASSIMP_BUILD_ASSIMP_TOOLS={}", "OFF")) - .arg(format!("-DASSIMP_BUILD_TESTS={}", "OFF")) - .arg(format!( - "-DASSIMP_BUILD_ZLIB={}", - if cfg!(feature = "nozlib") { - "OFF" - } else { - "ON" - } - )); - - if target.system == "windows" { - // if windows - if target.abi == Some("gnu".to_owned()) { - panic!("MinGW is not supported"); - } - - match target.architecture.as_str() { - "x86_64" => assimp_cmake.args(["-A", "x64"]), - "i686" => assimp_cmake.args(["-A", "Win32"]), - _ => panic!("Unsupported architecture"), - }; - } else { - // if not windows, use ninja and clang - assimp_cmake - .env( - "CMAKE_GENERATOR", - env::var("CMAKE_GENERATOR").unwrap_or_else(|_| "Ninja".to_string()), - ) - .env("CC", env::var("CC").unwrap_or_else(|_| "clang".to_string())) - .env( - "CXX", - env::var("CXX").unwrap_or_else(|_| "clang++".to_string()), - ) - .env( - "ASM", - env::var("ASM").unwrap_or_else(|_| "clang".to_string()), - ) - .env( - "CXXFLAGS", - env::var("CXXFLAGS").unwrap_or(format!("-target {}", target)), - ) - .env( - "CFLAGS", - env::var("CFLAGS").unwrap_or(format!("-target {}", target)), - ); - } - - build_support::run_command(&mut assimp_cmake, "cmake"); - - // build assimp - let mut assimp_cmake_install = Command::new("cmake"); - assimp_cmake_install - .current_dir(&assimp_build_dir) - .args(["--build", "."]) - .args(["--target", "install"]) - .args(["--config", "Release"]) - .args([ - "--parallel", - &env::var("NUM_JOBS").unwrap_or_else(|_| num_cpus::get().to_string()), - ]); - - build_support::run_command(&mut assimp_cmake_install, "cmake"); - - let mut link_libs = if target.system == "windows" { - // if windows, there is a suffix after the assimp library name, find library name here. - let assimp_lib = fs::read_dir(&assimp_lib_dir) - .unwrap() - .map(|e| e.unwrap()) - .find(|f| f.file_name().to_string_lossy().starts_with("assimp")) - .expect("Failed to find assimp library"); - vec![assimp_lib - .file_name() - .to_str() - .unwrap() - .split('.') - .next() - .unwrap() - .to_owned()] - } else { - vec!["assimp".to_owned()] - }; - - if cfg!(not(feature = "nozlib")) { - link_libs.push("zlibstatic".to_owned()) - } - - // generate bindings.rs - run_bindgen(&bindings_rs, Some(&assimp_include_dir)); - - BuildManifest { - link_search_dir: assimp_lib_dir, - assimp_license, - link_libs, - bindings_rs, - target: target.to_string(), - } -} - -fn package(manifest: &BuildManifest, output: impl AsRef) { - let file = fs::File::create(output).unwrap(); - let enc = GzEncoder::new(file, Compression::default()); - let mut tar_builder = tar::Builder::new(enc); - - tar_builder - .append_file( - "LICENSE", - &mut fs::File::open(&manifest.assimp_license).unwrap(), - ) - .unwrap(); - - tar_builder - .append_dir("lib", &manifest.link_search_dir) - .unwrap(); - - for lib_name in &manifest.link_libs { - let filename = static_lib_filename(lib_name); - tar_builder - .append_file( - format!("lib/{}", filename), - &mut fs::File::open(manifest.link_search_dir.join(filename)).unwrap(), - ) - .unwrap(); - } - - let manifest_json = serde_json::to_string(&BuildManifest { - link_search_dir: PathBuf::from("lib"), - assimp_license: PathBuf::from("LICENSE"), - link_libs: manifest.link_libs.clone(), - bindings_rs: PathBuf::from(BINDINGS_FILE), - target: manifest.target.clone(), - }) - .unwrap(); - - let manifest_json_date = manifest_json.as_bytes(); - let mut header = tar::Header::new_gnu(); - header.set_size(manifest_json_date.len() as u64); - header.set_cksum(); - header.set_mode(0o644); - header.set_mtime( - SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .unwrap_or_default() - .as_secs(), - ); - - tar_builder - .append_data(&mut header, "manifest.json", manifest_json_date) - .unwrap(); - - tar_builder.finish().unwrap(); -} - -fn download_from_cache(cache_tar_name: impl AsRef, version: impl AsRef) -> BuildManifest { - let download_url = format!( - "https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", - version.as_ref(), - cache_tar_name.as_ref() + cmake_dir.join("lib").display() ); - - println!("Downloading {}", download_url); - let package = build_support::download(cache_tar_name, download_url).expect("Download Failed"); - - unpack(package) -} - -fn unpack(package: impl AsRef) -> BuildManifest { - let unpack_dir = PathBuf::from(env::var("OUT_DIR").unwrap()).join("unpack"); - fs::create_dir_all(&unpack_dir).unwrap(); - - let file = fs::File::open(package).unwrap(); - let mut tar_archive = tar::Archive::new(GzDecoder::new(file)); - - tar_archive.unpack(&unpack_dir).unwrap(); - - let manifest_json = unpack_dir.join("manifest.json"); - let manifest: BuildManifest = - serde_json::from_reader(io::BufReader::new(fs::File::open(manifest_json).unwrap())) - .unwrap(); - - BuildManifest { - link_search_dir: unpack_dir.join(manifest.link_search_dir), - assimp_license: unpack_dir.join(manifest.assimp_license), - link_libs: manifest.link_libs.clone(), - bindings_rs: unpack_dir.join(manifest.bindings_rs), - target: manifest.target, - } -} - -fn main() { - if cfg!(feature = "static-link") { - let target = Target::new(); - let version = env::var("CARGO_PKG_VERSION").unwrap(); - let mut feature_suffix = String::new(); - if cfg!(feature = "nozlib") { - feature_suffix.push_str("-nozlib"); - } - - let cache_tar_name = format!("russimp-{}-{}{}.tar.gz", version, target, feature_suffix); - - println!("cargo:rerun-if-env-changed=RUSSIMP_PREBUILT"); - let use_cache = env::var("RUSSIMP_PREBUILT").unwrap_or_else(|_| "ON".to_string()) != "OFF" - && cfg!(feature = "prebuilt"); - - let build_manifest = if use_cache { - download_from_cache(&cache_tar_name, &version) - } else { - let build_manifest = build_from_source(&target); - - // write build result to cache directory - println!("cargo:rerun-if-env-changed=RUSSIMP_BUILD_CACHE_DIR"); - if let Ok(cache_dir) = env::var("RUSSIMP_BUILD_CACHE_DIR") { - fs::create_dir_all(&cache_dir).unwrap(); - let output_tar_path = Path::new(&cache_dir).join(&cache_tar_name); - package(&build_manifest, output_tar_path); - } - - build_manifest - }; - - install(&build_manifest); - } else { - let (include, libdir, libname) = assimp_dynamic_linking(); - - if cfg!(target_os = "windows") { - let _ = Command::new("cargo") - .arg("vcpkg") - .arg("build") - .output() - .unwrap(); - } - - run_bindgen( - PathBuf::from(env::var("OUT_DIR").unwrap()).join(BINDINGS_FILE), - Some(&PathBuf::from(include)), - ); - - println!("cargo:rustc-link-search=native={}", libdir); - println!("cargo:rustc-link-lib={}", libname); - } -} - -fn assimp_dynamic_linking() -> (String, String, String) { - let target = env::var("TARGET").unwrap(); - let vcpkg_root = env::var("VCPKG_ROOT").unwrap_or_else(|_| "target/vcpkg".to_string()); - - let include_path = if target.contains("apple") { - "/opt/homebrew/opt/assimp/include" - } else if env::var("DOCS_RS").is_ok() { - "assimp/include" - } else { - "/usr/local/include" - }; - - let mut lib = vcpkg::Config::new() - .vcpkg_root(vcpkg_root.into()) - .find_package("assimp") - .unwrap_or(vcpkg::Library { - include_paths: vec![PathBuf::from(include_path)], - link_paths: vec![PathBuf::from("/usr/local/lib")], - found_names: vec!["assimp".to_owned()], - - ports: vec![], - cargo_metadata: vec![], - dll_paths: vec![], - found_dlls: vec![], - - is_static: false, - found_libs: vec![], - vcpkg_triplet: "".to_string(), - }); - - if cfg!(target_os = "windows") { - // Following dependencies are pulled in via Irrlicht. - // vcpkg doesn't know how to find these system dependencies, so we list them here. - println!("cargo:rustc-link-lib=user32"); - println!("cargo:rustc-link-lib=gdi32"); - lib.link_paths[0] = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()) - .join(lib.link_paths[0].as_path()); - } - - ( - lib.include_paths[0].to_str().unwrap().to_owned(), - lib.link_paths[0].to_str().unwrap().to_owned(), - lib.found_names - .iter() - .find(|n| n.starts_with("assimp")) - .unwrap() - .to_owned(), - ) + println!("cargo:rustc-link-lib=static={}", lib_name()); + println!("cargo:rustc-link-lib=static=zlibstatic"); } From 21b9b12a63cf66bdfbc5c693b1b74f255a0438f6 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 15:24:21 +0200 Subject: [PATCH 10/98] Fix build on Linux --- build.rs | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/build.rs b/build.rs index a23953a..ab8e735 100644 --- a/build.rs +++ b/build.rs @@ -1,14 +1,4 @@ -mod build_support; - -use std::{ - env, io, - path::{Path, PathBuf}, - process::Command, - time::SystemTime, -}; - -const BINDINGS_FILE: &str = "bindings.rs"; -const WRAPPER_FILE: &str = "wrapper.h"; +use std::{env, path::PathBuf}; // Compiler specific compiler flags for CMake fn compiler_flags() -> Vec<&'static str> { @@ -26,12 +16,26 @@ fn compiler_flags() -> Vec<&'static str> { flags } -fn lib_name() -> &'static str { - return if cfg!(target_env = "msvc") { - "assimp-vc143-mt" +fn lib_names() -> Vec<&'static str> { + let mut names = Vec::new(); + + if cfg!(target_env = "msvc") { + names.push("assimp-vc143-mt"); } else { - "assimp" - }; + names.push("assimp"); + } + + names.push("zlibstatic"); + + if cfg!(target_os = "linux") { + names.push("stdc++"); + } + + if cfg!(target_os = "macos") { + names.push("c++"); + } + + names } fn main() { @@ -67,7 +71,7 @@ fn main() { let cmake_dir = cmake.build(); bindgen::builder() - .header(WRAPPER_FILE) + .header("wrapper.h") .clang_arg(format!("-I{}", out_dir.join("include").display())) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .allowlist_type("ai.*") @@ -80,13 +84,15 @@ fn main() { .derive_debug(true) .generate() .unwrap() - .write_to_file(out_dir.join(BINDINGS_FILE)) + .write_to_file(out_dir.join("bindings.rs")) .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); println!( "cargo:rustc-link-search=native={}", cmake_dir.join("lib").display() ); - println!("cargo:rustc-link-lib=static={}", lib_name()); - println!("cargo:rustc-link-lib=static=zlibstatic"); + + for n in lib_names().iter() { + println!("cargo:rustc-link-lib=static={}", n); + } } From 9d1e182cc4e7958df994327e885138f7fb7f1792 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 15:34:19 +0200 Subject: [PATCH 11/98] Implement static-link feature --- build.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index ab8e735..515019c 100644 --- a/build.rs +++ b/build.rs @@ -19,8 +19,12 @@ fn compiler_flags() -> Vec<&'static str> { fn lib_names() -> Vec<&'static str> { let mut names = Vec::new(); - if cfg!(target_env = "msvc") { - names.push("assimp-vc143-mt"); + if cfg!(target_os = "windows") { + if cfg!(target_env = "gnu") { + panic!("Windows GNU is not supported, assimp fails to build for some reason.\nSee https://github.com/assimp/assimp/issues/4868"); + } else { + names.push("assimp-vc143-mt"); + } } else { names.push("assimp"); } @@ -48,20 +52,23 @@ fn main() { "ON" }; + // Build static libs? + let build_static = if cfg!(feature = "static-link") { + "ON" + } else { + "OFF" + }; + // CMake let mut cmake = cmake::Config::new("assimp"); cmake .profile("Release") .static_crt(true) - .define("BUILD_SHARED_LIBS", "OFF") + .define("BUILD_SHARED_LIBS", build_static) .define("ASSIMP_BUILD_ASSIMP_TOOLS", "OFF") .define("ASSIMP_BUILD_TESTS", "OFF") .define("ASSIMP_BUILD_ZLIB", build_zlib); - if cfg!(target_os = "windows") && cfg!(target_env = "gnu") { - panic!("Windows GNU is not supported, assimp fails to build for some reason\nSee https://github.com/assimp/assimp/issues/4868"); - } - // Add compiler flags for flag in compiler_flags().iter() { cmake.cflag(flag); From 2eb9f629972a0ee1136be5ac075bc8223a3aaa9e Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 15:44:01 +0200 Subject: [PATCH 12/98] Remove unnecessary build_support module and Cargo dependencies. --- Cargo.toml | 14 ---------- build_support/download.rs | 20 --------------- build_support/mod.rs | 45 -------------------------------- build_support/target.rs | 54 --------------------------------------- 4 files changed, 133 deletions(-) delete mode 100644 build_support/download.rs delete mode 100644 build_support/mod.rs delete mode 100644 build_support/target.rs diff --git a/Cargo.toml b/Cargo.toml index 5ff31cb..9db9a7b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,20 +26,6 @@ nolibcxx = [] [build-dependencies] bindgen = "0.63.0" -vcpkg = "0.2.15" -ureq = "2.5" -serde_json = "1.0" -serde = { version = "1.0", features = ["derive"] } -tar = "0.4" -flate2 = "1.0" num_cpus = "1.13" cmake = "0.1.49" which = "4.3.0" - -[package.metadata.vcpkg] -git = "https://github.com/microsoft/vcpkg" -rev = "7178ff9" - -[package.metadata.vcpkg.target] -x86_64-pc-windows-msvc = { triplet = "x64-windows-static-md", install = ["assimp", "zlib"] } -x86-pc-windows-msvc = { triplet = "x86-windows-static-md", install = ["assimp", "zlib"] } diff --git a/build_support/download.rs b/build_support/download.rs deleted file mode 100644 index 08a329e..0000000 --- a/build_support/download.rs +++ /dev/null @@ -1,20 +0,0 @@ -use std::path::{Path, PathBuf}; -use std::{env, fs, io}; - -pub fn download(name: impl AsRef, url: impl AsRef) -> io::Result { - let resp = ureq::get(url.as_ref()).call(); - let download_dir = Path::new(&env::var("OUT_DIR").unwrap()).join("download"); - fs::create_dir_all(&download_dir).unwrap(); - let output_path = download_dir.join(name.as_ref()); - - match resp { - Ok(resp) => { - let mut reader = resp.into_reader(); - - let mut output_file = fs::File::create(&output_path)?; - io::copy(&mut reader, &mut output_file)?; - Ok(output_path) - } - Err(error) => Err(io::Error::new(io::ErrorKind::Other, error.to_string())), - } -} diff --git a/build_support/mod.rs b/build_support/mod.rs deleted file mode 100644 index d25cafc..0000000 --- a/build_support/mod.rs +++ /dev/null @@ -1,45 +0,0 @@ -mod download; -mod target; -use std::{io::ErrorKind, process::Command}; - -pub use download::*; -pub use target::*; - -pub fn run_command(cmd: &mut Command, program: &str) { - println!( - "current_dir: {:?}\nrunning: {:?}", - cmd.get_current_dir() - .map(|p| p.display().to_string()) - .unwrap_or_else(|| "".to_string()), - cmd - ); - let status = match cmd.status() { - Ok(status) => status, - Err(ref e) if e.kind() == ErrorKind::NotFound => { - panic!( - "{}", - &format!( - "failed to execute command: {}\nis `{}` not installed?", - e, program - ) - ); - } - Err(e) => panic!("{}", &format!("failed to execute command: {:?}", e)), - }; - if !status.success() { - panic!( - "{}", - &format!("command did not execute successfully, got: {}", status) - ); - } -} - -#[cfg(any(target_os = "linux", target_os = "macos"))] -pub fn static_lib_filename(lib_name: &str) -> String { - format!("lib{}.a", lib_name) -} - -#[cfg(target_os = "windows")] -pub fn static_lib_filename(lib_name: &str) -> String { - format!("{}.lib", lib_name) -} diff --git a/build_support/target.rs b/build_support/target.rs deleted file mode 100644 index db0819a..0000000 --- a/build_support/target.rs +++ /dev/null @@ -1,54 +0,0 @@ -use std::{ - env, - fmt::{self, Display, Formatter}, -}; - -#[derive(Clone, Debug)] -pub struct Target { - pub architecture: String, - pub vendor: String, - pub system: String, - pub abi: Option, -} - -impl Display for Target { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!( - f, - "{}-{}-{}", - &self.architecture, &self.vendor, &self.system - )?; - - if let Some(ref abi) = self.abi { - write!(f, "-{}", abi) - } else { - Ok(()) - } - } -} - -impl Target { - pub fn new() -> Target { - let target_str = env::var("TARGET").unwrap(); - Target::parse_target(target_str) - } - - pub fn parse_target(target_str: impl AsRef) -> Target { - let target_str = target_str.as_ref(); - let target: Vec = target_str.split('-').map(|s| s.into()).collect(); - assert!(target.len() >= 3, "Failed to parse TARGET {}", target_str); - - let abi = if target.len() > 3 { - Some(target[3].clone()) - } else { - None - }; - - Target { - architecture: target[0].clone(), - vendor: target[1].clone(), - system: target[2].clone(), - abi, - } - } -} From daeff38aba122533d809e65cf91c9190d5e244f0 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 15:44:29 +0200 Subject: [PATCH 13/98] Add all C headers to bindgen's wrapper.h. --- wrapper.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/wrapper.h b/wrapper.h index d47a2d2..b267fc5 100644 --- a/wrapper.h +++ b/wrapper.h @@ -1,4 +1,23 @@ +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include +#include +#include +#include +#include #include From 4ac668ca1063fc903c8e11fa7eb0097892206180 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 16:08:54 +0200 Subject: [PATCH 14/98] Fix problematic libraries and minor crate update. --- Cargo.toml | 2 +- wrapper.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9db9a7b..04d2049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,6 @@ nolibcxx = [] [build-dependencies] bindgen = "0.63.0" -num_cpus = "1.13" +num_cpus = "1.13.1" cmake = "0.1.49" which = "4.3.0" diff --git a/wrapper.h b/wrapper.h index b267fc5..babe8f4 100644 --- a/wrapper.h +++ b/wrapper.h @@ -12,9 +12,7 @@ #include #include #include -#include #include -#include #include #include #include From 8be7269c0806854cae3d0cc8c8366f9f87905b66 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 17:28:16 +0200 Subject: [PATCH 15/98] Fix static-link being the other way around --- build.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.rs b/build.rs index 515019c..6b3a614 100644 --- a/build.rs +++ b/build.rs @@ -54,9 +54,9 @@ fn main() { // Build static libs? let build_static = if cfg!(feature = "static-link") { - "ON" - } else { "OFF" + } else { + "ON" }; // CMake From 1790dd263a11bf6e726bee013757bfd1f6948524 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 17:31:40 +0200 Subject: [PATCH 16/98] Fix dynamic link search path --- build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.rs b/build.rs index 6b3a614..895974e 100644 --- a/build.rs +++ b/build.rs @@ -99,6 +99,11 @@ fn main() { cmake_dir.join("lib").display() ); + println!( + "cargo:rustc-link-search=native={}", + cmake_dir.join("bin").display() + ); + for n in lib_names().iter() { println!("cargo:rustc-link-lib=static={}", n); } From f4425a69d8803294128b5fdc54d00bb4c7b4adc1 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Wed, 11 Jan 2023 17:44:07 +0200 Subject: [PATCH 17/98] Revert submodule to v5.2.5 --- assimp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assimp b/assimp index 9ace81a..9519a62 160000 --- a/assimp +++ b/assimp @@ -1 +1 @@ -Subproject commit 9ace81a3d22fbb25039983eae27a818f09ef18a9 +Subproject commit 9519a62dd20799c5493c638d1ef5a6f484e5faf1 From 90db9f4089cd7d4467fb77228cfd2e3ed35ed90e Mon Sep 17 00:00:00 2001 From: AregevDev Date: Thu, 12 Jan 2023 19:12:43 +0200 Subject: [PATCH 18/98] Buildscript downloads prebuilt package --- .gitmodules | 1 + Cargo.toml | 5 ++++- build.rs | 62 +++++++++++++++++++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index 7d9f53f..1c20522 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,4 @@ [submodule "assimp"] path = assimp url = https://github.com/assimp/assimp + branch = "v5.2.5" diff --git a/Cargo.toml b/Cargo.toml index 04d2049..c848580 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,9 @@ nolibcxx = [] [build-dependencies] bindgen = "0.63.0" -num_cpus = "1.13.1" cmake = "0.1.49" +flate2 = "1.0.25" +num_cpus = "1.13.1" +reqwest = { version = "0.11.13", features = ["blocking"] } +tar = "0.4.38" which = "4.3.0" diff --git a/build.rs b/build.rs index 895974e..c6ce6fc 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,6 @@ -use std::{env, path::PathBuf}; +use std::{env, fs, io, path::PathBuf}; +use std::io::Error; +use flate2::read::GzDecoder; // Compiler specific compiler flags for CMake fn compiler_flags() -> Vec<&'static str> { @@ -42,9 +44,7 @@ fn lib_names() -> Vec<&'static str> { names } -fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - +fn build_from_source() { // Build Zlib from source? let build_zlib = if cfg!(feature = "nozlib") { "OFF" @@ -77,9 +77,53 @@ fn main() { let cmake_dir = cmake.build(); + println!( + "cargo:rustc-link-search=native={}", + cmake_dir.join("lib").display() + ); + + println!( + "cargo:rustc-link-search=native={}", + cmake_dir.join("bin").display() + ); +} + +fn link_from_package() { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let target = env::var("TARGET").unwrap(); + let crate_version = env::var("CARGO_PKG_VERSION").unwrap(); + let archive_name = format!("russimp-{}-{}.tar.gz", crate_version, target); + let dl_link = format!("https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", crate_version, archive_name); + + match fs::File::open(&out_dir.join(&archive_name)) { + Ok(_) => {} + Err(_) => { + let resp = reqwest::blocking::get(dl_link).unwrap(); + let mut bytes = io::Cursor::new(resp.bytes().unwrap()); + + let mut file = fs::File::create(out_dir.join(&archive_name)).unwrap(); + io::copy(&mut bytes, &mut file).unwrap(); + } + } + + let file = fs::File::open(out_dir.join(&archive_name)).unwrap(); + let mut archive = tar::Archive::new(GzDecoder::new(file)); + archive.unpack(out_dir).unwrap(); +} + +fn main() { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + + if cfg!(not(feature = "prebuilt")) { + build_from_source(); + } else { + link_from_package(); + } + bindgen::builder() .header("wrapper.h") .clang_arg(format!("-I{}", out_dir.join("include").display())) + .clang_arg(format!("-I{}", "assimp/include")) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .allowlist_type("ai.*") .allowlist_function("ai.*") @@ -94,16 +138,6 @@ fn main() { .write_to_file(out_dir.join("bindings.rs")) .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); - println!( - "cargo:rustc-link-search=native={}", - cmake_dir.join("lib").display() - ); - - println!( - "cargo:rustc-link-search=native={}", - cmake_dir.join("bin").display() - ); - for n in lib_names().iter() { println!("cargo:rustc-link-lib=static={}", n); } From 6964cc0182e926c9ccb3e7fb96fc55caaca9d8db Mon Sep 17 00:00:00 2001 From: AregevDev Date: Thu, 12 Jan 2023 21:47:26 +0200 Subject: [PATCH 19/98] Support building shared libs from source. --- Cargo.toml | 5 +++-- build.rs | 29 +++++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c848580..9fb914a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,8 +19,9 @@ doctest = false [features] default = [] -prebuilt = ["static-link"] -static-link = [] +prebuilt = [] +build-assimp = [] +static-link = ["build-assimp"] nozlib = [] nolibcxx = [] diff --git a/build.rs b/build.rs index c6ce6fc..e4689d0 100644 --- a/build.rs +++ b/build.rs @@ -1,7 +1,16 @@ use std::{env, fs, io, path::PathBuf}; -use std::io::Error; use flate2::read::GzDecoder; +struct Library(&'static str, &'static str); + +const fn static_lib() -> &'static str { + return if cfg!(feature = "static-link") { + "static" + } else { + "dylib" + }; +} + // Compiler specific compiler flags for CMake fn compiler_flags() -> Vec<&'static str> { let mut flags = Vec::new(); @@ -18,27 +27,27 @@ fn compiler_flags() -> Vec<&'static str> { flags } -fn lib_names() -> Vec<&'static str> { +fn lib_names() -> Vec { let mut names = Vec::new(); if cfg!(target_os = "windows") { if cfg!(target_env = "gnu") { panic!("Windows GNU is not supported, assimp fails to build for some reason.\nSee https://github.com/assimp/assimp/issues/4868"); } else { - names.push("assimp-vc143-mt"); + names.push(Library("assimp-vc143-mt", static_lib())); } } else { - names.push("assimp"); + names.push(Library("assimp", static_lib())); } - names.push("zlibstatic"); + names.push(Library("zlibstatic", "static")); if cfg!(target_os = "linux") { - names.push("stdc++"); + names.push(Library("stdc++","dylib")); } if cfg!(target_os = "macos") { - names.push("c++"); + names.push( Library("c++", "dylib")); } names @@ -114,9 +123,9 @@ fn link_from_package() { fn main() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - if cfg!(not(feature = "prebuilt")) { + if cfg!(feature = "build-assimp") { build_from_source(); - } else { + } else if cfg!(feature = "prebuilt") { link_from_package(); } @@ -139,6 +148,6 @@ fn main() { .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); for n in lib_names().iter() { - println!("cargo:rustc-link-lib=static={}", n); + println!("cargo:rustc-link-lib={}={}", n.1, n.0); } } From 38275e2af5409370dea2bb107fb72a6b53a260fd Mon Sep 17 00:00:00 2001 From: AregevDev Date: Thu, 12 Jan 2023 21:47:51 +0200 Subject: [PATCH 20/98] GitHub actions cleanup. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 63 ++++++++--------------------------- install_assimp.bash | 24 ------------- 3 files changed, 15 insertions(+), 74 deletions(-) delete mode 100644 install_assimp.bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 02e5937..bf42ff2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: triple: aarch64-apple-darwin - os: windows-2019 triple: x86_64-pc-windows-msvc - features: ['static-link', 'static-link,nozlib'] + features: ['static-link', 'static-link, nozlib'] steps: - name: Checkout uses: actions/checkout@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3299102..039d0c2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,59 +6,24 @@ env: CARGO_TERM_COLOR: always jobs: - lin-build: - runs-on: ubuntu-latest + cross-platform-build: + runs-on: ${{ matrix.os }} + needs: install-deps + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 - - name: Install assimp - run: sudo bash ${GITHUB_WORKSPACE}/install_assimp.bash - - name: Install stable - uses: actions-rs/toolchain@v1 + - name: Install LLVM and Clang + uses: KyleMayes/install-llvm-action@v1.6.1 with: - profile: minimal - toolchain: stable - override: true - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --lib --verbose - - win-build: - runs-on: windows-latest - steps: - - name: Set up Visual Studio shell - uses: egor-tensin/vs-shell@v2 - - name: Set up LIBCLANG_PATH - run: echo "LIBCLANG_PATH=$env:VCINSTALLDIR\Tools\Llvm\x64\bin" >> $env:GITHUB_ENV - - uses: actions/checkout@v2 - - name: Install stable - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: install cargo-vcpkg - run: cargo install cargo-vcpkg - - name: vcpkg build - run: cargo vcpkg build - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --lib --verbose - - macos-build: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - name: Install assimp - run: brew install assimp - - name: Install stable + version: '12.0' + - name: Install CMake + uses: lukka/get-cmake@latest + - name: Install Rust uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable override: true - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --lib --verbose + - name: Run Tests + run: cargo test --lib --features static-link diff --git a/install_assimp.bash b/install_assimp.bash deleted file mode 100644 index 227fc31..0000000 --- a/install_assimp.bash +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -path_apt_sourcelist=/etc/apt/sources.list -path_assimp_repo=/tmp/assimp -path_assimp_build="${path_assimp_repo}/build" - -if ! grep -q "apt.llvm.org" ${path_apt_sourcelist}; then - bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" -fi - -apt install -y git cmake ninja-build - -if [ ! -d ${path_assimp_repo} ]; then - git clone --depth 1 --branch v5.2.5 https://github.com/assimp/assimp.git ${path_assimp_repo} -fi - -if [ ! -d ${path_assimp_build} ]; then - mkdir ${path_assimp_build} - # shellcheck disable=SC2164 - cd ${path_assimp_build} - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_INSTALL_PREFIX=/usr/local -G Ninja .. - ninja - ninja install -fi \ No newline at end of file From 419486e97fc414eecce42b74aa5834875ee1a441 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Thu, 12 Jan 2023 21:49:10 +0200 Subject: [PATCH 21/98] Fix GitHub actions. --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 039d0c2..3bc833a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,6 @@ env: jobs: cross-platform-build: runs-on: ${{ matrix.os }} - needs: install-deps strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] From 286aa213bbfc94297a1c82ae33f4401b472b24f2 Mon Sep 17 00:00:00 2001 From: AregevDev Date: Thu, 12 Jan 2023 21:57:02 +0200 Subject: [PATCH 22/98] Fix GitHub actions not cloning assimp submodule. --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bc833a..953fcd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,8 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 + with: + submodules: true - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1.6.1 with: From 0583d75e71b3233fc72ccdec4540ed44594f6c76 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 12 Jan 2023 23:15:18 +0200 Subject: [PATCH 23/98] Add XCode select on macOS build. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 953fcd4..8deafe6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,9 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + - name: macOS Xcode + run: 'sudo xcode-select --install' + if: ${{ matrix.os == 'macos-latest' }} - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1.6.1 with: From de5ebdad400639767ec6377bc9ab831bed11156e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 12 Jan 2023 23:46:51 +0200 Subject: [PATCH 24/98] Downgrade to macOS 11 --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8deafe6..2e3c541 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,14 +10,11 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ubuntu-latest, macos-11, windows-latest] steps: - uses: actions/checkout@v2 with: submodules: true - - name: macOS Xcode - run: 'sudo xcode-select --install' - if: ${{ matrix.os == 'macos-latest' }} - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1.6.1 with: From 7f1fc7b32b5b8eaee34ce0796af6dd9c0b07f7f3 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 00:12:48 +0200 Subject: [PATCH 25/98] Maybe LLVM is the problem? --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2e3c541..a23e33d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,13 +10,14 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-11, windows-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 with: submodules: true - name: Install LLVM and Clang uses: KyleMayes/install-llvm-action@v1.6.1 + if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }} with: version: '12.0' - name: Install CMake From 4280d3e1fe8cc94226ebcf631f57054c18b49a14 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 00:46:08 +0200 Subject: [PATCH 26/98] Move LLVM install to package managers. --- .github/workflows/test.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a23e33d..0163be3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,11 +15,17 @@ jobs: - uses: actions/checkout@v2 with: submodules: true - - name: Install LLVM and Clang - uses: KyleMayes/install-llvm-action@v1.6.1 - if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }} - with: - version: '12.0' +# - name: Install LLVM on Windows +# uses: KyleMayes/install-llvm-action@v1.6.1 +# with: +# version: '14.0' +# if: ${{ matrix.os == 'windows-latest' }} + - name: Install LLVM on macOS + run: brew install llvm + if: ${{ matrix.os == 'macos-latest' }} + - name: Install LLVM on Linux + run: sudo update && apt install llvm-dev libclang-dev clang + if: ${{ matrix.os == 'ubuntu-latest' }} - name: Install CMake uses: lukka/get-cmake@latest - name: Install Rust From 5bc079575b04bd6c88267e84f2b49046da9ffb4c Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 00:55:30 +0200 Subject: [PATCH 27/98] Ignore... --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0163be3..74a602c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: run: brew install llvm if: ${{ matrix.os == 'macos-latest' }} - name: Install LLVM on Linux - run: sudo update && apt install llvm-dev libclang-dev clang + run: sudo apt update && apt install llvm-dev libclang-dev clang -y if: ${{ matrix.os == 'ubuntu-latest' }} - name: Install CMake uses: lukka/get-cmake@latest From b2b33e2baa3ea0e1138b79b0456bdd77c452b7af Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 00:57:10 +0200 Subject: [PATCH 28/98] Add sudo. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74a602c..7a4bec7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: run: brew install llvm if: ${{ matrix.os == 'macos-latest' }} - name: Install LLVM on Linux - run: sudo apt update && apt install llvm-dev libclang-dev clang -y + run: sudo apt update && sudo apt install llvm-dev libclang-dev clang -y if: ${{ matrix.os == 'ubuntu-latest' }} - name: Install CMake uses: lukka/get-cmake@latest From 16a89d74903fc7e576094206242e617b195e73f6 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 01:20:16 +0200 Subject: [PATCH 29/98] Use the built-in LLVM installation on macOS. --- .github/workflows/test.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7a4bec7..af7335d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,14 +15,6 @@ jobs: - uses: actions/checkout@v2 with: submodules: true -# - name: Install LLVM on Windows -# uses: KyleMayes/install-llvm-action@v1.6.1 -# with: -# version: '14.0' -# if: ${{ matrix.os == 'windows-latest' }} - - name: Install LLVM on macOS - run: brew install llvm - if: ${{ matrix.os == 'macos-latest' }} - name: Install LLVM on Linux run: sudo apt update && sudo apt install llvm-dev libclang-dev clang -y if: ${{ matrix.os == 'ubuntu-latest' }} From a89f614f60b4154a43f802575b51b98ea70516c4 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 02:24:43 +0200 Subject: [PATCH 30/98] Use cache for LLVM, CMake and Rust --- .github/workflows/test.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af7335d..2bfbc96 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,15 +15,37 @@ jobs: - uses: actions/checkout@v2 with: submodules: true + depth: 1 + + - name: Cache LLVM Installation + id: llvm-cache + + uses: actions/cache@v3 + with: + path: | + ${{ runner.temp }}/llvm + key: ${{ runner.os }}-llvm-14.0 + + # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM on Linux - run: sudo apt update && sudo apt install llvm-dev libclang-dev clang -y - if: ${{ matrix.os == 'ubuntu-latest' }} + if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' + uses: KyleMayes/install-llvm-action@v1 + with: + directory: ${{ runner.temp }}/llvm + version: '14.0' + - name: Install CMake uses: lukka/get-cmake@latest + with: + useLocalCache: true + - name: Install Rust uses: actions-rs/toolchain@v1 with: toolchain: stable override: true + + - uses: Swatinem/rust-cache@v2 + - name: Run Tests run: cargo test --lib --features static-link From f12f535ab915c8ca9afd6b513571aa4c34af47ff Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 02:25:05 +0200 Subject: [PATCH 31/98] Add build stage --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2bfbc96..ad8dd26 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,5 +47,8 @@ jobs: - uses: Swatinem/rust-cache@v2 + - name: Build + run: cargo build --features static-link + - name: Run Tests run: cargo test --lib --features static-link From e1e1145c2f2ad1179740bb7f0216015722ef5ec3 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 02:37:05 +0200 Subject: [PATCH 32/98] Rename actions --- .github/workflows/test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad8dd26..ffb0c18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,9 +17,9 @@ jobs: submodules: true depth: 1 - - name: Cache LLVM Installation + - name: Cache LLVM id: llvm-cache - + if: runner.os == 'Linux' uses: actions/cache@v3 with: path: | @@ -27,7 +27,7 @@ jobs: key: ${{ runner.os }}-llvm-14.0 # LLVM comes preinstalled on Windows and macOS runners - - name: Install LLVM on Linux + - name: Install LLVM if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' uses: KyleMayes/install-llvm-action@v1 with: @@ -45,10 +45,11 @@ jobs: toolchain: stable override: true + - name: Cache Rust - uses: Swatinem/rust-cache@v2 - name: Build run: cargo build --features static-link - - name: Run Tests + - name: Test run: cargo test --lib --features static-link From 3010d334c239b58355b3a1873bb4e2a6467e59c5 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 02:38:00 +0200 Subject: [PATCH 33/98] Fix script --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ffb0c18..17f9f5d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: override: true - name: Cache Rust - - uses: Swatinem/rust-cache@v2 + uses: Swatinem/rust-cache@v2 - name: Build run: cargo build --features static-link From f51a67f07bb9f152891004a63de4859bf1d680f5 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 17:45:32 +0200 Subject: [PATCH 34/98] Implement package creation --- .github/workflows/test.yml | 7 +++--- Cargo.toml | 9 +++++++ bin/package/main.rs | 51 ++++++++++++++++++++++++++++++++++++++ build.rs | 28 +++++++++++++++++---- src/lib.rs | 4 +++ 5 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 bin/package/main.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17f9f5d..5ce6eff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ name: Test -on: [push, pull_request] +on: [ push, pull_request ] env: CARGO_TERM_COLOR: always @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [ ubuntu-latest, macos-latest, windows-latest ] steps: - uses: actions/checkout@v2 with: @@ -49,7 +49,8 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Build - run: cargo build --features static-link + run: | + cargo build --features static-link - name: Test run: cargo test --lib --features static-link diff --git a/Cargo.toml b/Cargo.toml index 9fb914a..10c36da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,10 @@ name = "russimp_sys" path = "src/lib.rs" doctest = false +[[bin]] +name = "package" +path = "bin/package/main.rs" + [features] default = [] prebuilt = [] @@ -25,8 +29,13 @@ static-link = ["build-assimp"] nozlib = [] nolibcxx = [] +[dependencies] +tar = "0.4.38" +flate2 = "1.0.25" + [build-dependencies] bindgen = "0.63.0" +built = "0.5.2" cmake = "0.1.49" flate2 = "1.0.25" num_cpus = "1.13.1" diff --git a/bin/package/main.rs b/bin/package/main.rs new file mode 100644 index 0000000..36f0464 --- /dev/null +++ b/bin/package/main.rs @@ -0,0 +1,51 @@ +use flate2::read::GzEncoder; +use flate2::Compression; +use std::fs::File; +use std::path::PathBuf; +use std::{env, fs}; + +const LICENSE_FILEPATH: &str = "LICENSE"; +const CONFIG_FILEPATH: &str = "include/assimp/config.h"; + +const fn static_lib() -> &'static str { + return if cfg!(feature = "static-link") { + "static" + } else { + "dylib" + }; +} + +fn main() { + let out_dir = PathBuf::from(env!("OUT_DIR")); + let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + + let target = russimp_sys::built_info::TARGET; + let ar_filename = format!("russimp-{}-{}.tar.gz", env!("CARGO_PKG_VERSION"), target); + + let from_dir = out_dir.join(static_lib()); + let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); + let mut config_filename = File::open(from_dir.join(CONFIG_FILEPATH)).unwrap(); + + fs::create_dir_all(&out_dir).unwrap(); + let tar_file = File::create(out_dir.join("package").join(&ar_filename)).unwrap(); + let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); + + archive + .append_dir_all(format!("{}/bin", static_lib()), from_dir.join("bin")) + .unwrap(); + archive + .append_dir_all(format!("{}/lib", static_lib()), from_dir.join("lib")) + .unwrap(); + archive + .append_file( + format!("{}/{}", static_lib(), LICENSE_FILEPATH), + &mut licence, + ) + .unwrap(); + archive + .append_file( + format!("{}/{}", static_lib(), CONFIG_FILEPATH), + &mut config_filename, + ) + .unwrap(); +} diff --git a/build.rs b/build.rs index e4689d0..4513791 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ -use std::{env, fs, io, path::PathBuf}; use flate2::read::GzDecoder; +use std::{env, fs, io, path::PathBuf}; struct Library(&'static str, &'static str); @@ -43,17 +43,19 @@ fn lib_names() -> Vec { names.push(Library("zlibstatic", "static")); if cfg!(target_os = "linux") { - names.push(Library("stdc++","dylib")); + names.push(Library("stdc++", "dylib")); } if cfg!(target_os = "macos") { - names.push( Library("c++", "dylib")); + names.push(Library("c++", "dylib")); } names } fn build_from_source() { + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + // Build Zlib from source? let build_zlib = if cfg!(feature = "nozlib") { "OFF" @@ -73,6 +75,7 @@ fn build_from_source() { cmake .profile("Release") .static_crt(true) + .out_dir(out_dir.join(static_lib())) .define("BUILD_SHARED_LIBS", build_static) .define("ASSIMP_BUILD_ASSIMP_TOOLS", "OFF") .define("ASSIMP_BUILD_TESTS", "OFF") @@ -102,7 +105,10 @@ fn link_from_package() { let target = env::var("TARGET").unwrap(); let crate_version = env::var("CARGO_PKG_VERSION").unwrap(); let archive_name = format!("russimp-{}-{}.tar.gz", crate_version, target); - let dl_link = format!("https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", crate_version, archive_name); + let dl_link = format!( + "https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", + crate_version, archive_name + ); match fs::File::open(&out_dir.join(&archive_name)) { Ok(_) => {} @@ -121,7 +127,10 @@ fn link_from_package() { } fn main() { + println!("cargo:rerun-if-changed=bin/package/main.rs"); + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); if cfg!(feature = "build-assimp") { build_from_source(); @@ -131,7 +140,7 @@ fn main() { bindgen::builder() .header("wrapper.h") - .clang_arg(format!("-I{}", out_dir.join("include").display())) + .clang_arg(format!("-I{}", out_dir.join(static_lib()).join("include").display())) .clang_arg(format!("-I{}", "assimp/include")) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .allowlist_type("ai.*") @@ -147,6 +156,15 @@ fn main() { .write_to_file(out_dir.join("bindings.rs")) .expect("Could not generate russimp bindings, for details see https://github.com/jkvargas/russimp-sys"); + let mut built_opts = built::Options::default(); + built_opts + .set_dependencies(false) + .set_compiler(false) + .set_ci(false) + .set_cfg(false); + built::write_built_file_with_opts(&built_opts, &manifest_dir, &out_dir.join("built.rs")) + .unwrap(); + for n in lib_names().iter() { println!("cargo:rustc-link-lib={}={}", n.1, n.0); } diff --git a/src/lib.rs b/src/lib.rs index 827dcb2..ce48d8b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,10 @@ #![allow(non_snake_case)] #![allow(improper_ctypes)] +pub mod built_info { + include!(concat!(env!("OUT_DIR"), "/built.rs")); +} + include!(concat!(env!("OUT_DIR"), "/bindings.rs")); impl From for String { From e19467cd647fa45a8e9a80b2c77d3f395b90e022 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 19:45:36 +0200 Subject: [PATCH 35/98] Add support for cross compiling on M1 and Raspberry Pi --- .github/workflows/test.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5ce6eff..4db76e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,10 +7,21 @@ env: jobs: cross-platform-build: - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.target.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + target: + - os: ubuntu-latest + triple: x86_64-unknown-linux-gnu + - os: ubuntu-latest + triple: aarch-unknown-linux-gnu + - os: macos-latest + triple: x86_64-apple-darwin + - os: macos-latest + triple: aarch64-apple-darwin + - os: windows-latest + triple: x86_64-pc-windows-msvc + features: [ 'build-assimp', 'static-link' ] steps: - uses: actions/checkout@v2 with: @@ -44,13 +55,13 @@ jobs: with: toolchain: stable override: true + target: ${{ matrix.target.triple }} - name: Cache Rust uses: Swatinem/rust-cache@v2 - name: Build - run: | - cargo build --features static-link + run: cargo build --features ${{ matrix.features }} --target ${{ matrix.target.triple }} - name: Test - run: cargo test --lib --features static-link + run: cargo test --features ${{ matrix.features }} --target ${{ matrix.target.triple }} From 63973c9c0a08c8d0d736e8ca5f6555a258e88f70 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 19:50:22 +0200 Subject: [PATCH 36/98] Fix Raspberry Pi triple --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4db76e7..34c7d82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - os: ubuntu-latest triple: x86_64-unknown-linux-gnu - os: ubuntu-latest - triple: aarch-unknown-linux-gnu + triple: aarch64-unknown-linux-gnu - os: macos-latest triple: x86_64-apple-darwin - os: macos-latest From f0cb95c32d51f199a216e629e8a2a4a611ae3b7e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 20:13:09 +0200 Subject: [PATCH 37/98] Install aarch64 GCC --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34c7d82..5b1aab3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,13 @@ jobs: directory: ${{ runner.temp }}/llvm version: '14.0' + - name: Install GGC on aarch64 + if: matrix.target.triple == 'aarch64-unknown-linux-gnu' + run: | + sudo apt update + sudo apt install -y gcc-aarch64-linux-gnu + sudo apt install -y g++-aarch64-linux-gnu + - name: Install CMake uses: lukka/get-cmake@latest with: From d118d755abd560cff7e77b345a7536d0dd5eccb0 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 20:29:08 +0200 Subject: [PATCH 38/98] Run with cross. --- .github/workflows/test.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b1aab3..9756583 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,7 +68,15 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Build - run: cargo build --features ${{ matrix.features }} --target ${{ matrix.target.triple }} + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: build + args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - name: Test - run: cargo test --features ${{ matrix.features }} --target ${{ matrix.target.triple }} + uses: actions-rs/cargo@v1 + with: + use-cross: true + command: test + args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} From cc2de1484cdeef6de79e2da35ef11ff5031cd5e5 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 20:45:10 +0200 Subject: [PATCH 39/98] Fix file create error --- bin/package/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/package/main.rs b/bin/package/main.rs index 36f0464..5e4972d 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -26,7 +26,7 @@ fn main() { let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); let mut config_filename = File::open(from_dir.join(CONFIG_FILEPATH)).unwrap(); - fs::create_dir_all(&out_dir).unwrap(); + fs::create_dir_all(&out_dir.join("package")).unwrap(); let tar_file = File::create(out_dir.join("package").join(&ar_filename)).unwrap(); let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); From 581b078a76a08c9694430faacc70db3342159c19 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 20:45:32 +0200 Subject: [PATCH 40/98] Make reqwest use rustls --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 10c36da..c8f3e48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,6 @@ built = "0.5.2" cmake = "0.1.49" flate2 = "1.0.25" num_cpus = "1.13.1" -reqwest = { version = "0.11.13", features = ["blocking"] } +reqwest = { version = "0.11.13", features = ["blocking", "rustls-tls"] } tar = "0.4.38" which = "4.3.0" From 4aa4bf55e836cb90e9dc66198cd51af7d6056816 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 21:20:37 +0200 Subject: [PATCH 41/98] Install libssl on Linux. --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9756583..ebac778 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -52,6 +52,12 @@ jobs: sudo apt install -y gcc-aarch64-linux-gnu sudo apt install -y g++-aarch64-linux-gnu + - name: Install OpenSSL on Linux + if: runner.os == 'Linux' + run: | + sudo apt update + sudo apt install -y libssl-dev + - name: Install CMake uses: lukka/get-cmake@latest with: From dc035713c6072654157a56c14b03bee0aa0ab742 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 21:46:33 +0200 Subject: [PATCH 42/98] Keep running matrix when jobs fail. --- .github/workflows/test.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebac778..2f28bf4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,7 @@ jobs: - os: windows-latest triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] + fail-fast: false steps: - uses: actions/checkout@v2 with: @@ -52,12 +53,6 @@ jobs: sudo apt install -y gcc-aarch64-linux-gnu sudo apt install -y g++-aarch64-linux-gnu - - name: Install OpenSSL on Linux - if: runner.os == 'Linux' - run: | - sudo apt update - sudo apt install -y libssl-dev - - name: Install CMake uses: lukka/get-cmake@latest with: From ca581dc105a760cce7932cfc6e606470197da690 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 13 Jan 2023 21:47:24 +0200 Subject: [PATCH 43/98] Fix fail-fast --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f28bf4..12fa7db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ jobs: cross-platform-build: runs-on: ${{ matrix.target.os }} strategy: + fail-fast: false matrix: target: - os: ubuntu-latest @@ -22,7 +23,6 @@ jobs: - os: windows-latest triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] - fail-fast: false steps: - uses: actions/checkout@v2 with: From 47cb31ed9bb55cd6bc4fea33b7247166264cf37d Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 02:30:21 +0200 Subject: [PATCH 44/98] Revert cross. --- .github/workflows/test.yml | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12fa7db..d340875 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ env: CARGO_TERM_COLOR: always jobs: - cross-platform-build: + build-test: runs-on: ${{ matrix.target.os }} strategy: fail-fast: false @@ -14,12 +14,8 @@ jobs: target: - os: ubuntu-latest triple: x86_64-unknown-linux-gnu - - os: ubuntu-latest - triple: aarch64-unknown-linux-gnu - os: macos-latest triple: x86_64-apple-darwin - - os: macos-latest - triple: aarch64-apple-darwin - os: windows-latest triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] @@ -29,30 +25,15 @@ jobs: submodules: true depth: 1 - - name: Cache LLVM - id: llvm-cache - if: runner.os == 'Linux' - uses: actions/cache@v3 - with: - path: | - ${{ runner.temp }}/llvm - key: ${{ runner.os }}-llvm-14.0 - # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' uses: KyleMayes/install-llvm-action@v1 with: directory: ${{ runner.temp }}/llvm + cached: true version: '14.0' - - name: Install GGC on aarch64 - if: matrix.target.triple == 'aarch64-unknown-linux-gnu' - run: | - sudo apt update - sudo apt install -y gcc-aarch64-linux-gnu - sudo apt install -y g++-aarch64-linux-gnu - - name: Install CMake uses: lukka/get-cmake@latest with: @@ -71,13 +52,11 @@ jobs: - name: Build uses: actions-rs/cargo@v1 with: - use-cross: true command: build args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - name: Test uses: actions-rs/cargo@v1 with: - use-cross: true command: test args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} From ef81762ff0e515d30a6bfee1e22d7fac30c8a379 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 12:24:14 +0200 Subject: [PATCH 45/98] Add package step. --- .github/workflows/release.yml | 8 ++++---- .github/workflows/test.yml | 36 ++++++++++++++++++++++++++++++++++- bin/package/main.rs | 14 +++++++++++--- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf42ff2..5e3a746 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,13 +22,13 @@ jobs: fail-fast: false matrix: target: - - os: ubuntu-20.04 + - os: ubuntu-lastest triple: x86_64-unknown-linux-gnu - - os: macos-11 + - os: macos-lastest triple: x86_64-apple-darwin - - os: macos-11 + - os: macos-latest triple: aarch64-apple-darwin - - os: windows-2019 + - os: windows-latest triple: x86_64-pc-windows-msvc features: ['static-link', 'static-link, nozlib'] steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d340875..6e6c67a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ env: CARGO_TERM_COLOR: always jobs: - build-test: + test: runs-on: ${{ matrix.target.os }} strategy: fail-fast: false @@ -16,6 +16,8 @@ jobs: triple: x86_64-unknown-linux-gnu - os: macos-latest triple: x86_64-apple-darwin + - os: macos-latest + triple: aarch64-apple-darwin - os: windows-latest triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] @@ -60,3 +62,35 @@ jobs: with: command: test args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} + if: ${{ matrix.target.triple }} != 'aarch64-apple-darwin' + + - name: Package Assimp + if: ${{ matrix.target.triple }} != 'aarch64-apple-darwin' + uses: actions-rs/cargo@v1 + with: + command: run + args: --target ${{ matrix.target.triple }} --bin package --features ${{ matrix.features }} + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + +# create-release: +# name: Create Release +# needs: test +# if: startsWith(github.ref, 'refs/tags/v') +# runs-on: ${{ matrix.target.os }} +# strategy: +# fail-fast: false +# matrix: +# target: +# - os: ubuntu-latest +# triple: x86_64-unknown-linux-gnu +# - os: macos-latest +# triple: x86_64-apple-darwin +# - os: macos-latest +# triple: aarch64-apple-darwin +# - os: windows-latest +# triple: x86_64-pc-windows-msvc +# features: [ 'build-assimp', 'static-link' ] +# env: +# RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp +# steps: diff --git a/bin/package/main.rs b/bin/package/main.rs index 5e4972d..dd57941 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -18,16 +18,22 @@ const fn static_lib() -> &'static str { fn main() { let out_dir = PathBuf::from(env!("OUT_DIR")); let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + let ar_dir = PathBuf::from(option_env!("RUSSIMP_PACKAGE_DIR").unwrap_or(env!("OUT_DIR"))); let target = russimp_sys::built_info::TARGET; - let ar_filename = format!("russimp-{}-{}.tar.gz", env!("CARGO_PKG_VERSION"), target); + let ar_filename = format!( + "russimp-{}-{}-{}.tar.gz", + env!("CARGO_PKG_VERSION"), + target, + static_lib() + ); let from_dir = out_dir.join(static_lib()); let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); let mut config_filename = File::open(from_dir.join(CONFIG_FILEPATH)).unwrap(); - fs::create_dir_all(&out_dir.join("package")).unwrap(); - let tar_file = File::create(out_dir.join("package").join(&ar_filename)).unwrap(); + fs::create_dir_all(&ar_dir.join("package")).unwrap(); + let tar_file = File::create(ar_dir.join("package").join(&ar_filename)).unwrap(); let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); archive @@ -48,4 +54,6 @@ fn main() { &mut config_filename, ) .unwrap(); + + archive.finish().unwrap(); } From d5c2b6c4700c01f117f5196c569aee5ec4992f5f Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 13:06:11 +0200 Subject: [PATCH 46/98] Fix package creation on CI. --- bin/package/main.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/package/main.rs b/bin/package/main.rs index dd57941..da186dc 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -8,14 +8,20 @@ const LICENSE_FILEPATH: &str = "LICENSE"; const CONFIG_FILEPATH: &str = "include/assimp/config.h"; const fn static_lib() -> &'static str { - return if cfg!(feature = "static-link") { + return if cfg!(feature = "build-assimp") && cfg!(not(feature = "static-link")) { + "dylib" + } else if cfg!(feature = "static-link") { "static" } else { - "dylib" + "" }; } fn main() { + if static_lib().is_empty() { + panic!("Nothing to package.\nPlease enable either the `build-assimp` or `static-link` feature."); + } + let out_dir = PathBuf::from(env!("OUT_DIR")); let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); let ar_dir = PathBuf::from(option_env!("RUSSIMP_PACKAGE_DIR").unwrap_or(env!("OUT_DIR"))); @@ -36,9 +42,12 @@ fn main() { let tar_file = File::create(ar_dir.join("package").join(&ar_filename)).unwrap(); let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); - archive - .append_dir_all(format!("{}/bin", static_lib()), from_dir.join("bin")) - .unwrap(); + if static_lib() == "dylib" { + archive + .append_dir_all(format!("{}/bin", static_lib()), from_dir.join("bin")) + .unwrap(); + } + archive .append_dir_all(format!("{}/lib", static_lib()), from_dir.join("lib")) .unwrap(); From 4468a1669ee13a6350c35ad42b56453854cd871a Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 13:41:31 +0200 Subject: [PATCH 47/98] Remove CI build for aarch64-apple-darwin. --- .github/workflows/test.yml | 4 ---- bin/package/main.rs | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e6c67a..34e6a17 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,8 +16,6 @@ jobs: triple: x86_64-unknown-linux-gnu - os: macos-latest triple: x86_64-apple-darwin - - os: macos-latest - triple: aarch64-apple-darwin - os: windows-latest triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] @@ -62,10 +60,8 @@ jobs: with: command: test args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - if: ${{ matrix.target.triple }} != 'aarch64-apple-darwin' - name: Package Assimp - if: ${{ matrix.target.triple }} != 'aarch64-apple-darwin' uses: actions-rs/cargo@v1 with: command: run diff --git a/bin/package/main.rs b/bin/package/main.rs index da186dc..f24899e 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -42,7 +42,8 @@ fn main() { let tar_file = File::create(ar_dir.join("package").join(&ar_filename)).unwrap(); let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); - if static_lib() == "dylib" { + // On Windows, the dynamic libraries are located in the bin directory. + if static_lib() == "dylib" && cfg!(target_env = "msvc") { archive .append_dir_all(format!("{}/bin", static_lib()), from_dir.join("bin")) .unwrap(); From 0a3da62b2c98b070fd3e04248c066ef5444c8b9d Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 15:48:09 +0200 Subject: [PATCH 48/98] Implement prebuilt feature from local archive. --- bin/package/main.rs | 12 ++++++------ build.rs | 34 ++++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/bin/package/main.rs b/bin/package/main.rs index f24899e..9d134ba 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -38,29 +38,29 @@ fn main() { let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); let mut config_filename = File::open(from_dir.join(CONFIG_FILEPATH)).unwrap(); - fs::create_dir_all(&ar_dir.join("package")).unwrap(); - let tar_file = File::create(ar_dir.join("package").join(&ar_filename)).unwrap(); + fs::create_dir_all(&ar_dir).unwrap(); + let tar_file = File::create(ar_dir.join(&ar_filename)).unwrap(); let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); // On Windows, the dynamic libraries are located in the bin directory. if static_lib() == "dylib" && cfg!(target_env = "msvc") { archive - .append_dir_all(format!("{}/bin", static_lib()), from_dir.join("bin")) + .append_dir_all(format!("bin"), from_dir.join("bin")) .unwrap(); } archive - .append_dir_all(format!("{}/lib", static_lib()), from_dir.join("lib")) + .append_dir_all(format!("lib"), from_dir.join("lib")) .unwrap(); archive .append_file( - format!("{}/{}", static_lib(), LICENSE_FILEPATH), + format!("{}", LICENSE_FILEPATH), &mut licence, ) .unwrap(); archive .append_file( - format!("{}/{}", static_lib(), CONFIG_FILEPATH), + format!("{}", CONFIG_FILEPATH), &mut config_filename, ) .unwrap(); diff --git a/build.rs b/build.rs index 4513791..2c64ac0 100644 --- a/build.rs +++ b/build.rs @@ -101,23 +101,29 @@ fn build_from_source() { } fn link_from_package() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let out_dir; let target = env::var("TARGET").unwrap(); let crate_version = env::var("CARGO_PKG_VERSION").unwrap(); - let archive_name = format!("russimp-{}-{}.tar.gz", crate_version, target); - let dl_link = format!( - "https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", - crate_version, archive_name - ); + let archive_name = format!("russimp-{}-{}-{}.tar.gz", crate_version, target, static_lib()); - match fs::File::open(&out_dir.join(&archive_name)) { - Ok(_) => {} - Err(_) => { - let resp = reqwest::blocking::get(dl_link).unwrap(); - let mut bytes = io::Cursor::new(resp.bytes().unwrap()); - - let mut file = fs::File::create(out_dir.join(&archive_name)).unwrap(); - io::copy(&mut bytes, &mut file).unwrap(); + if option_env!("RUSSIMP_PACKAGE_DIR").is_some() { + out_dir = PathBuf::from(env!("RUSSIMP_PACKAGE_DIR")); + } else { + out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + let dl_link = format!( + "https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", + crate_version, archive_name + ); + + match fs::File::open(&out_dir.join(&archive_name)) { + Ok(_) => {} + Err(_) => { + let resp = reqwest::blocking::get(dl_link).unwrap(); + let mut bytes = io::Cursor::new(resp.bytes().unwrap()); + + let mut file = fs::File::create(out_dir.join(&archive_name)).unwrap(); + io::copy(&mut bytes, &mut file).unwrap(); + } } } From aab763d20e6dcc5bf8660162da971be1c565d790 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 16:37:48 +0200 Subject: [PATCH 49/98] Add environment variable for "Package Assimp" step. --- bin/package/main.rs | 14 ++++---------- build.rs | 15 ++++++++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/package/main.rs b/bin/package/main.rs index 9d134ba..89223b4 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -8,13 +8,13 @@ const LICENSE_FILEPATH: &str = "LICENSE"; const CONFIG_FILEPATH: &str = "include/assimp/config.h"; const fn static_lib() -> &'static str { - return if cfg!(feature = "build-assimp") && cfg!(not(feature = "static-link")) { + if cfg!(feature = "build-assimp") && cfg!(not(feature = "static-link")) { "dylib" } else if cfg!(feature = "static-link") { "static" } else { "" - }; + } } fn main() { @@ -53,16 +53,10 @@ fn main() { .append_dir_all(format!("lib"), from_dir.join("lib")) .unwrap(); archive - .append_file( - format!("{}", LICENSE_FILEPATH), - &mut licence, - ) + .append_file(format!("{}", LICENSE_FILEPATH), &mut licence) .unwrap(); archive - .append_file( - format!("{}", CONFIG_FILEPATH), - &mut config_filename, - ) + .append_file(format!("{}", CONFIG_FILEPATH), &mut config_filename) .unwrap(); archive.finish().unwrap(); diff --git a/build.rs b/build.rs index 2c64ac0..02b0612 100644 --- a/build.rs +++ b/build.rs @@ -4,11 +4,11 @@ use std::{env, fs, io, path::PathBuf}; struct Library(&'static str, &'static str); const fn static_lib() -> &'static str { - return if cfg!(feature = "static-link") { + if cfg!(feature = "static-link") { "static" } else { "dylib" - }; + } } // Compiler specific compiler flags for CMake @@ -104,10 +104,15 @@ fn link_from_package() { let out_dir; let target = env::var("TARGET").unwrap(); let crate_version = env::var("CARGO_PKG_VERSION").unwrap(); - let archive_name = format!("russimp-{}-{}-{}.tar.gz", crate_version, target, static_lib()); + let archive_name = format!( + "russimp-{}-{}-{}.tar.gz", + crate_version, + target, + static_lib() + ); if option_env!("RUSSIMP_PACKAGE_DIR").is_some() { - out_dir = PathBuf::from(env!("RUSSIMP_PACKAGE_DIR")); + out_dir = PathBuf::from(env::var("RUSSIMP_PACKAGE_DIR").unwrap()); } else { out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let dl_link = format!( @@ -115,7 +120,7 @@ fn link_from_package() { crate_version, archive_name ); - match fs::File::open(&out_dir.join(&archive_name)) { + match fs::File::open(out_dir.join(&archive_name)) { Ok(_) => {} Err(_) => { let resp = reqwest::blocking::get(dl_link).unwrap(); From ce46cf4245e814bafd0342cd0a30880f7014029c Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 17:07:09 +0200 Subject: [PATCH 50/98] Create release. --- .github/workflows/test.yml | 45 +++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 34e6a17..87b2dff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: true depth: 1 @@ -62,6 +62,7 @@ jobs: args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - name: Package Assimp + if: startsWith(github.ref, 'refs/tags/v') uses: actions-rs/cargo@v1 with: command: run @@ -69,24 +70,24 @@ jobs: env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp -# create-release: -# name: Create Release -# needs: test -# if: startsWith(github.ref, 'refs/tags/v') -# runs-on: ${{ matrix.target.os }} -# strategy: -# fail-fast: false -# matrix: -# target: -# - os: ubuntu-latest -# triple: x86_64-unknown-linux-gnu -# - os: macos-latest -# triple: x86_64-apple-darwin -# - os: macos-latest -# triple: aarch64-apple-darwin -# - os: windows-latest -# triple: x86_64-pc-windows-msvc -# features: [ 'build-assimp', 'static-link' ] -# env: -# RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp -# steps: + release: + name: Release + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + depth: 1 + - name: Create GitHub Release + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: ${{ secrets.RUSSIMP_FORK_TOKEN }} + automatic_release_tag: ${{ github.ref }} + title: ${{ github.ref }} + files: | + ${{ env.RUSSIMP_PACKAGE_DIR }}/* From 18766e5906b8b6778b947a03f249dc0d0bf9b708 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 17:13:16 +0200 Subject: [PATCH 51/98] Fix release job. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87b2dff..b09c5d5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -75,8 +75,6 @@ jobs: needs: test if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest - env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp steps: - name: Checkout uses: actions/checkout@v3 @@ -91,3 +89,5 @@ jobs: title: ${{ github.ref }} files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp From 4dbb8b2f49df393faeaf606a28188143ec7e95af Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 17:49:48 +0200 Subject: [PATCH 52/98] Upload artifacts with release. --- .github/workflows/test.yml | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b09c5d5..9a002dd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -70,24 +70,29 @@ jobs: env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + - name: Create Release + if: startsWith(github.ref, 'refs/tags/v') + uses: ncipollo/release-action@v1 + with: + allowUpdates: true + artifacts: ${{ env.RUSSIMP_PACKAGE_DIR }}/* + artifactContentType: application/gzip + artifactErrorsFailBuild: true + draft: true + token: ${{ secrets.RUSSIMP_FORK_TOKEN }} + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + release: name: Release needs: test if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: true - depth: 1 - - name: Create GitHub Release - uses: marvinpinto/action-automatic-releases@latest + - name: Publish Release + uses: ncipollo/release-action@v1 with: - repo_token: ${{ secrets.RUSSIMP_FORK_TOKEN }} - automatic_release_tag: ${{ github.ref }} - title: ${{ github.ref }} - files: | - ${{ env.RUSSIMP_PACKAGE_DIR }}/* + allowUpdates: true + token: ${{ secrets.ACCESS_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp From 3ab2c7556870d394705c3c4fe917538dcc9faf91 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 18:12:01 +0200 Subject: [PATCH 53/98] Fix release token. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a002dd..cf7eca8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,6 +93,6 @@ jobs: uses: ncipollo/release-action@v1 with: allowUpdates: true - token: ${{ secrets.ACCESS_TOKEN }} + token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp From d1ac3bff47a09547cc74f03afa2eb7d375dac517 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 19:13:02 +0200 Subject: [PATCH 54/98] Remove redundant workflows. --- .github/workflows/release.yml | 109 ------------------- .github/workflows/{test.yml => workflow.yml} | 3 +- 2 files changed, 2 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/release.yml rename .github/workflows/{test.yml => workflow.yml} (98%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 5e3a746..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Build Release -on: - push: - tags: - - v* -jobs: - create-release: - runs-on: ubuntu-20.04 - steps: - - name: Create Release - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - omitBody: true - prerelease: true - draft: true - token: ${{ secrets.ACCESS_TOKEN }} - build: - runs-on: ${{ matrix.target.os }} - needs: create-release - strategy: - fail-fast: false - matrix: - target: - - os: ubuntu-lastest - triple: x86_64-unknown-linux-gnu - - os: macos-lastest - triple: x86_64-apple-darwin - - os: macos-latest - triple: aarch64-apple-darwin - - os: windows-latest - triple: x86_64-pc-windows-msvc - features: ['static-link', 'static-link, nozlib'] - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - submodules: true - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - name: Install dependencies (Linux) - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install ninja-build - - name: Install LLVM (Windows) # required for bindgen to work, see https://github.com/rust-lang/rust-bindgen/issues/1797 - uses: KyleMayes/install-llvm-action@v1 - if: runner.os == 'Windows' - with: - version: '11.0' - directory: ${{ runner.temp }}/llvm - - name: Install dependencies (macOS) - if: runner.os == 'macOS' - run: | - brew install ninja - - name: Install Rust target ${{ matrix.target.triple }} - run: | - rustup target add ${{ matrix.target.triple }} - - name: Build ${{ matrix.target.triple }} - env: - RUSSIMP_BUILD_CACHE_DIR: ${{ runner.temp }}/release - RUSSIMP_BUILD_OUT_DIR: ${{ runner.temp }}/out - RUSSIMP_PREBUILT: OFF - run: | - cargo build -vv --release --no-default-features --features ${{ matrix.features }} --target ${{ matrix.target.triple }} - shell: bash - - name: Upload release - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - artifacts: ${{ runner.temp }}/release/* - artifactContentType: application/gzip - artifactErrorsFailBuild: true - omitBodyDuringUpdate: true - omitNameDuringUpdate: true - prerelease: true - draft: true - token: ${{ secrets.ACCESS_TOKEN }} - publish-release: - runs-on: ubuntu-20.04 - needs: build - steps: - - name: Publish Release - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - omitBody: true - token: ${{ secrets.ACCESS_TOKEN }} - cargo-publish: - needs: publish-release - env: - CRATESIO_TOKEN: ${{ secrets.CRATESIO_TOKEN }} - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - name: Install assimp - run: sudo bash ${GITHUB_WORKSPACE}/install_assimp.bash - - name: Install stable - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: cargo publish - continue-on-error: true - run: cargo publish --token ${CRATESIO_TOKEN} diff --git a/.github/workflows/test.yml b/.github/workflows/workflow.yml similarity index 98% rename from .github/workflows/test.yml rename to .github/workflows/workflow.yml index cf7eca8..28d3945 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/workflow.yml @@ -1,4 +1,4 @@ -name: Test +name: Workflow on: [ push, pull_request ] @@ -7,6 +7,7 @@ env: jobs: test: + name: Test runs-on: ${{ matrix.target.os }} strategy: fail-fast: false From 4e4e2c69f0e8fc999006e62e7fc10b668294070a Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 20:42:17 +0200 Subject: [PATCH 55/98] Switch to a different release action. --- .github/workflows/workflow.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 28d3945..c52ce67 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -73,13 +73,11 @@ jobs: - name: Create Release if: startsWith(github.ref, 'refs/tags/v') - uses: ncipollo/release-action@v1 + uses: softprops/action-gh-release@v1 with: - allowUpdates: true - artifacts: ${{ env.RUSSIMP_PACKAGE_DIR }}/* - artifactContentType: application/gzip - artifactErrorsFailBuild: true + files: ${{ runner.temp }}/russimp/* draft: true + generate_release_notes: true token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp @@ -91,9 +89,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Publish Release - uses: ncipollo/release-action@v1 + uses: softprops/action-gh-release@v1 with: - allowUpdates: true token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp From db65332a88ce08b929ca9e15b407abbd6c91b537 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 21:20:25 +0200 Subject: [PATCH 56/98] Resplit workflows. --- .../workflows/{workflow.yml => release.yml} | 34 +++++----- .github/workflows/test.yml | 63 +++++++++++++++++++ bin/package/main.rs | 2 + 3 files changed, 82 insertions(+), 17 deletions(-) rename .github/workflows/{workflow.yml => release.yml} (76%) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/workflow.yml b/.github/workflows/release.yml similarity index 76% rename from .github/workflows/workflow.yml rename to .github/workflows/release.yml index c52ce67..0ebf6d4 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,16 @@ -name: Workflow +name: Release -on: [ push, pull_request ] +on: + push: + tags: + - 'v*' env: CARGO_TERM_COLOR: always jobs: test: - name: Test + name: Build runs-on: ${{ matrix.target.os }} strategy: fail-fast: false @@ -56,41 +59,38 @@ jobs: command: build args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - - name: Package Assimp - if: startsWith(github.ref, 'refs/tags/v') uses: actions-rs/cargo@v1 with: command: run args: --target ${{ matrix.target.triple }} --bin package --features ${{ matrix.features }} env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + RUSSIMP_PACKAGE_DIR: ./russimp-package - name: Create Release - if: startsWith(github.ref, 'refs/tags/v') uses: softprops/action-gh-release@v1 with: - files: ${{ runner.temp }}/russimp/* + files: ${{ RUSSIMP_PACKAGE_DIR }}/* draft: true generate_release_notes: true token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + RUSSIMP_PACKAGE_DIR: ./russimp-package release: name: Release needs: test - if: startsWith(github.ref, 'refs/tags/v') runs-on: ubuntu-latest steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: true + depth: 1 + - name: Publish Release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v1.1.3 with: token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp + RUSSIMP_PACKAGE_DIR: ./russimp-package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e2a9fc9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,63 @@ +name: Test + +on: [ push, pull_request ] + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + name: Test + runs-on: ${{ matrix.target.os }} + strategy: + fail-fast: false + matrix: + target: + - os: ubuntu-latest + triple: x86_64-unknown-linux-gnu + - os: macos-latest + triple: x86_64-apple-darwin + - os: windows-latest + triple: x86_64-pc-windows-msvc + features: [ 'build-assimp', 'static-link' ] + steps: + - uses: actions/checkout@v3 + with: + submodules: true + depth: 1 + + # LLVM comes preinstalled on Windows and macOS runners + - name: Install LLVM + if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' + uses: KyleMayes/install-llvm-action@v1 + with: + directory: ${{ runner.temp }}/llvm + cached: true + version: '14.0' + + - name: Install CMake + uses: lukka/get-cmake@latest + with: + useLocalCache: true + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + target: ${{ matrix.target.triple }} + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + + - name: Build + uses: actions-rs/cargo@v1 + with: + command: build + args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} + + - name: Test + uses: actions-rs/cargo@v1 + with: + command: test + args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} diff --git a/bin/package/main.rs b/bin/package/main.rs index 89223b4..010179b 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -60,4 +60,6 @@ fn main() { .unwrap(); archive.finish().unwrap(); + + println!("Package created at: {}", ar_dir.join(&ar_filename).display()); } From 06b78392c404828426a3b1eb592589261bc64a13 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 21:30:16 +0200 Subject: [PATCH 57/98] Remove Unix newlines again. --- rustfmt.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/rustfmt.toml b/rustfmt.toml index b6a70f5..8a1751f 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,2 +1 @@ use_field_init_shorthand = true -newline_style = "Unix" \ No newline at end of file From bcc8e156855dc7748a1c367337aa7161acc2744d Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 21:36:32 +0200 Subject: [PATCH 58/98] Cleanup. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- bin/package/main.rs | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ebf6d4..b214dc7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM - if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' + if: runner.os == 'Linux' uses: KyleMayes/install-llvm-action@v1 with: directory: ${{ runner.temp }}/llvm diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e2a9fc9..681ab65 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM - if: runner.os == 'Linux' && steps.llvm-cache.outputs.cache-hit != 'true' + if: runner.os == 'Linux' uses: KyleMayes/install-llvm-action@v1 with: directory: ${{ runner.temp }}/llvm diff --git a/bin/package/main.rs b/bin/package/main.rs index 010179b..b432d56 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -61,5 +61,8 @@ fn main() { archive.finish().unwrap(); - println!("Package created at: {}", ar_dir.join(&ar_filename).display()); + println!( + "Package created at: {}", + ar_dir.join(&ar_filename).display() + ); } From 8434cbc4ccfb34960912e3d9682ab64afbed4272 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 21:46:08 +0200 Subject: [PATCH 59/98] Use actual path instead of the environment variable. --- .github/workflows/release.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b214dc7..907c06d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,12 +70,10 @@ jobs: - name: Create Release uses: softprops/action-gh-release@v1 with: - files: ${{ RUSSIMP_PACKAGE_DIR }}/* + files: ./russimp-package/* draft: true generate_release_notes: true token: ${{ secrets.RUSSIMP_FORK_TOKEN }} - env: - RUSSIMP_PACKAGE_DIR: ./russimp-package release: name: Release From bc937b0e8ee10b4eca13b8e12f5040423b42bb70 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 14 Jan 2023 22:10:10 +0200 Subject: [PATCH 60/98] Try to fix release.yml workflow. --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 907c06d..62bd43b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - 'v*' + - v* env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 681ab65..58bf2ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,8 @@ jobs: triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: true depth: 1 From be330813a43dcab61def0ba6e0d23c1f970686c3 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:17:24 +0200 Subject: [PATCH 61/98] Release workflow (#1) Implement release workflow. --- .github/workflows/release.yml | 49 ++++++++++++++++++++++------------- .github/workflows/test.yml | 7 +++-- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 62bd43b..2b1864f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,17 +3,16 @@ name: Release on: push: tags: - - v* + - 'v*' env: CARGO_TERM_COLOR: always jobs: - test: + build: name: Build runs-on: ${{ matrix.target.os }} strategy: - fail-fast: false matrix: target: - os: ubuntu-latest @@ -27,7 +26,6 @@ jobs: - uses: actions/checkout@v3 with: submodules: true - depth: 1 # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM @@ -67,28 +65,43 @@ jobs: env: RUSSIMP_PACKAGE_DIR: ./russimp-package - - name: Create Release - uses: softprops/action-gh-release@v1 + - name: Upload artifacts + uses: actions/upload-artifact@v3 with: - files: ./russimp-package/* - draft: true - generate_release_notes: true - token: ${{ secrets.RUSSIMP_FORK_TOKEN }} + name: russimp-packages + path: ${{ env.RUSSIMP_PACKAGE_DIR }}/* + env: + RUSSIMP_PACKAGE_DIR: ./russimp-package - release: - name: Release - needs: test + publish: + name: Publish Release + needs: build runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 with: submodules: true - depth: 1 - - name: Publish Release - uses: softprops/action-gh-release@v1.1.3 + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: russimp-packages + path: ${{ env.RUSSIMP_PACKAGE_DIR }} + + - name: List artifacts + run: | + echo "Recieved artifacts:" + ls -l $RUSSIMP_PACKAGE_DIR + + - name: Publish release on GitHub + uses: softprops/action-gh-release@v1 with: + generate_release_notes: true + body: | + This release was automatically created by GitHub Actions. + files: | + ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOKEN }} - env: - RUSSIMP_PACKAGE_DIR: ./russimp-package + env: + RUSSIMP_PACKAGE_DIR: ./russimp-package diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 58bf2ed..4bcc236 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,10 @@ name: Test -on: [ push, pull_request ] +on: + push: + tags-ignore: + - 'v*' + pull_request: env: CARGO_TERM_COLOR: always @@ -25,7 +29,6 @@ jobs: uses: actions/checkout@v3 with: submodules: true - depth: 1 # LLVM comes preinstalled on Windows and macOS runners - name: Install LLVM From 26ca52d0d480e298e045017729c3e49324c1c2a7 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:22:28 +0200 Subject: [PATCH 62/98] Remove redundant CMake step. --- .github/workflows/release.yml | 7 ++----- .github/workflows/test.yml | 5 ----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2b1864f..efb1156 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: with: submodules: true - # LLVM comes preinstalled on Windows and macOS runners + # LLVM comes preinstalled on Windows and macOS runners. - name: Install LLVM if: runner.os == 'Linux' uses: KyleMayes/install-llvm-action@v1 @@ -36,10 +36,7 @@ jobs: cached: true version: '14.0' - - name: Install CMake - uses: lukka/get-cmake@latest - with: - useLocalCache: true + # CMake is preinstalled on all runners. - name: Install Rust uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bcc236..42d81c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,11 +39,6 @@ jobs: cached: true version: '14.0' - - name: Install CMake - uses: lukka/get-cmake@latest - with: - useLocalCache: true - - name: Install Rust uses: actions-rs/toolchain@v1 with: From ccf92766a8c9cada0c42e4586a612bffce3480fd Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:30:18 +0200 Subject: [PATCH 63/98] Replace unmaintained actions-rs steps with manual commands. --- .github/workflows/release.yml | 27 ++++++++++----------------- .github/workflows/test.yml | 22 ++++++++-------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index efb1156..d12bff7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,7 +23,8 @@ jobs: triple: x86_64-pc-windows-msvc features: [ 'build-assimp', 'static-link' ] steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: true @@ -36,29 +37,21 @@ jobs: cached: true version: '14.0' - # CMake is preinstalled on all runners. + # CMake and Rust are preinstalled on all runners. - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - target: ${{ matrix.target.triple }} + - name: Update Rust + run: | + rustup update stable + rustup target add ${{ matrix.target.triple }} - name: Cache Rust uses: Swatinem/rust-cache@v2 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} + run: cargo build --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - name: Package Assimp - uses: actions-rs/cargo@v1 - with: - command: run - args: --target ${{ matrix.target.triple }} --bin package --features ${{ matrix.features }} + run: cargo run --bin package --target ${{ matrix.target.triple }} --bin package --features ${{ matrix.features }} env: RUSSIMP_PACKAGE_DIR: ./russimp-package @@ -88,7 +81,7 @@ jobs: - name: List artifacts run: | - echo "Recieved artifacts:" + echo "Received artifacts:" ls -l $RUSSIMP_PACKAGE_DIR - name: Publish release on GitHub diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42d81c4..c1fc95b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,24 +39,18 @@ jobs: cached: true version: '14.0' - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - target: ${{ matrix.target.triple }} + # CMake and Rust are preinstalled on all runners. + + - name: Update Rust + run: | + rustup update stable + rustup target add ${{ matrix.target.triple }} - name: Cache Rust uses: Swatinem/rust-cache@v2 - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} + run: cargo build --target ${{ matrix.target.triple }} --features ${{ matrix.features }} - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - args: --target ${{ matrix.target.triple }} --features ${{ matrix.features }} + run: cargo test --target ${{ matrix.target.triple }} --features ${{ matrix.features }} From 0d2cd6bec3d33eb733b5dd72ef308726c99fad25 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:37:21 +0200 Subject: [PATCH 64/98] Test tag-ignore. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1fc95b..b91a86f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,8 @@ name: Test on: push: - tags-ignore: - - 'v*' +# tags-ignore: +# - 'v*' pull_request: env: From d42f7aff0d11e21763d420de8202e5e9a3c32677 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:53:11 +0200 Subject: [PATCH 65/98] Test tag-ignore. --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b91a86f..bd20495 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,8 @@ name: Test on: push: -# tags-ignore: -# - 'v*' + tags-ignore: + - 'v**' pull_request: env: From 6b3c948af9646a4263d2efc47978b21820f60b7f Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:54:02 +0200 Subject: [PATCH 66/98] Test tag-ignore. --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd20495..a66c074 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,10 @@ name: Test on: push: + branches: + tags-ignore: - - 'v**' + - 'v*' pull_request: env: From d53fb302f6735484908830e8b7795042d6a47186 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:54:53 +0200 Subject: [PATCH 67/98] Test tag-ignore. --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a66c074..f755012 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,9 +3,9 @@ name: Test on: push: branches: - - tags-ignore: - - 'v*' + - '**' + tags: + - '!v*' pull_request: env: From 05dbfb091b6668afa4449ec6d157d543c2d77fb6 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 20:37:21 +0200 Subject: [PATCH 68/98] Fix test.yml not triggering --- .github/workflows/test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1fc95b..e33f1ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,8 +2,10 @@ name: Test on: push: - tags-ignore: - - 'v*' + branches: + - '**' + tags: + - '!v*' # Exclude tags starting with 'v' pull_request: env: @@ -42,7 +44,7 @@ jobs: # CMake and Rust are preinstalled on all runners. - name: Update Rust - run: | + run: | rustup update stable rustup target add ${{ matrix.target.triple }} From 78dfdcdc272816bdc832a79145e170d6ff75548a Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 21:30:52 +0200 Subject: [PATCH 69/98] Remove assimp suffix on Windows. --- build.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/build.rs b/build.rs index 02b0612..eab2268 100644 --- a/build.rs +++ b/build.rs @@ -30,12 +30,8 @@ fn compiler_flags() -> Vec<&'static str> { fn lib_names() -> Vec { let mut names = Vec::new(); - if cfg!(target_os = "windows") { - if cfg!(target_env = "gnu") { - panic!("Windows GNU is not supported, assimp fails to build for some reason.\nSee https://github.com/assimp/assimp/issues/4868"); - } else { - names.push(Library("assimp-vc143-mt", static_lib())); - } + if cfg!(target_os = "windows") && cfg!(target_env = "gnu") { + panic!("Windows GNU is not supported, assimp fails to build for some reason.\nSee https://github.com/assimp/assimp/issues/4868"); } else { names.push(Library("assimp", static_lib())); } @@ -79,7 +75,8 @@ fn build_from_source() { .define("BUILD_SHARED_LIBS", build_static) .define("ASSIMP_BUILD_ASSIMP_TOOLS", "OFF") .define("ASSIMP_BUILD_TESTS", "OFF") - .define("ASSIMP_BUILD_ZLIB", build_zlib); + .define("ASSIMP_BUILD_ZLIB", build_zlib) + .define("LIBRARY_SUFFIX", ""); // Add compiler flags for flag in compiler_flags().iter() { From 8f4b0695be6ca557e1c7a2c5f4a8ba0abdcf5c29 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 21:52:11 +0200 Subject: [PATCH 70/98] Implement nozlib feature. --- build.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index eab2268..57abf3e 100644 --- a/build.rs +++ b/build.rs @@ -11,6 +11,10 @@ const fn static_lib() -> &'static str { } } +const fn build_zlib() -> bool { + cfg!(feature = "build-zlib") +} + // Compiler specific compiler flags for CMake fn compiler_flags() -> Vec<&'static str> { let mut flags = Vec::new(); @@ -36,7 +40,11 @@ fn lib_names() -> Vec { names.push(Library("assimp", static_lib())); } - names.push(Library("zlibstatic", "static")); + if cfg!(feature = "nozlib") { + names.push(Library("z", "dylib")); + } else { + names.push(Library("zlibstatic", "static")); + } if cfg!(target_os = "linux") { names.push(Library("stdc++", "dylib")); @@ -53,14 +61,14 @@ fn build_from_source() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); // Build Zlib from source? - let build_zlib = if cfg!(feature = "nozlib") { + let build_zlib = if build_zlib() { "OFF" } else { "ON" }; // Build static libs? - let build_static = if cfg!(feature = "static-link") { + let build_static = if static_lib() == "static" { "OFF" } else { "ON" From 5b2bd1df4124c8c2e53f0c9215466b48a984ee9e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 23:14:40 +0200 Subject: [PATCH 71/98] Update assimp to master branch to fix version inconsistency. --- .gitmodules | 2 +- bin/package/main.rs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitmodules b/.gitmodules index 1c20522..c25e11a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "assimp"] path = assimp url = https://github.com/assimp/assimp - branch = "v5.2.5" + branch = "master" diff --git a/bin/package/main.rs b/bin/package/main.rs index b432d56..b8d0940 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -1,3 +1,5 @@ +use russimp_sys::*; + use flate2::read::GzEncoder; use flate2::Compression; use std::fs::File; @@ -61,8 +63,13 @@ fn main() { archive.finish().unwrap(); - println!( - "Package created at: {}", - ar_dir.join(&ar_filename).display() - ); + unsafe { + println!( + "Package created at: {}\nAssimp version: {}.{}.{}", + ar_dir.join(&ar_filename).display(), + aiGetVersionMajor(), + aiGetVersionMinor(), + aiGetVersionPatch(), + ); + } } From f054467dd4c3a9d789b978974d2cbc761edbd6ff Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Tue, 17 Jan 2023 23:30:01 +0200 Subject: [PATCH 72/98] Update submodule. --- assimp | 2 +- build.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/assimp b/assimp index 9519a62..67eae8e 160000 --- a/assimp +++ b/assimp @@ -1 +1 @@ -Subproject commit 9519a62dd20799c5493c638d1ef5a6f484e5faf1 +Subproject commit 67eae8ee5afa149b11267de8ec87de1538fa80b6 diff --git a/build.rs b/build.rs index 57abf3e..d6dffca 100644 --- a/build.rs +++ b/build.rs @@ -61,11 +61,7 @@ fn build_from_source() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); // Build Zlib from source? - let build_zlib = if build_zlib() { - "OFF" - } else { - "ON" - }; + let build_zlib = if build_zlib() { "OFF" } else { "ON" }; // Build static libs? let build_static = if static_lib() == "static" { From b65900d448166993705a714b4e0903bc2185b45d Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Wed, 18 Jan 2023 00:08:42 +0200 Subject: [PATCH 73/98] Rewrite README.md --- README.md | 59 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f5b59a2..ee1d872 100644 --- a/README.md +++ b/README.md @@ -1,55 +1,58 @@ # russimp-sys ![russimp-sys](https://github.com/jkvargas/russimp-sys/workflows/russimp-sys/badge.svg?branch=main) [![Crates.io](https://img.shields.io/crates/v/russimp-sys.svg)](https://crates.io/crates/russimp-sys) -Assimp raw bindings for Rust. +Unsafe Rust bindings for the Open Asset Import Library (assimp). +See: [Our safe assimp Rust library](https://github.com/jkvargas/russimp) -There is a high chance that you are actually looking for russimp https://github.com/jkvargas/russimp +Raw bindings for the C API of assimp. -## How to use +## Platform Support +We build, test, and provide prebuilt packages for the following targets: +- x86_64-pc-windows-msvc +- x86_64-apple-darwin +- x86_64-unknown-linux-gnu -**By default**, you will need to have `assimp` installed on your system, if you are an ubuntu user I believe you will need to install `libassimp-dev`. +Additional targets that work when building from source: +- aarch64-apple-darwin (M1 Macs, cross-compiled on x86_64.) +- aarch64-unknown-linux-gnu (Raspberry Pi 4b, built on the machine itself.) -`russimp-sys` will look for `assimp` library and headers from your system, generates rust bindings and [dynamic linking]() to `assimp` shared library. +Platforms that are not supported and won't build: +- x86_64-pc-windows-gnu (See: [assimp/4686]([https://github.com/assimp/assimp/issues/4868)) -**For Windows**, This package uses [cargo-vcpkg](https://crates.io/crates/cargo-vcpkg) to manage system dependencies. Running ```cargo vcpkg build``` will build the necessary dependencies within the target directory. Alternatively provide a VCPKG_ROOT environment variable pointed at the location of a shared vcpkg installation. +## Installation -**For who want a standalone executable file**. Enable [`prebuilt`](#prebuilt) feature, then `russimp-sys` will download the prebuilt `assimp` [static library]() and its dependencies from github, linking libraries to your executable, but it will increase the size of the executable. - -## Features - -You can use the following [FEATURES](https://doc.rust-lang.org/cargo/reference/features.html#the-features-section) to configure the behavior of `russimp-sys`. +**By default** `russimp-sys` is looking for the `assimp` library in the system. +However there are many ways for the crate to install the library for you by specifying these crate features: ### `prebuilt` +This features will download a prebuilt package from this repo's release page, these packages are built and published automatically every time we release a new version. -Download prebuilt `Assimp` static library binaries from github and skip building from source. - -Because `Assimp` build is slow and have build environment requirements. We provide prebuilt binaries for common platforms and features. +In addition, you can specify a local package by setting the `ASSIMP_PACKAGE_DIR` environment variable to the path of the package. +You can run the provided package binary to generate a package for your platform. -When a new version is released, github action automatically runs pre-build tasks, and all prebuilt binaries are saved in [github releases](https://github.com/jkvargas/russimp-sys/releases). +```cargo run --bin package --features ``` -The `russimp-sys` build script will try to download the prebuilt binaries from github first, and skip the full source build. +### `build-assimp` or `static-link` +The `build-assimp` feature will build the library from source and link it dynamically. +The `static-link` feature will build the library from source and link it statically. -### `static-link` +Building from source requires the following dependencies: +- CMake +- libclang (for `bindgen`) +- A C/C++ compiler +- RECOMMENDED: Ninja (For Windows users the buildscript automatically uses Ninja if it finds it in the PATH) -Enabling `static-link` feature without `prebuilt` feature, will build `assimp` from source. - -Build from source need the following dependencies: - -* cmake -* clang -* Ninja for Linux and MacOS, Visual Studio 2019 for Windows +### Additional Features: ### `nozlib` -By default `russimp-sys` will statically link zlibstatic, you can disable this feature if it conflicts with other dependencies. +By default `russimp-sys` will statically link `zlibstatic`, enabling this feature will make the crate link to the system's `zlib` library. ### `nolibcxx` -By default `russimp-sys` links to `libstdc++` in linux and `libc++` in macos, turning this on `russimp-sys` won't link to the c++ standard library. +By default `russimp-sys` links to `libstdc++` on Linux and `libc++` on macOS. Enabling this feature won't link to any C++ standard library. ## Changelog ### 1.0.3 * Builds based on 5.2.5 release ### 1.0.0 - -- Builds based on 5.1.0 release From 0a892dadc2cd13100ed8d78dcb98e29148c8bb57 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 26 Jan 2023 20:14:19 +0200 Subject: [PATCH 74/98] Fix nozlib feature name bug. --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index d6dffca..a71b881 100644 --- a/build.rs +++ b/build.rs @@ -12,7 +12,7 @@ const fn static_lib() -> &'static str { } const fn build_zlib() -> bool { - cfg!(feature = "build-zlib") + cfg!(not(feature = "nozlib")) } // Compiler specific compiler flags for CMake From 84422a1589b7156a0c1ae388213fbeba64429898 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 26 Jan 2023 20:21:21 +0200 Subject: [PATCH 75/98] Fix static / dynamic build mismatch. --- build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.rs b/build.rs index a71b881..91cc1cb 100644 --- a/build.rs +++ b/build.rs @@ -64,7 +64,7 @@ fn build_from_source() { let build_zlib = if build_zlib() { "OFF" } else { "ON" }; // Build static libs? - let build_static = if static_lib() == "static" { + let build_static = if static_lib() == "dylib" { "OFF" } else { "ON" From 47b8b2e952422cb650328a1f51620436ca28de8e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 26 Jan 2023 20:28:46 +0200 Subject: [PATCH 76/98] Fix CRATESIO_TOKEN env variable. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d12bff7..8029732 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -92,6 +92,6 @@ jobs: This release was automatically created by GitHub Actions. files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* - token: ${{ secrets.RUSSIMP_FORK_TOKEN }} + token: ${{ secrets.CRATESIO_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ./russimp-package From 53c37a2d284d32a3668e125d142a1c0b2996f492 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 26 Jan 2023 20:33:26 +0200 Subject: [PATCH 77/98] Add changelog. --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ee1d872..268a1b4 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ However there are many ways for the crate to install the library for you by spec ### `prebuilt` This features will download a prebuilt package from this repo's release page, these packages are built and published automatically every time we release a new version. -In addition, you can specify a local package by setting the `ASSIMP_PACKAGE_DIR` environment variable to the path of the package. +In addition, you can specify a local package by setting the `RUSSIMP_PACKAGE_DIR` environment variable to the path of the package. You can run the provided package binary to generate a package for your platform. ```cargo run --bin package --features ``` @@ -45,14 +45,19 @@ Building from source requires the following dependencies: ### `nozlib` -By default `russimp-sys` will statically link `zlibstatic`, enabling this feature will make the crate link to the system's `zlib` library. +By default `russimp-sys` will statically link `zlibstatic`. Enabling this feature will link to the system's `zlib` library. ### `nolibcxx` By default `russimp-sys` links to `libstdc++` on Linux and `libc++` on macOS. Enabling this feature won't link to any C++ standard library. ## Changelog - +### 2.0.0 +* Complete overhaul of the build script. +* Expose all assimp headers. +* Rework CI pipeline. +* Support for local assimp packaging and local package usage. (See: `prebuilt` feature) +* Remove vcpkg support. ### 1.0.3 * Builds based on 5.2.5 release ### 1.0.0 From b52fdd8a4f376bd944f4b2e83e3ceafe275a4736 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Thu, 26 Jan 2023 20:36:28 +0200 Subject: [PATCH 78/98] Apply rustfmt. --- build.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/build.rs b/build.rs index 91cc1cb..4137d80 100644 --- a/build.rs +++ b/build.rs @@ -64,11 +64,7 @@ fn build_from_source() { let build_zlib = if build_zlib() { "OFF" } else { "ON" }; // Build static libs? - let build_static = if static_lib() == "dylib" { - "OFF" - } else { - "ON" - }; + let build_static = if static_lib() == "dylib" { "OFF" } else { "ON" }; // CMake let mut cmake = cmake::Config::new("assimp"); From 12b2768e1c052c532cc5158d86a0302062790c1c Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 27 Jan 2023 18:48:56 +0200 Subject: [PATCH 79/98] Bump edition, remove redundant dependencies. --- Cargo.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8f3e48..d969bb8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "russimp-sys" version = "1.0.3" authors = ["Jhonny Knaak de Vargas"] -edition = "2018" +edition = "2021" license-file = "LICENSE" readme = "README.md" homepage = "https://github.com/jkvargas/russimp-sys" @@ -27,7 +27,6 @@ prebuilt = [] build-assimp = [] static-link = ["build-assimp"] nozlib = [] -nolibcxx = [] [dependencies] tar = "0.4.38" @@ -38,7 +37,6 @@ bindgen = "0.63.0" built = "0.5.2" cmake = "0.1.49" flate2 = "1.0.25" -num_cpus = "1.13.1" reqwest = { version = "0.11.13", features = ["blocking", "rustls-tls"] } tar = "0.4.38" which = "4.3.0" From 5c831dbb6a4536043d86f4f8d5a9edaffc15e28f Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Fri, 27 Jan 2023 18:50:52 +0200 Subject: [PATCH 80/98] Remove nolibcxx feature. --- Cargo.toml | 1 - README.md | 4 ---- build.rs | 6 +++--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d969bb8..27fb62a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ default = [] prebuilt = [] build-assimp = [] static-link = ["build-assimp"] -nozlib = [] [dependencies] tar = "0.4.38" diff --git a/README.md b/README.md index 268a1b4..5bc071a 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,6 @@ Building from source requires the following dependencies: By default `russimp-sys` will statically link `zlibstatic`. Enabling this feature will link to the system's `zlib` library. -### `nolibcxx` - -By default `russimp-sys` links to `libstdc++` on Linux and `libc++` on macOS. Enabling this feature won't link to any C++ standard library. - ## Changelog ### 2.0.0 * Complete overhaul of the build script. diff --git a/build.rs b/build.rs index 4137d80..5c5a161 100644 --- a/build.rs +++ b/build.rs @@ -40,10 +40,10 @@ fn lib_names() -> Vec { names.push(Library("assimp", static_lib())); } - if cfg!(feature = "nozlib") { - names.push(Library("z", "dylib")); - } else { + if build_zlib() { names.push(Library("zlibstatic", "static")); + } else { + names.push(Library("z", "dylib")); } if cfg!(target_os = "linux") { From ec0c6c72f7f035c179237367d346eb9404babd9f Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 08:01:55 +0200 Subject: [PATCH 81/98] Tiny reformatting --- build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/build.rs b/build.rs index 5c5a161..48561ce 100644 --- a/build.rs +++ b/build.rs @@ -170,6 +170,7 @@ fn main() { .set_compiler(false) .set_ci(false) .set_cfg(false); + built::write_built_file_with_opts(&built_opts, &manifest_dir, &out_dir.join("built.rs")) .unwrap(); From f55486e90fe1e2546f212405de1e924092901de1 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 08:02:41 +0200 Subject: [PATCH 82/98] Update changelog. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5bc071a..d13674b 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ By default `russimp-sys` will statically link `zlibstatic`. Enabling this featur * Rework CI pipeline. * Support for local assimp packaging and local package usage. (See: `prebuilt` feature) * Remove vcpkg support. +* Remove `nolibcxx` feature. ### 1.0.3 * Builds based on 5.2.5 release ### 1.0.0 From b03b1620459ddbcf2193dff40a1a16f4eec43cb2 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 08:03:40 +0200 Subject: [PATCH 83/98] Increase version. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 27fb62a..53ff938 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "russimp-sys" -version = "1.0.3" +version = "2.0.0" authors = ["Jhonny Knaak de Vargas"] edition = "2021" license-file = "LICENSE" From 38d6f2e8d19513d84496c608e9e4c65097d10a0c Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 12:20:54 +0200 Subject: [PATCH 84/98] Fix uncompressed package archive bug. --- .github/workflows/release.yml | 6 ++++- README.md | 3 ++- bin/package/main.rs | 41 ++++++++++++++++++++--------------- build.rs | 40 +++++++++++++++++++++++++--------- 4 files changed, 60 insertions(+), 30 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8029732..d0b7126 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,6 +84,10 @@ jobs: echo "Received artifacts:" ls -l $RUSSIMP_PACKAGE_DIR + - name: Package crate + run: | + cargo package --features prebuilt + - name: Publish release on GitHub uses: softprops/action-gh-release@v1 with: @@ -92,6 +96,6 @@ jobs: This release was automatically created by GitHub Actions. files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* - token: ${{ secrets.CRATESIO_TOKEN }} + token: ${{ secrets.RUSSIMP_FORK_TOEKN }} env: RUSSIMP_PACKAGE_DIR: ./russimp-package diff --git a/README.md b/README.md index d13674b..32ce576 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ By default `russimp-sys` will statically link `zlibstatic`. Enabling this featur ## Changelog ### 2.0.0 -* Complete overhaul of the build script. +* Complete overhaul of the build process. + * Expose all assimp headers. * Rework CI pipeline. * Support for local assimp packaging and local package usage. (See: `prebuilt` feature) diff --git a/bin/package/main.rs b/bin/package/main.rs index b8d0940..4535597 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -1,13 +1,11 @@ use russimp_sys::*; -use flate2::read::GzEncoder; +use flate2::write::GzEncoder; use flate2::Compression; -use std::fs::File; +use std::fs::{self, File}; use std::path::PathBuf; -use std::{env, fs}; const LICENSE_FILEPATH: &str = "LICENSE"; -const CONFIG_FILEPATH: &str = "include/assimp/config.h"; const fn static_lib() -> &'static str { if cfg!(feature = "build-assimp") && cfg!(not(feature = "static-link")) { @@ -26,7 +24,7 @@ fn main() { let out_dir = PathBuf::from(env!("OUT_DIR")); let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let ar_dir = PathBuf::from(option_env!("RUSSIMP_PACKAGE_DIR").unwrap_or(env!("OUT_DIR"))); + let ar_dst_dir = PathBuf::from(option_env!("RUSSIMP_PACKAGE_DIR").unwrap_or(env!("OUT_DIR"))); let target = russimp_sys::built_info::TARGET; let ar_filename = format!( @@ -38,11 +36,12 @@ fn main() { let from_dir = out_dir.join(static_lib()); let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); - let mut config_filename = File::open(from_dir.join(CONFIG_FILEPATH)).unwrap(); - fs::create_dir_all(&ar_dir).unwrap(); - let tar_file = File::create(ar_dir.join(&ar_filename)).unwrap(); - let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::default())); + fs::create_dir_all(&ar_dst_dir).unwrap(); + println!("Packaging at: {}", ar_dst_dir.display()); + + let tar_file = File::create(ar_dst_dir.join(&ar_filename)).unwrap(); + let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::best())); // On Windows, the dynamic libraries are located in the bin directory. if static_lib() == "dylib" && cfg!(target_env = "msvc") { @@ -52,24 +51,30 @@ fn main() { } archive - .append_dir_all(format!("lib"), from_dir.join("lib")) + .append_dir_all("include", from_dir.join("include")) .unwrap(); archive - .append_file(format!("{}", LICENSE_FILEPATH), &mut licence) + .append_dir_all(format!("lib"), from_dir.join("lib")) .unwrap(); archive - .append_file(format!("{}", CONFIG_FILEPATH), &mut config_filename) + .append_file(format!("{}", LICENSE_FILEPATH), &mut licence) .unwrap(); archive.finish().unwrap(); - unsafe { - println!( - "Package created at: {}\nAssimp version: {}.{}.{}", - ar_dir.join(&ar_filename).display(), + let (major, minor, patch) = unsafe { + ( aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionPatch(), - ); - } + ) + }; + + println!( + "Package created at: {}\nAssimp version: {}.{}.{}", + ar_dst_dir.join(&ar_filename).display(), + major, + minor, + patch, + ); } diff --git a/build.rs b/build.rs index 48561ce..5103c45 100644 --- a/build.rs +++ b/build.rs @@ -61,10 +61,14 @@ fn build_from_source() { let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); // Build Zlib from source? - let build_zlib = if build_zlib() { "OFF" } else { "ON" }; + let build_zlib = if build_zlib() { "ON" } else { "OFF" }; // Build static libs? - let build_static = if static_lib() == "dylib" { "OFF" } else { "ON" }; + let build_shared = if static_lib() == "static" { + "OFF" + } else { + "ON" + }; // CMake let mut cmake = cmake::Config::new("assimp"); @@ -72,7 +76,7 @@ fn build_from_source() { .profile("Release") .static_crt(true) .out_dir(out_dir.join(static_lib())) - .define("BUILD_SHARED_LIBS", build_static) + .define("BUILD_SHARED_LIBS", build_shared) .define("ASSIMP_BUILD_ASSIMP_TOOLS", "OFF") .define("ASSIMP_BUILD_TESTS", "OFF") .define("ASSIMP_BUILD_ZLIB", build_zlib) @@ -98,7 +102,7 @@ fn build_from_source() { } fn link_from_package() { - let out_dir; + let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let target = env::var("TARGET").unwrap(); let crate_version = env::var("CARGO_PKG_VERSION").unwrap(); let archive_name = format!( @@ -108,30 +112,46 @@ fn link_from_package() { static_lib() ); + let ar_src_dir; + if option_env!("RUSSIMP_PACKAGE_DIR").is_some() { - out_dir = PathBuf::from(env::var("RUSSIMP_PACKAGE_DIR").unwrap()); + ar_src_dir = PathBuf::from(env::var("RUSSIMP_PACKAGE_DIR").unwrap()); } else { - out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); + ar_src_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let dl_link = format!( "https://github.com/jkvargas/russimp-sys/releases/download/v{}/{}", crate_version, archive_name ); - match fs::File::open(out_dir.join(&archive_name)) { + match fs::File::open(ar_src_dir.join(&archive_name)) { Ok(_) => {} Err(_) => { let resp = reqwest::blocking::get(dl_link).unwrap(); let mut bytes = io::Cursor::new(resp.bytes().unwrap()); - let mut file = fs::File::create(out_dir.join(&archive_name)).unwrap(); + let mut file = fs::File::create(ar_src_dir.join(&archive_name)).unwrap(); io::copy(&mut bytes, &mut file).unwrap(); } } } - let file = fs::File::open(out_dir.join(&archive_name)).unwrap(); + dbg!(ar_src_dir.join(&archive_name)); + + let file = fs::File::open(ar_src_dir.join(&archive_name)).unwrap(); let mut archive = tar::Archive::new(GzDecoder::new(file)); - archive.unpack(out_dir).unwrap(); + let ar_dest_dir = out_dir.join(static_lib()); + + archive.unpack(&ar_dest_dir).unwrap(); + + println!( + "cargo:rustc-link-search=native={}", + ar_dest_dir.join("lib").display() + ); + + println!( + "cargo:rustc-link-search=native={}", + ar_dest_dir.join("bin").display() + ); } fn main() { From 1c069910b5ffa02b8a576380e98114af97d45e96 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 13:15:34 +0200 Subject: [PATCH 85/98] Implement publishing on creates.io --- .github/workflows/release.yml | 7 ++++--- Cargo.toml | 6 +++--- build.rs | 2 -- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0b7126..d6717a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,9 +84,10 @@ jobs: echo "Received artifacts:" ls -l $RUSSIMP_PACKAGE_DIR - - name: Package crate - run: | - cargo package --features prebuilt + - name: Publish release on crates.io + run: cargo publish --features prebuilt --allow-dirty + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} - name: Publish release on GitHub uses: softprops/action-gh-release@v1 diff --git a/Cargo.toml b/Cargo.toml index 53ff938..9893059 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://github.com/jkvargas/russimp-sys" categories = ["rendering", "external-ffi-bindings", "game-engines", "multimedia"] keywords = ["assimp", "3d", "blend", "3ds", "glTF"] repository = "https://github.com/jkvargas/russimp-sys" -description = "Raw Assimp bindings for rust" +description = "Raw Assimp bindings for Rust" exclude = ["/assimp", "*.bash", "*.ps1"] [lib] @@ -23,13 +23,13 @@ path = "bin/package/main.rs" [features] default = [] -prebuilt = [] build-assimp = [] +prebuilt = [] static-link = ["build-assimp"] [dependencies] -tar = "0.4.38" flate2 = "1.0.25" +tar = "0.4.38" [build-dependencies] bindgen = "0.63.0" diff --git a/build.rs b/build.rs index 5103c45..a952f4d 100644 --- a/build.rs +++ b/build.rs @@ -155,8 +155,6 @@ fn link_from_package() { } fn main() { - println!("cargo:rerun-if-changed=bin/package/main.rs"); - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); From 1ac7ad168fc84a3f0d445be3b9b86719f91d5018 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 15:06:36 +0200 Subject: [PATCH 86/98] Make package binary return Result. --- bin/package/main.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/bin/package/main.rs b/bin/package/main.rs index 4535597..2710237 100644 --- a/bin/package/main.rs +++ b/bin/package/main.rs @@ -3,6 +3,7 @@ use russimp_sys::*; use flate2::write::GzEncoder; use flate2::Compression; use std::fs::{self, File}; +use std::io; use std::path::PathBuf; const LICENSE_FILEPATH: &str = "LICENSE"; @@ -17,9 +18,12 @@ const fn static_lib() -> &'static str { } } -fn main() { +fn main() -> Result<(), Box> { if static_lib().is_empty() { - panic!("Nothing to package.\nPlease enable either the `build-assimp` or `static-link` feature."); + return Err(Box::new(io::Error::new( + io::ErrorKind::Other, + "You must specify either the `static-link` or `build-assimp` feature", + ))); } let out_dir = PathBuf::from(env!("OUT_DIR")); @@ -35,32 +39,24 @@ fn main() { ); let from_dir = out_dir.join(static_lib()); - let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH)).unwrap(); + let mut licence = File::open(manifest_dir.join(LICENSE_FILEPATH))?; - fs::create_dir_all(&ar_dst_dir).unwrap(); + fs::create_dir_all(&ar_dst_dir)?; println!("Packaging at: {}", ar_dst_dir.display()); - let tar_file = File::create(ar_dst_dir.join(&ar_filename)).unwrap(); + let tar_file = File::create(ar_dst_dir.join(&ar_filename))?; let mut archive = tar::Builder::new(GzEncoder::new(tar_file, Compression::best())); // On Windows, the dynamic libraries are located in the bin directory. if static_lib() == "dylib" && cfg!(target_env = "msvc") { - archive - .append_dir_all(format!("bin"), from_dir.join("bin")) - .unwrap(); + archive.append_dir_all(format!("bin"), from_dir.join("bin"))?; } - archive - .append_dir_all("include", from_dir.join("include")) - .unwrap(); - archive - .append_dir_all(format!("lib"), from_dir.join("lib")) - .unwrap(); - archive - .append_file(format!("{}", LICENSE_FILEPATH), &mut licence) - .unwrap(); + archive.append_dir_all("include", from_dir.join("include"))?; + archive.append_dir_all(format!("lib"), from_dir.join("lib"))?; + archive.append_file(format!("{}", LICENSE_FILEPATH), &mut licence)?; - archive.finish().unwrap(); + archive.finish()?; let (major, minor, patch) = unsafe { ( @@ -77,4 +73,6 @@ fn main() { minor, patch, ); + + Ok(()) } From 050a49660f033f1ba68b691a73e08c0439712d6b Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 15:31:59 +0200 Subject: [PATCH 87/98] Try removing downloaded packages from the CI repo directory. --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6717a3..c52fcf1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,7 @@ jobs: uses: actions/download-artifact@v3 with: name: russimp-packages - path: ${{ env.RUSSIMP_PACKAGE_DIR }} + path: ${{ env.RUNNER_TEMP }}/russimp-package - name: List artifacts run: | @@ -99,4 +99,4 @@ jobs: ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} env: - RUSSIMP_PACKAGE_DIR: ./russimp-package + RUSSIMP_PACKAGE_DIR: ${{ env.RUNNER_TEMP }}/russimp-package From 5d00cfddf458dd6c9788b4cba66dce395c9d954f Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 15:38:57 +0200 Subject: [PATCH 88/98] Fix release.yml --- .github/workflows/release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c52fcf1..557b0cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -77,7 +77,7 @@ jobs: uses: actions/download-artifact@v3 with: name: russimp-packages - path: ${{ env.RUNNER_TEMP }}/russimp-package + path: ${{ runner.temp }}/russimp-package - name: List artifacts run: | @@ -85,7 +85,7 @@ jobs: ls -l $RUSSIMP_PACKAGE_DIR - name: Publish release on crates.io - run: cargo publish --features prebuilt --allow-dirty + run: cargo publish --features prebuilt env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} @@ -99,4 +99,4 @@ jobs: ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} env: - RUSSIMP_PACKAGE_DIR: ${{ env.RUNNER_TEMP }}/russimp-package + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package From ce398c9a6a238dd9fb354e18e6b5746be82291a4 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 15:45:55 +0200 Subject: [PATCH 89/98] Fix release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 557b0cb..04e9e88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -99,4 +99,4 @@ jobs: ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package + RUSSIMP_PACKAGE_DIR: /tmp/russimp-package # This is fine, because the runner is Linux. From 8e49a560d0ccd04b4e8a7d0a12116b37ebffec30 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 17:16:08 +0200 Subject: [PATCH 90/98] Fix release.yml --- .github/workflows/release.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 04e9e88..6a3d660 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,8 +41,7 @@ jobs: - name: Update Rust run: | - rustup update stable - rustup target add ${{ matrix.target.triple }} + rustup default stable - name: Cache Rust uses: Swatinem/rust-cache@v2 @@ -84,11 +83,6 @@ jobs: echo "Received artifacts:" ls -l $RUSSIMP_PACKAGE_DIR - - name: Publish release on crates.io - run: cargo publish --features prebuilt - env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} - - name: Publish release on GitHub uses: softprops/action-gh-release@v1 with: @@ -98,5 +92,10 @@ jobs: files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} + + - name: Publish release on crates.io + run: cargo publish --features prebuilt + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: /tmp/russimp-package # This is fine, because the runner is Linux. + RUSSIMP_PACKAGE_DIR: $RUNNER_TEMP # This is fine, because the runner is Linux. From 85eaf87bf4dd7081e83df3c76337f3741372ccb8 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 17:49:42 +0200 Subject: [PATCH 91/98] Fix release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a3d660..8fe526d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,4 +98,4 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: $RUNNER_TEMP # This is fine, because the runner is Linux. + RUSSIMP_PACKAGE_DIR: ${{ format({0}, runner.temp) }} # This is fine, because the runner is Linux. From 2c539444dbd3cd9c4385efe5f2ddabc9283cf029 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 17:49:42 +0200 Subject: [PATCH 92/98] Fix release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6a3d660..b2e56b8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,4 +98,4 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: $RUNNER_TEMP # This is fine, because the runner is Linux. + RUSSIMP_PACKAGE_DIR: ${{ format('{0}', runner.temp) }} # This is fine, because the runner is Linux. From e87a303decfa3536f96ad20273b3aa5e04c603e9 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 17:53:37 +0200 Subject: [PATCH 93/98] Fix release.yml --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b2e56b8..ffb6e22 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,4 +98,4 @@ jobs: env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} env: - RUSSIMP_PACKAGE_DIR: ${{ format('{0}', runner.temp) }} # This is fine, because the runner is Linux. + RUSSIMP_PACKAGE_DIR: ${{ format('{0}', ${{runner.temp}}) }} # This is fine, because the runner is Linux. From 9a24528b4bd83bc564c5320cbbd75fbe66e00614 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 18:01:13 +0200 Subject: [PATCH 94/98] Fix release.yml --- .github/workflows/release.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ffb6e22..b7e6553 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -82,6 +82,8 @@ jobs: run: | echo "Received artifacts:" ls -l $RUSSIMP_PACKAGE_DIR + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package - name: Publish release on GitHub uses: softprops/action-gh-release@v1 @@ -92,10 +94,11 @@ jobs: files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package - name: Publish release on crates.io run: cargo publish --features prebuilt env: CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} - env: - RUSSIMP_PACKAGE_DIR: ${{ format('{0}', ${{runner.temp}}) }} # This is fine, because the runner is Linux. + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package From afe545312656df872a789280bbe95a0ad682f575 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 18:02:18 +0200 Subject: [PATCH 95/98] Fix release.yml --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7e6553..8a3e1e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,8 +94,8 @@ jobs: files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* token: ${{ secrets.RUSSIMP_FORK_TOEKN }} - env: - RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package + env: + RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package - name: Publish release on crates.io run: cargo publish --features prebuilt From 7799ebd4a6941e383f16128194f3fd6d96651642 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 18:21:51 +0200 Subject: [PATCH 96/98] Fix spelling error. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a3e1e8..0a5b80d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,7 +93,7 @@ jobs: This release was automatically created by GitHub Actions. files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* - token: ${{ secrets.RUSSIMP_FORK_TOEKN }} + token: ${{ secrets.RUSSIMP_FORK_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package From f032b03f5cb9ea2399356d061176c9bc9385cc58 Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 18:54:10 +0200 Subject: [PATCH 97/98] Update crates.io token --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0a5b80d..a8b46cf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -98,7 +98,7 @@ jobs: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package - name: Publish release on crates.io - run: cargo publish --features prebuilt + run: cargo publish --features prebuilt --token $CRATES_IO_TOKEN env: - CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }} + CRATES_IO_TOKEN: ${{ secrets.RUSSIMP_FORK_CRATES_IO_TOKEN }} RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package From b208ce5016d055fe86a3050c8cd0add2130d5b8e Mon Sep 17 00:00:00 2001 From: Alon Regev Date: Sat, 28 Jan 2023 19:28:06 +0200 Subject: [PATCH 98/98] Restore original secret variables' names. --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8b46cf..aedcb3d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -93,12 +93,12 @@ jobs: This release was automatically created by GitHub Actions. files: | ${{ env.RUSSIMP_PACKAGE_DIR }}/* - token: ${{ secrets.RUSSIMP_FORK_TOKEN }} + token: ${{ secrets.ACCESS_TOKEN }} env: RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package - name: Publish release on crates.io run: cargo publish --features prebuilt --token $CRATES_IO_TOKEN env: - CRATES_IO_TOKEN: ${{ secrets.RUSSIMP_FORK_CRATES_IO_TOKEN }} + CRATES_IO_TOKEN: ${{ secrets.CRATESIO_TOKEN }} RUSSIMP_PACKAGE_DIR: ${{ runner.temp }}/russimp-package