Skip to content

Instantly share code, notes, and snippets.

@playniuniu
Created October 10, 2020 12:28
Show Gist options
  • Select an option

  • Save playniuniu/07899fc851a73f49ae79abd6c8567f05 to your computer and use it in GitHub Desktop.

Select an option

Save playniuniu/07899fc851a73f49ae79abd6c8567f05 to your computer and use it in GitHub Desktop.
Makefile for cross compile rust
BINARY=hello_cargo
run:
# run
@cargo run
linux:
# build for linux
@rm -f ${BINARY}
@cargo build --release --target=x86_64-unknown-linux-musl
@mv target/x86_64-unknown-linux-musl/release/${BINARY} .
windows:
# build for windows
@rm -f ${BINARY}.exe
@cargo build --release --target=x86_64-pc-windows-gnu
@mv target/x86_64-pc-windows-gnu/release/${BINARY}.exe .
@upx ${BINARY}.exe
arm:
# build for arm
@rm -f ${BINARY}
@cargo build --release --target=armv7-unknown-linux-musleabihf
@mv target/armv7-unknown-linux-musleabihf/release/${BINARY} .
@upx ${BINARY}
clean:
# clean
@rm -f ${BINARY}
@rm -f ${BINARY}.exe
PHONY: run linux windows arm clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment