From da12e8519ecfce80b8e60b8be993b3e8541be4e8 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 21 Dec 2024 19:01:42 +0100 Subject: [PATCH] add windows build process --- .gitignore | 1 + Makefile | 25 ++++++++++++++++++------- build.rs | 6 ++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 build.rs diff --git a/.gitignore b/.gitignore index 90254f8..a768d82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target /user *.zip +version.txt diff --git a/Makefile b/Makefile index 39d733e..a864adf 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,22 @@ -release_name = marble_machinations -bin_name = marble2 +VERSION = `cat version.txt` +RELEASE_DIRNAME = marble_machinations_${VERSION} +BIN_NAME = marble-machinations + +TARGET_W64 = x86_64-pc-windows-gnu linux: cargo build --release - mkdir ${release_name} - cp target/release/${bin_name} ${release_name}/ - cp -r assets levels ${release_name}/ - zip -r ${release_name}_linux.zip ${release_name}/ - rm -rf ${release_name} + mkdir ${RELEASE_DIRNAME} + cp target/release/${BIN_NAME} ${RELEASE_DIRNAME}/ + cp -r assets levels ${RELEASE_DIRNAME}/ + zip -r ${RELEASE_DIRNAME}_linux.zip ${RELEASE_DIRNAME}/ + rm -rf ${RELEASE_DIRNAME} + +windows: + cargo build --release --target=${TARGET_W64} + mkdir ${RELEASE_DIRNAME}_win + cp target/${TARGET_W64}/release/${BIN_NAME}.exe ${RELEASE_DIRNAME}_win/ + cp -r assets levels ${RELEASE_DIRNAME}_win/ + zip -r ${RELEASE_DIRNAME}_win.zip ${RELEASE_DIRNAME}_win/ + rm -rf ${RELEASE_DIRNAME}_win diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..dd69605 --- /dev/null +++ b/build.rs @@ -0,0 +1,6 @@ +use std::{fs::File, io::Write}; + +fn main(){ + let version = concat!("v", env!("CARGO_PKG_VERSION")); + File::create("version.txt").unwrap().write_all(version.as_bytes()).unwrap(); +} \ No newline at end of file