Skip to content
Open
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
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

@vtrofin vtrofin Apr 28, 2023

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be improved to first check whether yarn is installed and if not use npm -i instead of 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
Expand Down
3 changes: 2 additions & 1 deletion npm/getBinary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pyaco-core/src/notify.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand All @@ -14,7 +14,7 @@ use crate::Result;
pub fn async_debounced_watcher(
timeout: Duration,
) -> Result<(
Debouncer<ReadDirectoryChangesWatcher>,
Debouncer<RecommendedWatcher>,
mpsc::Receiver<std::result::Result<Vec<DebouncedEvent>, Vec<notify::Error>>>,
)> {
let (tx, rx) = mpsc::channel(1);
Expand Down