aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 03e44543dff4c3b0fcb0978af9f518e0559d405e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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