Skip to content

Instantly share code, notes, and snippets.

@mbround18
Last active October 9, 2023 05:09
Show Gist options
  • Save mbround18/da7e141f8f75acb40281ac5860a04faf to your computer and use it in GitHub Desktop.
Save mbround18/da7e141f8f75acb40281ac5860a04faf to your computer and use it in GitHub Desktop.
Fast build on windows for WSL2
# Following this tutorial: https://markentier.tech/posts/2022/01/speedy-rust-builds-under-wsl2/
# This makes developing on windows significantly easier for rust projects!!
SOURCE_DIR = $(PWD)
# `notdir` returns the part after the last `/`
# so if the source was "/some/nested/project", only "project" remains
BUILD_DIR = ~/tmp/$(notdir $(SOURCE_DIR))
wsl.build: wsl.sync
cd $(BUILD_DIR) && cargo build
rsync -av $(BUILD_DIR)/target/debug/ $(SOURCE_DIR)/target/debug/ \
--exclude .git \
--exclude target \
--exclude .fingerprint \
--exclude build \
--exclude incremental \
--exclude deps
wsl.run: wsl.sync
cd $(BUILD_DIR) && cargo run
wsl.test: wsl.sync
cd $(BUILD_DIR) && cargo test
wsl.sync:
mkdir -p $(BUILD_DIR)
rsync -av $(SOURCE_DIR)/ $(BUILD_DIR)/ --exclude .git --exclude target
wsl.clean:
rm -rf $(BUILD_DIR)/target
wsl.clean-all:
rm -rf $(BUILD_DIR)
wsl.clippy: wsl.sync
cd $(BUILD_DIR) && cargo clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment