From cd27f41b6ba3394c16f6bdce50813c1e86760f51 Mon Sep 17 00:00:00 2001
From: Tobias Reisinger <tobias@msrg.cc>
Date: Wed, 1 May 2024 13:56:05 +0200
Subject: [PATCH] Add make releases command

---
 .gitignore |  7 ++++---
 Cross.toml |  5 +++++
 Makefile   | 13 ++++++++++++-
 3 files changed, 21 insertions(+), 4 deletions(-)
 create mode 100644 Cross.toml

diff --git a/.gitignore b/.gitignore
index 3c52919..07d4c70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,8 @@
 /core
 /controller
 
-/emgauwa-core.json
-/emgauwa-controller.json
+/emgauwa-*.json
+/emgauwa-*.sqlite
 
-/target
\ No newline at end of file
+/target
+/out
diff --git a/Cross.toml b/Cross.toml
new file mode 100644
index 0000000..2b8c82d
--- /dev/null
+++ b/Cross.toml
@@ -0,0 +1,5 @@
+[build]
+pre-build = [
+    "curl -Lo /usr/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64",
+    "chmod +x /usr/bin/yq"
+]
diff --git a/Makefile b/Makefile
index 221f27e..78bcf51 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,6 @@
 configs:
 	$(MAKE) -C core config
 	ln -s core/emgauwa-core.json emgauwa-core.json
-
 	$(MAKE) -C controller config
 	ln -s controller/emgauwa-controller.json emgauwa-controller.json
 
@@ -14,3 +13,15 @@ clone-ssh:
 	git clone git@git.serguzim.me:emgauwa/common.git
 	git clone git@git.serguzim.me:emgauwa/core.git
 	git clone git@git.serguzim.me:emgauwa/controller.git
+
+emgauwa-core_%:
+	$(TOOL) build --target $* --release
+	mkdir -p out/releases
+	cp target/$*/release/emgauwa-core out/releases/emgauwa-core_$*
+	cp target/$*/release/emgauwa-controller out/releases/emgauwa-controller_$*
+
+releases:
+	$(MAKE) TOOL=cross emgauwa-core_arm-unknown-linux-gnueabihf
+	$(MAKE) TOOL=cargo emgauwa-core_x86_64-unknown-linux-gnu
+	$(MAKE) TOOL=cross emgauwa-core_x86_64-unknown-linux-musl
+