-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (58 loc) · 1.89 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
#!/usr/bin/make
# Note: we have to unset some vars because web-ext is too stupid to not
# discard unneeded vars regarding commands.
ADDON := ./addon
SRC := ./src
FIREFOX_PROFILE := ./profile.firefox
CHROME_PROFILE := ./profile.chrome
START_URL := about:blank
NPM_CMD := $(shell command -v yarn || command -v npm)
NPM_BIN := $(shell $(NPM_CMD) bin)
CHROME_CMD := $(shell command -v chrome || command -v chromium)
ESLINT := $(NPM_BIN)/eslint
WEB_EXT := $(NPM_BIN)/web-ext
WEBPACK := $(NPM_BIN)/webpack
.PHONY: default
default: init source-lint source-build
init:
$(NPM_CMD) install
source-lint:
$(ESLINT) src
source-build:
$(WEBPACK) --progress
source-clean:
rm -f ./$(ADDON)/manifest.json
rm -rf ./$(ADDON)/resources/dist
source-watch:
$(WEBPACK) --watch --progress
webext-run-firefox:
test -d $(FIREFOX_PROFILE) || mkdir $(FIREFOX_PROFILE)
unset WEB_EXT_API_KEY WEB_EXT_API_SECRET ;\
$(WEB_EXT) run -s $(ADDON) -p $(FIREFOX_PROFILE) \
--keep-profile-changes \
--browser-console \
--url $(START_URL)
webext-run-chrome:
test -d $(CHROME_PROFILE) || mkdir $(CHROME_PROFILE)
$(CHROME_CMD) \
--user-data-dir=$(CHROME_PROFILE) \
--load-extension=$(ADDON) \
$(START_URL)
moz-run: source-build
${MAKE} -j2 source-watch webext-run-firefox
moz-lint:
unset WEB_EXT_FIREFOX_BINARY WEB_EXT_API_KEY WEB_EXT_API_SECRET ;\
$(WEB_EXT) lint -s $(ADDON) --self-hosted
moz-pack: source-lint source-build moz-lint
unset WEB_EXT_FIREFOX_BINARY ;\
$(WEB_EXT) sign -s $(ADDON)
chrome-run: source-build
${MAKE} -j2 source-watch webext-run-chrome
chrome-pack: source-lint source-build
test -d web-ext-artifacts || mkdir web-ext-artifacts
set -e ;\
dest=$$(cat addon/manifest.json | jq -r '.applications.gecko.id + "-" + .version') ;\
(cd $(ADDON) && zip -qr -9 -X ../web-ext-artifacts/$$dest.zip .) ;\
echo "web-ext-artifacts/$$dest.zip writen"
lint: source-lint source-build moz-lint
clean: source-clean