-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
97 lines (68 loc) · 2.18 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
.PHONY: build-addon coverage coverage-lcov format format-cpp lint lint-cpp \
lint-cpp-ci lint-js test test-tap
prebuildify = ./node_modules/.bin/prebuildify
prebuildify-cross = ./node_modules/.bin/prebuildify-cross
# hack, otherwise GitHub Actions for Windows:
# '.' is not recognized as an internal or external command, operable program or batch file.
build-addon:
$(prebuildify) --target [email protected] --napi --strip && node -p "process.platform"
build-addon-linux:
$(prebuildify-cross) -i centos7-devtoolset7 -i alpine --target [email protected] --napi --strip
nyc = ./node_modules/.bin/nyc
coverage:
$(nyc) node test/index.js
coverage-lcov: coverage
$(nyc) report -r lcov
format_cpp_files = ./src/addon.cc
format: format-cpp
format-cpp:
clang-format -i -verbose $(format_cpp_files)
standard = ./node_modules/.bin/standard
lint_dir = build/lint
lint: lint-cpp lint-js
lint-cpp:
mkdir -p $(lint_dir)/cpp/src
rsync -a --delete src/ $(lint_dir)/cpp/src
cd $(lint_dir)/cpp && clang-format -i -verbose $(format_cpp_files)
git diff --no-index --exit-code src $(lint_dir)/cpp/src
# `-verbose` not exists in [email protected]
# See https://github.com/actions/virtual-environments/issues/46
lint-cpp-ci:
clang-format -i $(format_cpp_files)
git diff --exit-code --color=always
lint-js:
$(standard)
package_dir = build/package
package_include_dirs = \
lib \
prebuilds \
src
package_include_files = \
binding.gyp \
bindings.js \
index.js \
js.js \
LICENSE \
package.json \
README.md
package: package-copy-files package-fix-packagejson package-pack package-copy
package-copy-files:
mkdir -p $(package_dir)
for loc in $(package_include_dirs); do \
rsync -a --delete $$loc $(package_dir); \
done
cp $(package_include_files) $(package_dir)
package-fix-packagejson:
util/package-fix-packagejson.js -f $(package_dir)/package.json
package-pack:
cd $(package_dir) && npm pack
package-copy:
cp $(package_dir)/keccak-`node -p "require('./package.json').version"`.tgz .
tape = ./node_modules/.bin/tape
tap_reporter = ./node_modules/.bin/tap-dot
test_files = test/index.js
test:
$(tape) $(test_files) | $(tap_reporter)
# See build-addon
test-tap:
$(tape) $(test_files) && node -p "process.platform"