-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Makefile
72 lines (56 loc) · 2.71 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
# For generating .wasm files for parsers
# See https://www.npmjs.com/package/web-tree-sitter
LANGUAGES = agda bash c c-sharp clojure cpp css dart elm elixir gleam go haskell hcl html java javascript json julia kotlin latex lua markdown nix perl php python query ruby rust scala scss sparql swift talon tsx typescript xml yaml
# Build web-tree-sitter parsers for $(LANGUAGES)
.PHONY: parsers
parsers: $(addprefix parsers/tree-sitter-,$(addsuffix .wasm,$(LANGUAGES)))
parsers/%.wasm: node_modules/%/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-elm.wasm: node_modules/@elm-tooling/tree-sitter-elm/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-markdown.wasm: node_modules/tree-sitter-markdown/tree-sitter-markdown/grammar.js
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-typescript.wasm: node_modules/tree-sitter-typescript/typescript/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-tsx.wasm: node_modules/tree-sitter-typescript/tsx/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-xml.wasm: node_modules/tree-sitter-xml/xml/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-php.wasm: node_modules/tree-sitter-php/php/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv $(notdir $@) $@
parsers/tree-sitter-c-sharp.wasm: node_modules/tree-sitter-c-sharp/package.json
mkdir -p $(dir $@)
npx tree-sitter build --wasm $(dir $^)
mv tree-sitter-c_sharp.wasm $@
# Build web-tree-sitter
WEB_TREE_SITTER_FILES := README.md package.json tree-sitter-web.d.ts tree-sitter.js tree-sitter.wasm
WEB_TREE_SITTER_DIR := vendor/web-tree-sitter
MAKE_CACHE_DIR := .make-work
.PHONY: web-tree-sitter
web-tree-sitter: $(addprefix $(WEB_TREE_SITTER_DIR)/,$(WEB_TREE_SITTER_FILES))
$(addprefix $(WEB_TREE_SITTER_DIR)/,$(WEB_TREE_SITTER_FILES)): tree-sitter-version
@rm -rf $(MAKE_CACHE_DIR)/tree-sitter
@TREE_SITTER_VERSION=$(shell cat tree-sitter-version) ;\
mkdir -p $(MAKE_CACHE_DIR)/tree-sitter && \
curl -L https://api.github.com/repos/tree-sitter/tree-sitter/tarball/$$TREE_SITTER_VERSION | \
tar -xz -C $(MAKE_CACHE_DIR)/tree-sitter --strip-components=1
@cd $(MAKE_CACHE_DIR)/tree-sitter && \
./script/build-wasm
@mkdir -p $(WEB_TREE_SITTER_DIR)
@cp $(MAKE_CACHE_DIR)/tree-sitter/LICENSE $(WEB_TREE_SITTER_DIR)
@cp $(addprefix $(MAKE_CACHE_DIR)/tree-sitter/lib/binding_web/,$(WEB_TREE_SITTER_FILES)) $(WEB_TREE_SITTER_DIR)
@rm -rf $(MAKE_CACHE_DIR)/tree-sitter