aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-10-17 14:49:21 +0200
committerWojtek Kosior <koszko@koszko.org>2022-10-17 14:50:50 +0200
commited2e14dd6ced4f64b6ac707c5998b38a78e6d7ad (patch)
treead57a2d94456011d0e770ddce6ad224a84a88561 /Makefile
parent6c1f8221d17b1f4d7955d48a77fefeaf6e3030d7 (diff)
downloadhaketilo-hydrilla-ed2e14dd6ced4f64b6ac707c5998b38a78e6d7ad.tar.gz
haketilo-hydrilla-ed2e14dd6ced4f64b6ac707c5998b38a78e6d7ad.zip
[builder][server][proxy] orchestrate Guix-powered development with a Makefile
* We're no longer treating builds from git and builds from release tarball differently. We now generate a source tarball under `./dist/` in both cases. * We're now using `guix time-machine` to ensure we're always running a Guix revision that works.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile73
1 files changed, 73 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..03e4454
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: CC0-1.0
+
+# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
+#
+# Available under the terms of Creative Commons Zero v1.0 Universal.
+
+GUIX := guix
+
+# Almost all commands in this Makefilo are run through `guix time-machine` with
+# Guix revision fixed to the one from the commit below. This ensures that the
+# same working environment is always used.
+GUIX_COMMIT := a86979b41a49a8fcdaa887970ba594dbba701226
+
+GUIX_TM = $(GUIX) time-machine --commit=$(GUIX_COMMIT) --
+
+GUIX_DEVSHELL = $(GUIX_TM) shell -Df guix.scm --
+
+wheel:
+ $(GUIX_DEVSHELL) python3 -m build
+
+dist src/hydrilla/_version.py:
+ $(GUIX_DEVSHELL) python3 -m build -s
+
+# Make a release tarball and repack its files as writeable - this will make it
+# easier for non-technical users to remove the unpacked release once they no
+# longer need it.
+release: clean-tarball-repack dist
+ $(GUIX_TM) pack -L ./hydrilla-guix -RR hydrilla \
+ -S /hydrilla=bin/hydrilla \
+ -S /hydrilla-builder=bin/hydrilla-builder \
+ -S /hydrilla-server=bin/hydrilla-server \
+ -S /haketilo=bin/haketilo | tee make-release.log
+ VER="$$(grep '^Version:' src/hydrilla.egg-info/PKG-INFO | cut -d' ' -f2)" && \
+ RELNAME=haketilo-and-hydrilla-bin-"$$VER"-"$$(arch)" && \
+ PACKFILE="$$(tail -1 make-release.log)" && \
+ mkdir rel-tarball-repack/ && \
+ mkdir rel-tarball-repack/"$$RELNAME" && \
+ tar -C rel-tarball-repack/"$$RELNAME"/ -xf "$$PACKFILE" && \
+ chmod -R +w rel-tarball-repack/"$$RELNAME" && \
+ tar -C rel-tarball-repack/ -cf "$$RELNAME".tar.gz "$$RELNAME"
+
+shell:
+ $(GUIX_DEVSHELL) || true
+
+shell-with-haketilo: dist
+ $(GUIX_TM) shell -f guix.scm -- || true
+
+catalogs:
+ $(GUIX_DEVSHELL) python3 setup.py compile_catalog
+
+refresh-catalogs:
+ $(GUIX_DEVSHELL) sh -c \
+ "python3 setup.py extract_messages && python3 setup.py update_catalog && python3 setup.py compile_catalog"
+
+test: src/hydrilla/_version.py catalogs
+ $(GUIX_DEVSHELL) pytest
+
+run-haketilo: src/hydrilla/_version.py catalogs
+ PYTHONPATH=./src $(GUIX_DEVSHELL) python3 -m hydrilla.mitmproxy_launcher
+
+clean-tarball-repack:
+ test -d rel-tarball-repack/ && chmod -R +w rel-tarball-repack/ || true
+ rm -rf rel-tarball-repack/
+
+clean: clean-tarball-repack
+ rm -rf build/ dist/ src/hydrilla.egg-info src/hydrilla/_version.py \
+ src/hydrilla/locales/messages.pot make-release.log \
+ haketilo-and-hydrilla-bin-*.tar.gz
+ find src/hydrilla/locales/ -name "messages.mo" -delete
+ rm -rf $$(find -name "__pycache__")
+
+.PHONY: release shell shell-with-haketilo dist wheel catalogs refresh-catalogs \
+ test run-haketilo clean-tarball-repack clean