-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
68 lines (57 loc) · 2.51 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
.PHONY:
SRC_DIR?="src"
BUILD_DIR?="build"
DIST_DIR?="dist"
CHROME_BINARY?="/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
PWD=${shell pwd}
VERSION?=${shell cat src/manifest--base.json | jq '.version'}
build-firefox:
@printf "\e[1m\e[94m♺ Building version ${VERSION} for Firefox\e[0m"
@mkdir -p ${BUILD_DIR}/firefox
@yes | rm -rf "${BUILD_DIR}/firefox/*"
@cp -r ${SRC_DIR}/* ${BUILD_DIR}/firefox
@# Firefox needs an empty background.service_worker
@cat ${BUILD_DIR}/firefox/manifest--base.json | jq '.background.service_worker = ""' > ${BUILD_DIR}/firefox/manifest.json
@rm ${BUILD_DIR}/firefox/manifest--base.json
@printf "\n\e[1m\e[32m✔ Done\e[0m\n\n"
build-chromium:
@printf "\e[1m\e[94m♺ Building version ${VERSION} for Chromium\e[0m"
@mkdir -p ${BUILD_DIR}/chromium
@yes | rm -rf "${BUILD_DIR}/chromium/*"
@cp -r ${SRC_DIR}/* ${BUILD_DIR}/chromium
@# Chrome does not need .background.scripts
@cat ${BUILD_DIR}/chromium/manifest--base.json | jq 'del(.background.scripts)' | jq 'del(.browser_specific_settings)' > ${BUILD_DIR}/chromium/manifest.json
@rm ${BUILD_DIR}/chromium/manifest--base.json
@printf "\n\e[1m\e[32m✔ Done\e[0m\n\n"
build-all:
@$(MAKE) build-firefox
@$(MAKE) build-chromium
watch:
@watchman --version > /dev/null 2>&1 || (printf "\e[1m\e[31mERROR: watchman is required. Please install it first.\e[0m\n"; exit 1)
@printf "\e[1m\e[94m♺ Starting watchman… \e[0m\n"
@watchman-make -p 'src/*' 'src/**/*' 'Makefile*' -t build-all
package-firefox:
@printf "\e[1m\e[94m♺ Packaging version ${VERSION} for Firefox\e[0m\n"
@mkdir -p ${DIST_DIR}
@cd ${BUILD_DIR}/firefox/ && zip -r -FS ${PWD}/${DIST_DIR}/${VERSION}--firefox.zip ./* -x "**/.*"
@printf "\e[1m\e[32m✔ Done\e[0m\n\n"
package-chromium:
@printf "\e[1m\e[94m♺ Packaging version ${VERSION} for Chromium\e[0m\n"
@mkdir -p ${DIST_DIR}
@cd ${BUILD_DIR}/chromium/ && zip -r -FS ${PWD}/${DIST_DIR}/${VERSION}--chromium.zip ./* -x "**/.*"
@printf "\e[1m\e[32m✔ Done\e[0m\n\n"
package-all:
@$(MAKE) build-firefox
@$(MAKE) package-firefox
@$(MAKE) build-chromium
@$(MAKE) package-chromium
run-chrome:
@$(MAKE) build-chromium
@printf "\e[1m\e[94m♺ Launching Chrome …\e[0m\n"
@-${CHROME_BINARY} --user-data-dir=/tmp/mastodon-profile-redirect-dev --load-extension=${BUILD_DIR}/chromium --no-first-run &>/dev/null &
@printf "\e[1m\e[32m✔ Done\e[0m\n\n"
run-firefox:
@$(MAKE) build-firefox
@printf "\e[1m\e[94m♺ Launching Firefox …\e[0m\n"
@web-ext run &>/dev/null &
@printf "\e[1m\e[32m✔ Done\e[0m\n\n"