diff --git a/.gitmodules b/.gitmodules index e45fae6..ef9b39b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "sys/MobilityDB"] - path = sys/MobilityDB +[submodule "sys/meos-src/source"] + path = sys/meos-src/source url = https://github.com/MobilityDB/MobilityDB.git diff --git a/Cargo.toml b/Cargo.toml index d09a79e..4a50dad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2021" [dependencies] paste = "1.0.15" -meos-sys = { path = "sys", version = "0.1.5" } +meos-sys = { path = "sys", version = "0.1.5", features=["bundled_proj"] } chrono = "0.4.38" libc = "0.2.155" bitmask-enum = "2.2.4" @@ -21,6 +21,7 @@ geos = { version = "9.0.0", optional = true } [features] default = ["geos"] +geos = ["dep:geos"] [dev-dependencies] csv = "1.3.0" diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 2a17719..f7fe5d6 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -14,6 +14,7 @@ edition = "2021" links = "meos" [dependencies] +meos-src = { path = "./meos-src", version = "0.1.3", optional = true } [build-dependencies] pkg-config = "0.3.30" @@ -24,5 +25,6 @@ bindgen = { version = "0.70.1", optional = true} default = ["v1_2"] v1_1 = [] v1_2 = [] -buildtime_bindgen = ["dep:bindgen"] + +buildtime_bindgen = ["dep:bindgen", "meos-src"] bundled_proj = ["buildtime_bindgen"] \ No newline at end of file diff --git a/sys/MobilityDB b/sys/MobilityDB deleted file mode 160000 index 60048b5..0000000 --- a/sys/MobilityDB +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 60048b5b4b7ce2f7560c024d1af024db73b3bd5b diff --git a/sys/build.rs b/sys/build.rs index 5450bf6..530d5af 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -18,17 +18,14 @@ fn main() { // If `bundled_proj` is on, use the git submodule to build MEOS from scratch let include_path = if cfg!(feature = "bundled_proj") { - let dst = cmake::Config::new("MobilityDB").define("MEOS", "1").build(); + let meos_path = std::env::var("DEP_MEOSSRC_SEARCH").unwrap(); - println!( - "cargo:rustc-link-search=dylib={}", - dst.join("lib").display() - ); + println!("cargo:rustc-link-search=dylib={}", meos_path); // Tell cargo to tell rustc to link the system meos shared library. println!("cargo:rustc-link-lib=meos"); - dst.join("lib") + meos_path // Else use pkg-config, using a default as a fallback } else { let pk_include_path = detect_meos_via_pkg_config(); @@ -48,14 +45,14 @@ fn main() { // Tell cargo to tell rustc to link the system meos shared library. println!("cargo:rustc-link-lib=dylib=meos"); - PathBuf::from(default_include_path) + default_include_path } else { - pk_include_path.unwrap() + pk_include_path.unwrap().display().to_string() } }; #[cfg(feature = "buildtime_bindgen")] - generate_bindings(include_path).unwrap(); + generate_bindings(include_path.into()).unwrap(); #[cfg(not(feature = "buildtime_bindgen"))] let _ = include_path; diff --git a/sys/meos-src/Cargo.toml b/sys/meos-src/Cargo.toml new file mode 100644 index 0000000..4489192 --- /dev/null +++ b/sys/meos-src/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "meos-src" +version = "0.1.3" +edition = "2021" +links = "meossrc" +build = "build.rs" +description = "static library build for meos-sys" +repository = "https://github.com/MobilityDB/RustMEOS" +authors = ["David GarcĂ­a Morillo "] +license-file = "LICENSE" +exclude = ["source/tests"] + +[build-dependencies] +cmake = "0.1" \ No newline at end of file diff --git a/sys/meos-src/build.rs b/sys/meos-src/build.rs new file mode 100644 index 0000000..85c07c3 --- /dev/null +++ b/sys/meos-src/build.rs @@ -0,0 +1,11 @@ +fn main() { + println!("cargo:rerun-if-changed=build.rs"); + + let libmeos = cmake::Config::new("source").define("MEOS", "1").build(); + + println!("cargo:lib=meos"); + + let search_path = format!("{}/lib", libmeos.display()); + assert!(std::path::Path::new(&search_path).exists()); + println!("cargo:search={}", search_path); +} diff --git a/sys/meos-src/source b/sys/meos-src/source new file mode 160000 index 0000000..256556c --- /dev/null +++ b/sys/meos-src/source @@ -0,0 +1 @@ +Subproject commit 256556c46812db8e52590735db90f2e5b45dc724 diff --git a/sys/meos-src/src/lib.rs b/sys/meos-src/src/lib.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/sys/meos-src/src/lib.rs @@ -0,0 +1 @@ +