diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..dc8a8243 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,46 @@ +name: macOS CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + macos-build: + name: macOS Build Examples + runs-on: macos-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + + - name: Setup Rust cache + uses: Swatinem/rust-cache@v2 + + - name: Fetch dependencies and update submodules + run: | + cargo fetch + # Ensure git submodules in the cargo git checkouts are initialized + for dir in ~/.cargo/git/checkouts/roslibrust-*/*/; do + if [ -d "$dir" ]; then + echo "Updating submodules in $dir" + (cd "$dir" && git submodule update --init --recursive) || true + fi + done + + - name: Debug - Check cargo git checkouts + run: | + echo "HOME: $HOME" + echo "CARGO_HOME: ${CARGO_HOME:-not set}" + echo "Checking for roslibrust checkouts:" + ls -la ~/.cargo/git/checkouts/ 2>/dev/null || echo "No checkouts directory" + find ~/.cargo/git/checkouts -name "roslibrust-*" -type d 2>/dev/null || echo "No roslibrust directories found" + echo "Checking for assets directory:" + find ~/.cargo/git/checkouts -name "assets" -type d 2>/dev/null || echo "No assets directories found" + + - name: Build examples without ROS dependencies + run: cargo build --examples diff --git a/ros-z-msgs/build.rs b/ros-z-msgs/build.rs index 95761a66..f9fe405c 100644 --- a/ros-z-msgs/build.rs +++ b/ros-z-msgs/build.rs @@ -220,29 +220,33 @@ fn discover_bundled_packages(bundled_packages: &[&str]) -> Result> fn find_roslibrust_assets() -> PathBuf { // Search in cargo's git checkout directory // The path will be something like: ~/.cargo/git/checkouts/roslibrust-{hash}/{commit}/assets - if let Ok(home) = env::var("CARGO_HOME").or_else(|_| env::var("HOME")) { - let cargo_git = PathBuf::from(home).join(".cargo/git/checkouts"); - - if let Ok(entries) = std::fs::read_dir(&cargo_git) { - for entry in entries.flatten() { - let path = entry.path(); - if path.is_dir() - && path - .file_name() - .and_then(|n| n.to_str()) - .is_some_and(|n| n.starts_with("roslibrust-")) - { - // Look for the assets directory in any commit subdirectory - if let Ok(commits) = std::fs::read_dir(&path) { - for commit_entry in commits.flatten() { - let assets_path = commit_entry.path().join("assets"); - if assets_path.exists() { - println!( - "cargo:warning=Using roslibrust git assets at {}", - assets_path.display() - ); - return assets_path; - } + let cargo_git = if let Ok(cargo_home) = env::var("CARGO_HOME") { + PathBuf::from(cargo_home).join("git/checkouts") + } else if let Ok(home) = env::var("HOME") { + PathBuf::from(home).join(".cargo/git/checkouts") + } else { + panic!("Neither CARGO_HOME nor HOME environment variable is set"); + }; + + if let Ok(entries) = std::fs::read_dir(&cargo_git) { + for entry in entries.flatten() { + let path = entry.path(); + if path.is_dir() + && path + .file_name() + .and_then(|n| n.to_str()) + .is_some_and(|n| n.starts_with("roslibrust-")) + { + // Look for the assets directory in any commit subdirectory + if let Ok(commits) = std::fs::read_dir(&path) { + for commit_entry in commits.flatten() { + let assets_path = commit_entry.path().join("assets"); + if assets_path.exists() { + println!( + "cargo:warning=Using roslibrust git assets at {}", + assets_path.display() + ); + return assets_path; } } }