-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (59 loc) · 2.34 KB
/
Copy pathMakefile
File metadata and controls
72 lines (59 loc) · 2.34 KB
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
NPM := $(CURDIR)/node_modules
LIB := $(CURDIR)/lib/skia.node
LIB_SRC := Cargo.toml lib/prebuild.mjs $(wildcard src/*.rs) $(wildcard src/*/*.rs) $(wildcard src/*/*/*.rs)
GIT_TAG = $(shell git describe)
PACKAGE_VERSION = $(shell npm run env | grep npm_package_version | sed -e 's/^.*=/v/')
PRERELEASE_FLAG = $(subst -rc,--prerelease,$(findstring -rc,$(PACKAGE_VERSION)))
NPM_VERSION = $(shell npm view skia-canvas version)
.PHONY: optimized dev test debug visual check clean distclean release skia-version with-local-skia
.DEFAULT_GOAL := $(LIB)
$(NPM):
npm ci --ignore-scripts
$(LIB): $(NPM) $(LIB_SRC)
@npm run build -- dev
@touch $(LIB)
optimized: $(NPM)
@rm -f $(LIB)
@npm run build
dev: $(NPM) $(LIB_SRC)
@npm run build -- custom
@touch $(LIB)
test: $(LIB)
node --test
debug: $(LIB)
node --test --watch
visual: $(LIB)
@node --watch-path lib --watch-path tests/visual tests/visual
check:
cargo check
clean:
rm -f $(LIB)
distclean: clean
rm -rf $(NPM)
rm -rf $(CURDIR)/target/debug
rm -rf $(CURDIR)/target/release
cargo clean
release:
@if [[ `git status -s package.json` != "" ]]; then printf "Commit changes to package.json first:\n\n"; git --no-pager diff package.json; exit 1; fi
@if [[ `git cherry -v` != "" ]]; then printf "Unpushed commits:\n"; git --no-pager log --oneline main --not --remotes="*/main"; exit 1; fi
@if gh release view $(PACKAGE_VERSION) --json id > /dev/null; then printf "Already published $(PACKAGE_VERSION)\n"; exit 1; fi
@echo
@echo "Currently on NPM: $(NPM_VERSION)"
@echo "Last Git Tag: $(GIT_TAG)"
@echo "Package Version: $(PACKAGE_VERSION)"
@echo
@/bin/echo -n "Update release -> $(PACKAGE_VERSION)? [y/N] "
@read line; if [[ $$line = "y" ]]; then printf "\nPushing tag to github...\n"; else exit 1; fi
@git tag -a $(PACKAGE_VERSION) -m $(PACKAGE_VERSION)
@git push origin --tags
@printf "\nCreating new release...\n"
@gh release create $(PACKAGE_VERSION) $(PRERELEASE_FLAG) --draft --fail-on-no-commits --generate-notes
@printf "\nNext: publish the release on github to submit to npm\n"
# linux-build helpers
skia-version:
@grep -m 1 '^skia-safe' Cargo.toml | egrep -o '[0-9\.]+'
with-local-skia:
echo '' >> Cargo.toml
echo '[patch.crates-io]' >> Cargo.toml
echo 'skia-safe = { path = "../rust-skia/skia-safe" }' >> Cargo.toml
echo 'skia-bindings = { path = "../rust-skia/skia-bindings" }' >> Cargo.toml