Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MacOS compatibility #81

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
## [Unreleased] - yyyy-mm-dd

### Added
- Support for MacOS

### Changed

Expand Down
16 changes: 10 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
use std::{env, path::PathBuf};

#[cfg(windows)]
#[cfg(target_os = "windows")]
const DEFAULT_LEAPSDK_LIB_PATH: &str = r"C:\Program Files\Ultraleap\LeapSDK\lib\x64";

#[cfg(not(windows))]
#[cfg(target_os = "macos")]
const DEFAULT_LEAPSDK_LIB_PATH: &str =
r"/Applications/Ultraleap Hand Tracking.app/Contents/LeapSDK/lib";

#[cfg(target_os = "linux")]
const DEFAULT_LEAPSDK_LIB_PATH: &str = r"/usr/share/doc/ultraleap-hand-tracking-service";

fn main() {
// Find Leap SDK
println!(r"cargo:rerun-if-env-changed=LEAPSDK_LIB_PATH");
println!(r"cargo::rerun-if-env-changed=LEAPSDK_LIB_PATH");

let leapsdk_path =
env::var("LEAPSDK_LIB_PATH").unwrap_or_else(|_| DEFAULT_LEAPSDK_LIB_PATH.to_string());

let leapsdk_path = PathBuf::from(leapsdk_path);

if !leapsdk_path.is_dir() {
println!("cargo:warning=Could not find LeapSDK at the location {}. Install it from https://developer.leapmotion.com/tracking-software-download or set its location with the environment variable LEAPSDK_LIB_PATH.", leapsdk_path.display());
println!("cargo::warning=Could not find LeapSDK at the location {}. Install it from https://developer.leapmotion.com/tracking-software-download or set its location with the environment variable LEAPSDK_LIB_PATH.", leapsdk_path.display());
} else {
let path_str = leapsdk_path
.to_str()
.unwrap_or_else(|| panic!("{} is not a valid path.", leapsdk_path.display()));

// Link to LeapC.lib
println!(r"cargo:rustc-link-search={}", path_str);
println!(r"cargo:rustc-link-lib=LeapC");
println!(r"cargo::rustc-link-search={}", path_str);
println!(r"cargo::rustc-link-lib=LeapC");
}
}
Loading