-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
143 lines (117 loc) · 4.14 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
## Copyright (C) 2021 David Miguel Susano Pinto <[email protected]>
##
## Copying and distribution of this file, with or without modification,
## are permitted in any medium without royalty provided the copyright
## notice and this notice are preserved. This file is offered as-is,
## without any warranty.
SPHINX_BUILD ?= sphinx-build
SPHINX_APIDOC ?= sphinx-apidoc
YARN ?= yarn
RSYNC ?= rsync
INKSCAPE ?= inkscape
PYTHON3 ?= python3
# Use the submodules by default but make it possible to link to a
# local clone or whatever.
MICROSCOPE_SRC ?= src
# This requires .ssh/config to be set with this host
SSH_HOST = microscope
SSH_TARGET_DIR = ./www
CONF_DIR = .
SOURCE_DIR = content
BUILD_DIR = _build
DOC_DIR = $(SOURCE_DIR)/doc
APIDOC_DIR = $(DOC_DIR)/api
.PHONY: help build build-apidoc clean
help:
@echo 'Makefile for the python-microscope.org website'
@echo ''
@echo 'Usage:'
@echo ' make sync-doc update the doc source with latest'
@echo ' make api-doc (re)generate the apidocs'
@echo ' make html (re)generate the web site'
@echo ' make publish upload to the interweb'
@echo ' make server test web server at http://0.0.0.0:8000/'
@echo ''
@echo 'Variables:'
@echo ' MICROSCOPE_SRC path for python-microscope repo'
BOOTSTRAP_ICONS_FILES = \
node_modules/bootstrap-icons/icons/bounding-box.svg \
node_modules/bootstrap-icons/icons/box-seam.svg \
node_modules/bootstrap-icons/icons/card-list.svg \
node_modules/bootstrap-icons/icons/code-slash.svg \
node_modules/bootstrap-icons/icons/file-text.svg \
node_modules/bootstrap-icons/icons/gear.svg \
node_modules/bootstrap-icons/icons/people.svg \
node_modules/bootstrap-icons/icons/person-plus.svg
BOOTSTRAP_FILES = \
node_modules/bootstrap/dist/css/bootstrap.min.css \
node_modules/bootstrap/dist/js/bootstrap.bundle.min.js
JQUERY_FILES = \
node_modules/jquery/dist/jquery.slim.min.js
THIRD_PARTY_FILES = \
$(BOOTSTRAP_ICONS_FILES) \
$(BOOTSTRAP_FILES) \
$(JQUERY_FILES)
# HACK: we need multiple files from the same yarn package so a single
# recipe would install multiple files. However, Make does not like
# that (see
## https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html
## ). So we just lie and instead list only one file per package.
THIRD_PARTY_FILES_ONE = \
node_modules/bootstrap-icons/package.json \
node_modules/bootstrap/package.json \
node_modules/jquery/package.json
node_modules/bootstrap-icons/package.json:
$(YARN) add [email protected]
node_modules/bootstrap/package.json:
$(YARN) add [email protected]
node_modules/jquery/package.json:
$(YARN) add [email protected]
_static/microscope-logo-96-dpi.png: _static/microscope-logo.svg
inkscape --file $< \
--export-dpi 96 \
--export-png $@
html: sync-doc api-doc $(THIRD_PARTY_FILES_ONE)
${SPHINX_BUILD} -c ${CONF_DIR} -b html ${SOURCE_DIR} ${BUILD_DIR}
# This command is duplicated from what's in microscope/setup.py
api-doc:
${SPHINX_APIDOC} \
--force --separate --module-first \
--tocfile index \
--output-dir $(APIDOC_DIR) \
${MICROSCOPE_SRC}/microscope \
${MICROSCOPE_SRC}/microscope/_wrappers/ \
${MICROSCOPE_SRC}/microscope/cameras/_SDK3.py \
${MICROSCOPE_SRC}/microscope/cameras/_SDK3Cam.py \
${MICROSCOPE_SRC}/microscope/devices.py \
${MICROSCOPE_SRC}/microscope/deviceserver.py \
${MICROSCOPE_SRC}/microscope/lasers/ \
${MICROSCOPE_SRC}/microscope/testsuite/ \
${MICROSCOPE_SRC}/microscope/win32.py
# We copy doc/ where the documentation is but also need to copy the
# NEWS file which is `include::` from doc/news.rst
sync-doc:
$(RSYNC) \
--recursive \
"$(MICROSCOPE_SRC)/doc/" "$(DOC_DIR)"
cp "$(MICROSCOPE_SRC)/NEWS.rst" "$(DOC_DIR)/../NEWS.rst"
clean:
$(RM) "$(DOC_DIR)/../NEWS.rst"
$(RM) -r \
"$(BUILD_DIR)" \
"$(APIDOC_DIR)" \
"$(DOC_DIR)" \
"node_modules"
server:
$(PYTHON3) -m http.server --directory ${BUILD_DIR}
upload:
$(RSYNC) -e "ssh" \
--partial --progress \
--recursive \
--verbose \
--compress \
--checksum \
--include tags \
--cvs-exclude \
--delete \
"$(BUILD_DIR)"/ "$(SSH_HOST):$(SSH_TARGET_DIR)"