Debian Codegraph @

Makefile

raw
1 SHELL:=bash
2 NUM_CPUS = $(shell nproc || grep -c '^processor' /proc/cpuinfo)
3 SETUP_PY_FLAGS = --use-distutils
4 VERSION_FILE=$(CURDIR)/DisplayCAL/VERSION
5 VERSION := $(shell cat $(VERSION_FILE))
6 VIRTUALENV_DIR:=.venv
7 SYSTEM_PYTHON?=python3
8 TARGET_ARCH?=`arch`
9
10 all: build FORCE
11
12 .PHONY: help
13 help:
14 @echo ""
15 @echo "Available targets:"
16 @make -qp | grep -o '^[a-z0-9-]\+' | sort
17
18 .PHONY: venv
19 venv:
20 @printf "\n\033[36m--- $@: Creating Local virtualenv '$(VIRTUALENV_DIR)' using '`which python`' ---\033[0m\n"
21 $(SYSTEM_PYTHON) -m venv $(VIRTUALENV_DIR)
22
23 .PHONY: build
24 build:
25 @printf "\n\033[36m--- $@: Building ---\033[0m"
26 @printf "\n\033[36m--- $@: Local install into virtualenv '$(VIRTUALENV_DIR)' ---\033[0m";
27 @source ./$(VIRTUALENV_DIR)/bin/activate; \
28 printf "\n\033[36m--- $@: Using python interpreter '`which python`' ---\033[0m\n"; \
29 pip install uv; \
30 uv pip install -r requirements.txt -r requirements-dev.txt; \
31 uv build;
32
33 install:
34 @printf "\n\033[36m--- $@: Installing displaycal to virtualenv at '$(VIRTUALENV_DIR)' using '`which python`' ---\033[0m\n"
35 source ./$(VIRTUALENV_DIR)/bin/activate; \
36 uv pip install ./dist/displaycal-$(VERSION)-*.whl --force-reinstall;
37
38 launch:
39 @printf "\n\033[36m--- $@: Launching DisplayCAL ---\033[0m\n"
40 @source ./$(VIRTUALENV_DIR)/bin/activate; \
41 displaycal
42
43 clean: FORCE
44 @printf "\n\033[36m--- $@: Clean ---\033[0m\n"
45 -rm -rf .pytest_cache
46 -rm -rf .coverage
47 -rm -rf .ruff_cache
48 -rm -rf .tox
49 -rm -rf $(VIRTUALENV_DIR)
50 -rm -rf dist
51 -rm -rf build
52
53 clean-all: clean
54 @printf "\n\033[36m--- $@: Clean All---\033[0m\n"
55 -rm -f INSTALLED_FILES
56 -rm -f setuptools-*.egg
57 -rm -f use-distutils
58 -rm -f main.py
59 -rm -Rf htmlcov
60 -rm .coverage.*
61 -rm MANIFEST.in
62 -rm -Rf displaycal.egg-info
63 -rm -Rf $(VIRTUALENV_DIR)
64
65 html:
66 ./setup.py readme
67
68 py2app:
69 @printf "\n\033[36m--- $@: Generating macOS APP ---\033[0m\n"
70 @source ./$(VIRTUALENV_DIR)/bin/activate; \
71 ACOSX_DEPLOYMENT_TARGE=11.0 ARCHFLAGS="-arch $(TARGET_ARCH)" python setup.py py2app --arch=$(TARGET_ARCH); \
72 for APP_PATH in dist/*/DisplayCAL-*/*.app; do \
73 echo "Signing $$APP_PATH..."; \
74 find "$$APP_PATH" -type f -name "*.dylib" -exec codesign --remove-signature {} +; \
75 find "$$APP_PATH" -type f -name "*.so" -exec codesign --remove-signature {} +; \
76 find "$$APP_PATH/Contents" -type f \( -name "*.dylib" -o -name "*.so" \) -exec codesign -s - -f -o linker-signed {} +; \
77 codesign --force --deep --options runtime --entitlements misc/entitlements.plist --sign - "$$APP_PATH"; \
78 done; \
79 build_folder=$(ls dist | grep -i py2app.macosx); \
80 xattr -cr "dist/${build_folder}/DisplayCAL-${VERSION}/DisplayCAL.app";
81
82 new-release:
83 @printf "\n\033[36m--- $@: Generating New Release ---\033[0m\n"
84 @if [ ! -d "$(VIRTUALENV_DIR)" ]; then \
85 printf "\n\033[31m--- $@: Virtualenv '$(VIRTUALENV_DIR)' not found, run 'make venv' first ---\033[0m\n"; \
86 exit 1; \
87 fi
88 git add $(VERSION_FILE)
89 git commit -m "Version $(VERSION)"
90 git push
91 git checkout main
92 git pull
93 git merge develop
94 git tag $(VERSION)
95 git push origin main --tags
96 git tag -f nightly
97 git push --force origin nightly
98 @source ./$(VIRTUALENV_DIR)/bin/activate; \
99 printf "\n\033[36m--- $@: Using python interpreter '`which python`' ---\033[0m\n"; \
100 uv pip install -r requirements.txt -r requirements-dev.txt; \
101 uv build; \
102 twine check dist/displaycal-$(VERSION).tar.gz; \
103 twine upload dist/displaycal-$(VERSION).tar.gz;
104
105 .PHONY: tests
106 tests:
107 @printf "\n\033[36m--- $@: Run Tests ---\033[0m"
108 @printf "\n\033[36m--- $@: Using virtualenv at '$(VIRTUALENV_DIR)' ---\033[0m"; \
109 source ./$(VIRTUALENV_DIR)/bin/activate; \
110 printf "\n\033[36m--- $@: Using python interpreter '`which python`' ---\033[0m\n"; \
111 pytest -n auto -W ignore --color=yes --cov-report term --cov-report html --cov=DisplayCAL --durations=50;
112
113 # https://www.gnu.org/software/make/manual/html_node/Force-Targets.html
114 FORCE: