Skip to content

Commit

Permalink
Keep trying to add the possibility to build MEOS from scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
Davichet-e committed Oct 17, 2024
1 parent 9cc41be commit 9bc8ac7
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ 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"
geos = { version = "9.0.0", optional = true }

[features]
default = ["geos"]
geos = ["dep:geos"]

[dev-dependencies]
csv = "1.3.0"
Expand Down
4 changes: 3 additions & 1 deletion sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
1 change: 0 additions & 1 deletion sys/MobilityDB
Submodule MobilityDB deleted from 60048b
15 changes: 6 additions & 9 deletions sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions sys/meos-src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license-file = "LICENSE"
exclude = ["source/tests"]

[build-dependencies]
cmake = "0.1"
11 changes: 11 additions & 0 deletions sys/meos-src/build.rs
Original file line number Diff line number Diff line change
@@ -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);
}
1 change: 1 addition & 0 deletions sys/meos-src/source
Submodule source added at 256556
1 change: 1 addition & 0 deletions sys/meos-src/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 9bc8ac7

Please sign in to comment.