-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
84 lines (66 loc) · 3.81 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
default: build
.PHONY: build default
# Server
# ------
py_files := $(shell find src/server -name '*.py' -not -path "src/server/.tox/*" -not -path "src/server/build/**")
server_version_file := src/server/quarchive/VERSION
server_version := $(shell cat $(server_version_file))
artefact := quarchive-$(server_version)-py3-none-any.whl
dist/$(artefact): $(py_files) $(server_version_file) | dist
cd src/server; tox
mv src/server/dist/$(artefact) dist/
# Extension
# ---------
ext_path := src/extension
node_modules := $(ext_path)/node_modules
web_ext := $(node_modules)/web-ext/bin/web-ext
eslint := $(node_modules)/eslint/bin/eslint.js
tsc := $(node_modules)/typescript/bin/tsc
jest := $(node_modules)/jest/bin/jest.js
generate_manifest := $(ext_path)/generate-manifest
# Source files
jest_sentinel := $(ext_path)/.jest-sentinel
ts_files := $(wildcard $(ext_path)/src/*.ts)
icons := $(ext_path)/icons/48x48.png $(ext_path)/icons/96x96.png
html_files := $(wildcard $(ext_path)/src/*.html)
ext_version_file := $(ext_path)/VERSION
ext_version := $(shell cat $(ext_version_file))
webextension_polyfill := $(node_modules)/webextension-polyfill/dist/browser-polyfill.js
# Build files (firefox)
ext_firefox_build_dir := $(ext_path)/firefox-build
ext_firefox_js_files := $(addprefix $(ext_firefox_build_dir)/, $(notdir $(ts_files:ts=js)))
ext_firefox_manifest := $(ext_firefox_build_dir)/manifest.json
dist/quarchive-$(ext_version)-firefox.zip: $(ext_path)/firefox-webextconfig.js $(web_ext) $(ext_firefox_manifest) $(jest_sentinel) $(ext_firefox_js_files) $(html_files) $(icons) $(webextension_polyfill) | dist
cp $(icons) $(webextension_polyfill) $(webextension_polyfill).map $(ts_files) $(html_files) $(ext_firefox_build_dir)
cd $(ext_path)/; $(realpath $(web_ext)) build -c $(realpath $<)
mv $(ext_firefox_build_dir)/quarchive-$(ext_version).zip $@
$(ext_firefox_js_files): $(ext_path)/tsconfig-firefox.json $(ts_files) $(tsc) | $(ext_firefox_build_dir)
$(tsc) --build $(ext_path)/tsconfig-firefox.json
$(ext_firefox_manifest): $(generate_manifest) $(ext_version_file) | $(ext_firefox_build_dir)
$(generate_manifest) firefox $(ext_version) > $@
# Build files (chrome)
ext_chrome_build_dir := $(ext_path)/chrome-build
ext_chrome_js_files := $(addprefix $(ext_chrome_build_dir)/, $(notdir $(ts_files:ts=js)))
ext_chrome_manifest := $(ext_chrome_build_dir)/manifest.json
dist/quarchive-$(ext_version)-chrome.zip: $(ext_path)/chrome-webextconfig.js $(web_ext) $(ext_chrome_manifest) $(jest_sentinel) $(ext_chrome_js_files) $(html_files) $(icons) $(webextension_polyfill) | dist
cp $(icons) $(webextension_polyfill) $(webextension_polyfill).map $(ts_files) $(html_files) $(ext_chrome_build_dir)
cd $(ext_path)/; $(realpath $(web_ext)) build -c $(realpath $<)
mv $(ext_chrome_build_dir)/quarchive-$(ext_version).zip $@
$(ext_chrome_js_files): $(ext_path)/tsconfig-chrome.json $(ts_files) $(tsc) | $(ext_chrome_build_dir)
$(tsc) --build $(ext_path)/tsconfig-chrome.json
$(ext_chrome_manifest): $(generate_manifest) $(ext_version_file) | $(ext_chrome_build_dir)
$(generate_manifest) chrome $(ext_version) > $@
$(jest_sentinel): $(ext_path)/jest.config.js $(ts_files) $(jest)
# FIXME: disabled in the build as there is some kind of racecondition with jest
# $(jest) -c $(ext_path)/jest.config.js $(ts_files)
touch $@
# $(ext_path)/.eslint-sentinel: $(eslint) $(js_files)
# $(eslint) -f unix $(ext_path)/quarchive-background.js $(ext_path)/quarchive-options.js
# touch $@
$(web_ext) $(tsc) $(eslint) $(jest) $(webextension_polyfill): $(ext_path)/package.json
cd $(ext_path); npm install --save-dev
# FIXME: for some reason mtimes don't get updated
touch $(tsc) $(eslint) $(jest) $(webextension_polyfill)
dist $(ext_firefox_build_dir) $(ext_chrome_build_dir):
mkdir -p $@
build: dist/quarchive-$(ext_version)-chrome.zip dist/quarchive-$(ext_version)-firefox.zip dist/$(artefact)