forked from hypothesis/browser-extension
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
97 lines (82 loc) · 3.09 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
SETTINGS_FILE := settings/chrome-dev.json
BROWSERIFY := node_modules/.bin/browserify
ESLINT := node_modules/.bin/eslint
EXORCIST := node_modules/.bin/exorcist
MUSTACHE := node_modules/.bin/mustache
PRETTIER := node_modules/.bin/prettier
.PHONY: default
default: extension
.PHONY: clean
clean:
rm -rf build/* build/.settings.json build/.*.deps
rm -rf dist/*
################################################################################
# We write the settings found in SETTINGS_FILE to build/.settings.json (when the
# contents change) in order to ensure that a different SETTINGS_FILE results in
# the appropriate things being rebuilt.
.PHONY: force
build/.settings.json: force
@tools/settings.js $(SETTINGS_FILE) | \
cmp -s - $@ || \
tools/settings.js $(SETTINGS_FILE) >$@
EXTENSION_SRC := pdfjs help images options
.PHONY: extension
extension: build/extension.bundle.js
extension: build/manifest.json
extension: build/client/build
extension: build/client/app.html
extension: build/settings-data.js
extension: build/unload-client.js
extension: build/pdfjs-init.js
extension: $(addprefix build/,$(EXTENSION_SRC))
build/extension.bundle.js: src/background/index.js
$(BROWSERIFY) -t babelify -d $< > [email protected]
cat [email protected] | $(EXORCIST) $(addsuffix .map,$@) >$@
@# When building the extension bundle, we also write out a list of
@# depended-upon files to .extension.bundle.deps, which we then include to
@# ensure that the bundle is rebuilt if any of these change. We ignore
@# vendor dependencies.
@$(BROWSERIFY) --list $< | \
grep -v node_modules | \
sed 's#^#$@: #' \
>build/.extension.bundle.deps
build/manifest.json: src/manifest.json.mustache build/.settings.json
$(MUSTACHE) build/.settings.json $< > $@
build/client/build: node_modules/unofficial-hypothesis/build/manifest.json
@mkdir -p $@
cp -R node_modules/unofficial-hypothesis/build/* $@
@# We can't leave the client manifest in the build or the Chrome Web Store
@# will complain.
rm $@/manifest.json
@# Add a serializable expression as the last statement in the boot script
@# bundle, otherwise Firefox will complain if attempting to execute the Browserify
@# bundle that the "Script returned non-structured-clonable data"
echo "null" >> build/client/build/boot.js
build/client/app.html: src/sidebar-app.html.mustache build/client build/.settings.json
tools/template-context-app.js build/.settings.json | $(MUSTACHE) - $< >$@
build/settings-data.js: src/settings-data.js.mustache build/client build/.settings.json
tools/template-context-settings.js build/.settings.json | $(MUSTACHE) - $< >$@
build/unload-client.js: src/unload-client.js
cp $< $@
build/pdfjs-init.js: src/pdfjs-init.js
cp $< $@
build/pdfjs: src/vendor/pdfjs
cp -R $< $@
build/%: src/%
@mkdir -p $@
cp -R $</* $@
dist/%.zip dist/%.xpi: extension
cd build && find . -not -path '*/\.*' -type f | zip -q -@ $(abspath $@)
.PHONY: lint
lint:
$(ESLINT) .
.PHONY: checkformatting
checkformatting:
$(PRETTIER) --check 'src/**/*.js' 'tests/**/*.js'
.PHONY: format
format:
$(PRETTIER) --list-different --write 'src/**/*.js' 'tests/**/*.js'
.PHONY: test
test:
npm test
-include build/.*.deps