diff --git a/Makefile b/Makefile index 3889002..c608ff6 100644 --- a/Makefile +++ b/Makefile @@ -1,35 +1,46 @@ .PHONY: setup release clean clean-all setup: - cargo install cross - npm install -g yarn + # Start setup + @if ! command -v cross &> /dev/null; then \ + cargo install cross --git https://github.com/cross-rs/cross; \ + fi + yarn + # Setup complete release: setup # Make release directory mkdir -p releases # Build node native binary for unsupported platforms - yarn release-pyaco-node + yarn build + + # Add targets for cross compilation + rustup target add x86_64-apple-darwin # Build binaries for all mainstream platforms - cross build --release --target x86_64-pc-windows-gnu + cargo build --release --target aarch64-apple-darwin cargo build --release --target x86_64-apple-darwin cross build --release --target x86_64-unknown-linux-gnu + cross build --release --target x86_64-pc-windows-gnu # Create folders for the binary - mkdir -p ./builds/pyaco-win64 + mkdir -p ./builds/pyaco-macos-arm64 mkdir -p ./builds/pyaco-macos mkdir -p ./builds/pyaco-linux + mkdir -p ./builds/pyaco-win64 # Copy the binaries into the right folder - cp ./target/x86_64-pc-windows-gnu/release/pyaco.exe ./builds/pyaco-win64/pyaco.exe + cp ./target/aarch64-apple-darwin/release/pyaco ./builds/pyaco-macos-arm64/pyaco cp ./target/x86_64-apple-darwin/release/pyaco ./builds/pyaco-macos/pyaco cp ./target/x86_64-unknown-linux-gnu/release/pyaco ./builds/pyaco-linux/pyaco + cp ./target/x86_64-pc-windows-gnu/release/pyaco.exe ./builds/pyaco-win64/pyaco.exe # Tar binaries (except for the native node one) - tar -C ./builds -czvf ./releases/pyaco-win64.tar.gz pyaco-win64 + tar -C ./builds -czvf ./releases/pyaco-macos-arm64.tar.gz pyaco-macos-arm64 tar -C ./builds -czvf ./releases/pyaco-macos.tar.gz pyaco-macos tar -C ./builds -czvf ./releases/pyaco-linux.tar.gz pyaco-linux + tar -C ./builds -czvf ./releases/pyaco-win64.tar.gz pyaco-win64 # Cleanup builds folder rm -fr ./builds diff --git a/npm/getBinary.js b/npm/getBinary.js index c73b13a..bca65d5 100644 --- a/npm/getBinary.js +++ b/npm/getBinary.js @@ -12,11 +12,12 @@ function getPlatform() { if (type === "Windows_NT" && arch === "x64") return "win64"; if (type === "Linux" && arch === "x64") return "linux"; if (type === "Darwin" && arch === "x64") return "macos"; + if (type === "Darwin" && arch === "arm64") return "macos-arm64"; console.warn( `Unknown platform: ${type} ${arch}. Defaulting to the node native module which might be slower. -` +`, ); return null; diff --git a/pyaco-core/src/notify.rs b/pyaco-core/src/notify.rs index 74e66f8..ef427e2 100644 --- a/pyaco-core/src/notify.rs +++ b/pyaco-core/src/notify.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use notify::ReadDirectoryChangesWatcher; +use notify::RecommendedWatcher; use notify_debouncer_mini::{new_debouncer, DebouncedEvent, Debouncer}; use tokio::{runtime::Handle, sync::mpsc}; @@ -14,7 +14,7 @@ use crate::Result; pub fn async_debounced_watcher( timeout: Duration, ) -> Result<( - Debouncer, + Debouncer, mpsc::Receiver, Vec>>, )> { let (tx, rx) = mpsc::channel(1);