From 633adefdb054a928a1f14ef8ed532e8292645eca Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Tue, 28 Jan 2025 00:20:37 -0500 Subject: [PATCH] wip --- platform/rust/build.rs | 30 ++++++++++++++++-------------- platform/rust/maplibre-native-src | 1 + 2 files changed, 17 insertions(+), 14 deletions(-) create mode 120000 platform/rust/maplibre-native-src diff --git a/platform/rust/build.rs b/platform/rust/build.rs index 6e7c92c83cb..d97b99e21a7 100644 --- a/platform/rust/build.rs +++ b/platform/rust/build.rs @@ -2,26 +2,28 @@ use std::env; use std::path::PathBuf; fn main() { - let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); - let project_root = PathBuf::from(manifest_dir) - .parent() - .unwrap() // "platform/" - .parent() - .unwrap() // "maplibre-native/" - .to_path_buf(); + let project_root = { + let manifest = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); + let root = manifest.join("maplibre-native-src"); + if root.is_symlink() || root.is_dir() { + // Use the symlinked directory to allow packaging + root + } else { + // Modeled from the kuzu project + // If the path is not directory, this is probably an in-source build on windows where the symlink is unreadable. + manifest.parent().unwrap().parent().unwrap().to_path_buf() + } + }; - let mut cmake_cfg = cmake::Config::new(&project_root); - - cmake_cfg + let build_dir = cmake::Config::new(&project_root) .generator("Ninja") .define("CMAKE_C_COMPILER_LAUNCHER", "ccache") .define("CMAKE_CXX_COMPILER_LAUNCHER", "ccache") .define("MLN_WITH_CORE_ONLY", "ON") - .build_target("mbgl-core"); - - let build_output = cmake_cfg.build(); + .build_target("mbgl-core") + .build(); - let lib_dir = build_output.join("build"); + let lib_dir = build_dir.join("build"); println!("cargo:rustc-link-search=native={}", lib_dir.display()); println!("cargo:rustc-link-lib=static=mbgl-core"); diff --git a/platform/rust/maplibre-native-src b/platform/rust/maplibre-native-src new file mode 120000 index 00000000000..c25bddb6dd4 --- /dev/null +++ b/platform/rust/maplibre-native-src @@ -0,0 +1 @@ +../.. \ No newline at end of file