-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
187 lines (170 loc) · 7.08 KB
/
Makefile
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
################################################################################
# #
# Convenience Makefile for old fogies who can't imagine its lack. #
# #
################################################################################
.PHONY: docs doc
VERSION := $(shell grep 'VERSION =' enlighten/common.py | awk '{print $$3}' | tr -d '"')
RPI_ID := $(shell test -f /etc/os-release && grep '^ID=' /etc/os-release | awk -F= '{print $$2}' | tr -d '"')
RPI_CODENAME := $(shell test -f /etc/os-release && grep '^VERSION_CODENAME=' /etc/os-release | awk -F= '{print $$2}' | tr -d '"')
PLATYPUS_BIN := ../Platypus/products/platypus_clt
help:
@echo "To build and run Enlighten, see README.md"
@echo
@echo "Supported targets:"
@echo
@echo " run - runs Enlighten from source"
@echo
@echo " clean - purge build artifacts (must re-run 'make deps')"
@echo " designer - runs Qt Designer with main GUI"
@echo " deps - rebuilds Qt artifacts after editing with Designer"
@echo
@echo " cloc - count SLOC in Python, JSON and .ini files"
@echo " doc - render documentation"
@echo " linux-installer - build a Linux binary using pyinstaller"
@echo " rpi-installer - build a Raspberry Pi binary using pyinstaller"
@echo " mac-installer - build a Mac application using pyinstaller and platypus"
@echo
@echo "VERSION = $(VERSION)"
cloc:
@cloc --include-lang=Python,JSON,INI --exclude-dir=uic_qrc .
# You may need to do this if you're sharing a sandbox between Linux, Windows, Mac
# etc to force .pyc rebuilds
clean:
@rm -rfv scripts/built-dist/Enlighten* \
scripts/windows_installer/ \
scripts/work-path/Enlighten \
enlighten/assets/uic_qrc/*.py \
build \
build-{linux,mac}* \
ENLIGHTEN-*.app \
ENLIGHTEN-linux-*.tgz \
ENLIGHTEN-MacOS-*.zip \
ENLIGHTEN-*.exe \
mac.bundled \
docs/doxygen \
enlighten.{err,out} \
build.{err,out} \
doxygen.{err,out}
@find . -name __pycache__ -exec rm -rfv {} \;
@find . -name \*.pyc -exec rm -fv {} \;
deps:
@dos2unix scripts/rebuild_resources.sh
@scripts/rebuild_resources.sh
designer:
@./designer.sh
doc: docs
docs:
@# Render Doxygen
@#
@rm -rf docs/doxygen/html
@test -L wasatch || ln -s ../Wasatch.PY/wasatch
doxygen 1>doxygen.out 2>doxygen.err
@test -L wasatch && rm wasatch
@#
@# Convert Changelog to HTML
@#
@echo "<!-- This file is generated by enlighten/Makefile 'make docs' and uploaded by enlighten/scripts/deploy. Do not hand-edit. -->" > docs/ENLIGHTEN_CHANGELOG.html
pandoc --metadata title:ENLIGHTEN-Changelog --toc --embed-resources --standalone --from gfm --to html CHANGELOG.md >> docs/ENLIGHTEN_CHANGELOG.html
@#
@# done
@#
@echo
@echo "View via:"
@echo
@echo " docs/doxygen/html/index.html"
# We don't seem to have to do this "EnlightenGUI" stuff on Windows, because the
# executable is named enlighten.exe and doesn't conflict with the enlighten/ directory;
# we don't have to do it on Mac, because pyinstaller doesn't support bundles and
# we have to roll all that in via platypus externally.
linux-installer-base:
rm -rf build-linux*
mkdir -p build-linux
pyinstaller \
--distpath="build-linux" \
--workpath="build-linux-work" \
--noconfirm \
--clean \
--windowed \
--paths="../Wasatch.PY" \
--paths="plugins" \
--hidden-import="scipy._lib.messagestream" \
--hidden-import="scipy.special.cython_special" \
--icon "../enlighten/assets/uic_qrc/images/EnlightenIcon.ico" \
--specpath="scripts" \
--name EnlightenGUI \
scripts/Enlighten.py 2>&1 \
| sed 's/^/pyinstaller: /'
mkdir -p build-linux/EnlightenGUI/enlighten/assets
cp -rv enlighten/assets/stylesheets build-linux/EnlightenGUI/enlighten/assets
cp -rv enlighten/assets/example_data build-linux/EnlightenGUI/enlighten/assets
cp -rv ../Wasatch.PY/udev build-linux/EnlightenGUI/
rm -fv build-linux/EnlightenGUI/_internal/libusb-1.0.so.0
mv -v build-linux/EnlightenGUI build-linux/ENLIGHTEN-$(VERSION)
( cd build-linux && tar zcvf ../ENLIGHTEN-linux-$(VERSION).tgz ENLIGHTEN-$(VERSION) | sed 's/^/compressing: /' )
linux-installer: linux-installer-base
@echo
@echo "ENLIGHTEN-$(VERSION) for Linux packaged in ENLIGHTEN-linux-$(VERSION).tgz"
rpi-installer: linux-installer-base
@echo
@FILENAME="ENLIGHTEN-${RPI_ID}-${RPI_CODENAME}-$(VERSION).tgz" && \
mv ENLIGHTEN-linux-$(VERSION).tgz $$FILENAME && \
echo "ENLIGHTEN-$(VERSION) for Raspberry Pi packaged in $$FILENAME"
mac-installer:
@rm -rf build-mac build-mac-work
@mkdir -p build-mac
@echo "Running PyInstaller..." # note capitalization
@python3.10 -m PyInstaller \
--distpath="build-mac" \
--workpath="build-mac-work" \
--noconfirm \
--clean \
--windowed \
--paths="../Wasatch.PY" \
--paths="pluginExamples" \
--hidden-import="scipy._lib.messagestream" \
--hidden-import="scipy.special.cython_special" \
--icon "../enlighten/assets/uic_qrc/images/EnlightenIcon.ico" \
--specpath="scripts" \
--name EnlightenGUI \
scripts/Enlighten.py 2>&1 \
| sed 's/^/pyinstaller: /'
@mkdir -p build-mac/EnlightenGUI/enlighten/assets
@cp -rv enlighten/assets/stylesheets build-mac/EnlightenGUI/enlighten/assets
@cp -rv enlighten/assets/example_data build-mac/EnlightenGUI/enlighten/assets
@echo "Now run:"
@echo " make mac-platypus"
# install with "brew install platypus"
mac-platypus:
@echo "Running Platypus..."
@rm -rf ENLIGHTEN-$(VERSION).app
@DIR=build-mac/EnlightenGUI ; ls $$DIR | grep -v EnlightenGUI | sed "s!^!-f $$DIR/!" > mac.bundled
@$(PLATYPUS_BIN) \
--name "ENLIGHTEN™ $(VERSION)" \
--interface-type 'None' \
--interpreter /usr/bin/env \
--app-icon enlighten/assets/uic_qrc/images/EnlightenIcon.icns \
--app-version $(VERSION) \
--author "Wasatch Photonics" \
--bundle-identifier "com.wasatchphotonics.Enlighten" \
--quit-after-execution \
--overwrite \
--optimize-nib \
`cat mac.bundled` \
build-mac/EnlightenGUI/EnlightenGUI \
ENLIGHTEN-$(VERSION) 2>&1 \
| sed 's/^/platypus: /'
@zip -r ENLIGHTEN-MacOS-$(VERSION).zip ENLIGHTEN-$(VERSION).app | sed 's/^/compressing: /'
@rm -rf ENLIGHTEN-$(VERSION).app
@echo
@echo "ENLIGHTEN-$(VERSION).app for MacOS packaged in ENLIGHTEN-MacOS-$(VERSION).zip"
# Run ENLIGHTEN with debug logging
run:
@python scripts/Enlighten.py --log-level debug 1>enlighten.out 2>enlighten.err
pylint:
@pylint enlighten plugins
flake8:
@find enlighten plugins -name \*.py | sort | grep -v uic_qrc | xargs flake8 | tee flake8.out
@echo && echo Counts:
@awk -F": " '{print $$2}' < flake8.out | sort | uniq -c | sort -n
@rm -f flake8.out